Browse files

Added ability to query for older log messages

  • Loading branch information...
1 parent 8b9f1b7 commit 6fdbc1984ea235a59cf56537130297fe8ecdea3b @davglass committed Feb 7, 2009
Showing with 23 additions and 0 deletions.
  1. +23 −0 logger/logger.rb
View
23 logger/logger.rb
@@ -74,6 +74,28 @@ def help(plugin, topic="")
"Logger: log all irc traffic to a database"
end
+ def replay(m, args)
+ nick = m.source.nick
+ channel = m.channel.to_s
+ begin
+ @dbconn.ping()
+ rescue
+ connect()
+ end
+ channel_sql = ""
+ if channel
+ channel_sql = " (channel = '#{channel}') and "
+ end
+
+ sql = "select #{@whoColumn}, #{@whatColumn} from #{@tableName} where #{channel_sql} (UNIX_TIMESTAMP(stamp) > (UNIX_TIMESTAMP(NOW()) - (60 * #{args[:time]})))"
+ @bot.say nick, "#{nick}, Replaying log from #{args[:time]} minutes ago for #{channel}.."
+ res = @dbconn.query(sql)
+ while row = res.fetch_row do
+ @bot.say nick, "#{row[0]}: #{row[1]}"
+ end
+
+ end
+
def listen(m)
if @listen
if not m.private?
@@ -95,3 +117,4 @@ def listen(m)
end
plugin = Logger.new
+plugin.map 'logger replay :time [*10]', :action => 'replay'

0 comments on commit 6fdbc19

Please sign in to comment.