From 014d99acb4fa25f5c3d0f2a4bb814fab165a4210 Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Wed, 08 Jul 2009 19:33:53 +0000 Subject: Add a `recent` supybot command to list recent meetings - This is mainly to help audit use of the bot, see what channels and when are using it. Right now limits to history of the last 10 meetings. darcs-hash:20090708193353-82ea9-992a76035ab5237f89f686db12489587064166a3.gz --- (limited to 'plugin.py') diff --git a/plugin.py b/plugin.py index 7415e22..4080e6d 100644 --- a/plugin.py +++ b/plugin.py @@ -49,7 +49,8 @@ try: meeting_cache except NameError: meeting_cache = {} - + recent_meetings = [ ] + class MeetBot(callbacks.Plugin): """Add the help for "@plugin help MeetBot" here @@ -102,6 +103,10 @@ class MeetBot(callbacks.Plugin): M._sendReply = _sendReply # callback to get supybot registry values. M._registryValue = self.registryValue + recent_meetings.append( + (channel, irc.msg.tags['receivedOn'], time.ctime())) + if len(recent_meetings) > 10: + del recent_meetings[0] # If there is no meeting going on, then we quit if M is None: return # Add line to our meeting buffer. @@ -163,6 +168,18 @@ class MeetBot(callbacks.Plugin): irc.reply("Deleted: meeting on (%s, %s)."%(channel, network)) deletemeeting = wrap(deletemeeting, ['admin', "channel", "something", optional("boolean", True)]) + def recent(self, irc, msg, args): + reply = [] + for channel, network, ctime in recent_meetings: + Mkey = (channel,network) + if Mkey in meeting_cache: state = ", running" + else: state = "" + reply.append("(%s, %s, %s%s)"%(channel, network, ctime, state)) + if reply: + irc.reply(" ".join(reply)) + else: + irc.reply("No recent meetings in internal state.") + recent = wrap(recent, ['admin']) def pingall(self, irc, msg, args, message): """ -- cgit v0.9.1