-- weechat plugin require("string") require("io") weechat.register("logtofile", "0.1", "logtofile_cleanup", "Log messages to you to a file", "ISO-8859-1") weechat.add_message_handler ("weechat_pv", "logtofile_message_hanler") weechat.add_message_handler ("weechat_highlight", "logtofile_message_hanler") logtofile_name = os.getenv("HOME") .. "/.irc_ev" logtofile_io = nil function logtofile_message_hanler(server, args) if not logtofile_io then local err logtofile_io,err = io.open(logtofile_name, "a+") if logtofile_io then weechat.print("logtofile: logging to: " .. tostring(logtofile_name)) else weechat.print("logtofile: error: " .. tostring(err)) end end if logtofile_io then local who,chan,msg,txt txt = args who,chan,msg = string.match(txt, "^:(%w+)![^:]* PRIVMSG ([^: ]*) *:(.*)$") if who and msg then txt = chan .." <" .. who .. "> " .. msg end logtofile_io:write(tostring(server) .. ":" .. txt .. "\n") logtofile_io:flush() end return weechat.PLUGIN_RC_OK() end function logtofile_cleanup () logtofile_io:close() logtofile_io = nil end -- vim: sw=8 ts=8 noet: