From a951fd8e9f0d221db2c4dee98b6be4047435082c Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Fri, 8 Oct 2010 18:37:34 -0500 Subject: Save actions, better date format, various bug fixes --- conf/example.conf | 6 ++++-- logbot.py | 31 ++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/conf/example.conf b/conf/example.conf index af9a99c..4289321 100644 --- a/conf/example.conf +++ b/conf/example.conf @@ -2,7 +2,7 @@ server = irc.freenode.net port = 6667 server_password = password -channels = #keryx +channels = #excid3 nick = Timber nick_password = password @@ -21,8 +21,10 @@ join = -!- %user% [%host%] has joined %channel% kick = -!- %user% was kicked from %channel% by %kicker% [%reason%] mode = -!- mode/%channel% [%modes% %person%] by %giver% nick = %old% is now known as %new% -part = -!- %user% has parted %channel% +part = -!- %user% [%host%] has parted %channel% pubmsg = <%user%> %message% pubnotice = -%user%:%channel%- %message% quit = -!- %user% has quit [%reason%] topic = %user% changed topic of %channel% to: %topic% +action = * %user% %action% +help = Check out http://excid3.com \ No newline at end of file diff --git a/logbot.py b/logbot.py index d4187dc..ea731b4 100644 --- a/logbot.py +++ b/logbot.py @@ -73,6 +73,9 @@ class LogBot(SingleServerIRCBot): nickname) self.nick_pass = nick_pass self.chans = channels + + print "Logbot %s" % __version__ + print "Connecting to %s:%i" % (server, port) def set_format(self, folder, format, stylesheet): self.folder = folder @@ -89,6 +92,9 @@ class LogBot(SingleServerIRCBot): c.privmsg("nickserv", "identify %s" % self.nick_pass) for channel in self.chans: c.join(channel) + + print "Connected" + print "Press Ctrl-C to quit" def on_pubmsg(self, c, e): user = nm_to_n(e.source()) @@ -100,7 +106,16 @@ class LogBot(SingleServerIRCBot): .replace("%color%", color)) def on_invite(self, c, e): - pass + c.join(e.arguments()[0]) + + def on_action(self, c, e): + user = nm_to_n(e.source()) + action = e.arguments()[0] + channel = e.target() + color = gen_color(user) + self.write(channel, self.format["action"].replace("%user%", user) \ + .replace("%action%", action) \ + .replace("%color%", color)) def on_join(self, c, e): user = nm_to_n(e.source()) @@ -130,12 +145,14 @@ class LogBot(SingleServerIRCBot): def on_part(self, c, e): user = nm_to_n(e.source()) + host = e.source() channel = e.target() self.write(channel, self.format["part"].replace("%user%", user) \ + .replace("%host%", host) \ .replace("%channel%", channel)) def on_privmsg(self, c, e): - pass + c.privmsg(nm_to_n(e.source()), self.format["help"]) def on_topic(self, c, e): user = nm_to_n(e.source()) @@ -168,7 +185,7 @@ class LogBot(SingleServerIRCBot): def write(self, channel, message): time = strftime("%H:%M:%S") - date = strftime("%d-%m-%Y") + date = strftime("%Y-%m-%d") if channel: print "%s> %s %s" % (channel, time, message) channels = [channel] @@ -211,7 +228,7 @@ class LogBot(SingleServerIRCBot): str = "[%s] %s" % \ (time, time, time, message) - append_to_index(path, str, True) + append_to_index(path, str, True) def create_html_file(path, title): @@ -258,15 +275,15 @@ def main(conf): # Get the formation information types = ["join", "kick", "mode", "nick", "part", "pubmsg", "pubnotice", - "quit", "topic"] + "quit", "topic", "action"] format = {} for type in types: format[type] = CONFIG.get("format", type) bot = LogBot(server, port, server_pass, channels, owner, nick, nick_pass) bot.set_format(folder, format, stylesheet) - bot.start() - + try: bot.start() + except KeyboardInterrupt: pass if __name__ == "__main__": # Require a config -- cgit v1.2.3-70-g09d2