Class: LogBot::Daemon
- Inherits:
-
MiniBot::Daemon
- Object
- MiniBot::Daemon
- LogBot::Daemon
- Defined in:
- lib/logbot/daemon.rb
Instance Method Summary collapse
- #action(channel, nick, msg) ⇒ Object
- #invited(channel, nick) ⇒ Object
- #kicked(channel, nick, message) ⇒ Object
- #message(channel, nick, msg) ⇒ Object
- #ready ⇒ Object
- #topic_changed(channel, nick, topic) ⇒ Object
- #user_joined(channel, nick) ⇒ Object
- #user_parted(channel, nick) ⇒ Object
Instance Method Details
#action(channel, nick, msg) ⇒ Object
26 27 28 |
# File 'lib/logbot/daemon.rb', line 26 def action(channel, nick, msg) Event.create :type => :action, :channel => channel, :nick => nick, :content => msg end |
#invited(channel, nick) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/logbot/daemon.rb', line 10 def invited(channel, nick) unless Channel.get(channel) join channel topic_fields = [:topic_message, :topic_author, :topic_created_on] tpic = Hash[ *topic_fields.zip(topic channel).flatten ] tpic[:topic_created_on] = Date.parse(tpic[:topic_created_on].strftime('%Y/%m/%d')) \ if tpic[:topic_created_on] Channel.create({ :name => channel }.merge(tpic).inject({}) { |h, (k, v)| h[k.to_sym] = v; h }) end end |
#kicked(channel, nick, message) ⇒ Object
22 23 24 |
# File 'lib/logbot/daemon.rb', line 22 def kicked(channel, nick, ) Channel.all(:name => channel).destroy!; end |
#message(channel, nick, msg) ⇒ Object
6 7 8 |
# File 'lib/logbot/daemon.rb', line 6 def (channel, nick, msg) Event.create :type => :message, :channel => channel, :nick => nick, :content => msg end |
#ready ⇒ Object
42 43 44 |
# File 'lib/logbot/daemon.rb', line 42 def ready join *Channel.all.map { |c| c.name } end |
#topic_changed(channel, nick, topic) ⇒ Object
38 39 40 |
# File 'lib/logbot/daemon.rb', line 38 def topic_changed(channel, nick, topic) Event.create :type => :topic_changed, :channel => channel, :nick => nick, :content => topic end |
#user_joined(channel, nick) ⇒ Object
30 31 32 |
# File 'lib/logbot/daemon.rb', line 30 def user_joined(channel, nick) Event.create :type => :user_joined, :channel => channel, :nick => nick end |
#user_parted(channel, nick) ⇒ Object
34 35 36 |
# File 'lib/logbot/daemon.rb', line 34 def user_parted(channel, nick) Event.create :type => :user_parted, :channel => channel, :nick => nick end |