Module: MiniBot::Commands

Includes:
Events::Constants
Included in:
Daemon
Defined in:
lib/minibot/commands.rb

Constant Summary

Constants included from Events::Constants

Events::Constants::ERR_NICKNAMEINUSE, Events::Constants::EXPECTED_REPLIES_TOPIC, Events::Constants::RPL_NOTOPIC, Events::Constants::RPL_TOPIC, Events::Constants::RPL_TOPIC_META, Events::Constants::RPL_WELCOME

Instance Method Summary collapse

Instance Method Details

#join(*channels) ⇒ Object



7
8
9
# File 'lib/minibot/commands.rb', line 7

def join(*channels)
  channels.each { |channel| server.write "JOIN #{channel}" }
end

#nickserv(command) ⇒ Object



35
36
37
# File 'lib/minibot/commands.rb', line 35

def nickserv(command)
  @server.write "NICKSERV #{command}"
end

#say(target, message) ⇒ Object



24
25
# File 'lib/minibot/commands.rb', line 24

def say(target, message)
end

#set_nick(nick) ⇒ Object



31
32
33
# File 'lib/minibot/commands.rb', line 31

def set_nick(nick)
  @server.write "NICK #{nick}"
end

#set_user(username, realname) ⇒ Object



27
28
29
# File 'lib/minibot/commands.rb', line 27

def set_user(username, realname)
  @server.write "USER #{username} 0 xxx :#{realname}"
end

#topic(channel) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/minibot/commands.rb', line 11

def topic(channel)
  topic = author = timestamp = nil
  server.write "TOPIC #{channel}", *EXPECTED_REPLIES_TOPIC do |code, reply|
    if code == RPL_TOPIC
      channel, topic = reply.split /\s+/, 2
    elsif code == RPL_TOPIC_META
      channel, author, timestamp = *reply.split
    end
  end

  [ topic && topic[1 .. -1], author, timestamp && Time.at(timestamp.to_i) ] 
end