Module: IrcCommands

Included in:
Imouto::Irc
Defined in:
lib/irc_commands.rb

Instance Method Summary collapse

Instance Method Details

#channel_mode(channel, state, mode, modeparams = '') ⇒ Object



26
27
28
29
# File 'lib/irc_commands.rb', line 26

def channel_mode(channel, state, mode, modeparams = '')
  return false unless %w(O o v a i m n q p s r t k l b e I).include? mode
  raw "MODE #{channel} #{state} #{mode} #{modeparams}"
end

#invite(nick, channel) ⇒ Object



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

def invite(nick, channel)
  raw "INVITE #{nick} #{channel}"
end

#join(channels) ⇒ Object



16
17
18
19
# File 'lib/irc_commands.rb', line 16

def join(channels)
  channels.respond_to?('join') && channels = channels.join(',')
  raw "JOIN #{channels}"
end

#kick(channel, user, reason = '') ⇒ Object



39
40
41
# File 'lib/irc_commands.rb', line 39

def kick(channel, user, reason = '')
  raw "KICK #{channel} #{user} :#{reason}"
end

#mode(nick, state, mode) ⇒ Object



7
8
9
10
# File 'lib/irc_commands.rb', line 7

def mode(nick, state, mode)
  return false unless %w(a i w r o O s).include? mode
  raw "MODE #{nick} #{state}#{mode}"
end

#notice(target, msg) ⇒ Object



47
48
49
# File 'lib/irc_commands.rb', line 47

def notice(target, msg)
  raw "NOTICE #{target} :#{msg}"
end

#part(channels, msg = '') ⇒ Object



21
22
23
24
# File 'lib/irc_commands.rb', line 21

def part(channels, msg = '')
  channels.respond_to?('join') && channels = channels.join(',')
  raw "PART #{channels} :#{msg}"
end

#privmsg(target, msg) ⇒ Object



43
44
45
# File 'lib/irc_commands.rb', line 43

def privmsg(target, msg)
  raw "PRIVMSG #{target} :#{msg}"
end

#quit(msg = '') ⇒ Object



12
13
14
# File 'lib/irc_commands.rb', line 12

def quit(msg = '')
  raw "QUIT :#{msg}"
end

#raw(string) ⇒ Object

Overwrite raw() to send to your socket wherever you include this



3
4
5
# File 'lib/irc_commands.rb', line 3

def raw(string)
  puts string
end

#topic(channel, topic) ⇒ Object



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

def topic(channel, topic)
  raw "TOPIC #{channel} :#{topic}"
end