Class: LogBot::Daemon

Inherits:
MiniBot::Daemon
  • Object
show all
Defined in:
lib/logbot/daemon.rb

Instance Method Summary collapse

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, message)
  Channel.all(:name => channel).destroy!;
end

#message(channel, nick, msg) ⇒ Object



6
7
8
# File 'lib/logbot/daemon.rb', line 6

def message(channel, nick, msg)
  Event.create :type => :message, :channel => channel, :nick => nick, :content => msg 
end

#readyObject



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