forked from g0v/Logbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogbot.rb.example
More file actions
31 lines (27 loc) · 762 Bytes
/
Copy pathlogbot.rb.example
File metadata and controls
31 lines (27 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require "json"
require "cinch"
require "redis"
channels = (ENV['LOGBOT_CHANNELS'] || '#test56').split /[\s,]+/
redis = Redis.new(:thread_safe => true)
channels.each do |chan|
redis.sadd("irclog:channels", "#{chan}")
end
bot = Cinch::Bot.new do
configure do |conf|
conf.server = (ENV['LOGBOT_SERVER'] || "irc.freenode.net")
conf.nick = (ENV['LOGBOT_NICK'] || "logbot_")
conf.channels = channels
end
on :message do |msg|
if not msg.channel.nil?
date = msg.time.strftime("%Y-%m-%d")
key = "irclog:channel:#{msg.channel.name}:#{date}"
redis.rpush(key, {
:time => "#{msg.time.strftime("%s.%L")}",
:nick => "#{msg.user.nick}",
:msg => "#{msg.message}"
}.to_json)
end
end
end
bot.start