Module: Flamethrower::Irc::Commands
- Includes:
- Codes
- Included in:
- Connection
- Defined in:
- lib/flamethrower/irc/commands.rb
Constant Summary
Constants included
from Codes
Flamethrower::Irc::Codes::ERR_BADCHANNELKEY, Flamethrower::Irc::Codes::ERR_UNKNOWNCOMMAND, Flamethrower::Irc::Codes::RPL_CHANNELMODEIS, Flamethrower::Irc::Codes::RPL_ENDOFMOTD, Flamethrower::Irc::Codes::RPL_ENDOFNAMES, Flamethrower::Irc::Codes::RPL_ENDOFWHO, Flamethrower::Irc::Codes::RPL_MOTD, Flamethrower::Irc::Codes::RPL_MOTDSTART, Flamethrower::Irc::Codes::RPL_NAMEREPLY, Flamethrower::Irc::Codes::RPL_NOWAWAY, Flamethrower::Irc::Codes::RPL_TOPIC, Flamethrower::Irc::Codes::RPL_UMODEIS, Flamethrower::Irc::Codes::RPL_UNAWAY, Flamethrower::Irc::Codes::RPL_WHOREPLY, Flamethrower::Irc::Codes::RPL_WLCM
Instance Method Summary
collapse
Instance Method Details
#error(code) ⇒ Object
84
85
86
|
# File 'lib/flamethrower/irc/commands.rb', line 84
def error(code)
":#{@current_user.hostname} #{code}"
end
|
#reply(code, message) ⇒ Object
80
81
82
|
# File 'lib/flamethrower/irc/commands.rb', line 80
def reply(code, message)
":#{@current_user.hostname} #{code} #{@current_user.nickname} #{message}"
end
|
#send_channel_list ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/flamethrower/irc/commands.rb', line 21
def send_channel_list
send_messages do |messages|
messages << reply(RPL_MOTD, ":Active channels:")
@irc_channels.each do |channel|
messages << reply(RPL_MOTD, ":#{channel.name} - #{channel.topic}")
end
messages << reply(RPL_ENDOFMOTD, ":End of channel list /MOTD")
end
end
|
#send_channel_mode(channel) ⇒ Object
60
61
62
|
# File 'lib/flamethrower/irc/commands.rb', line 60
def send_channel_mode(channel)
send_message reply(RPL_CHANNELMODEIS, "#{channel.name} #{channel.mode}")
end
|
#send_join(user, channel) ⇒ Object
72
73
74
|
# File 'lib/flamethrower/irc/commands.rb', line 72
def send_join(user, channel)
send_message ":#{user.to_s} JOIN #{channel.name}"
end
|
#send_motd ⇒ Object
10
11
12
13
14
15
|
# File 'lib/flamethrower/irc/commands.rb', line 10
def send_motd
send_messages do |messages|
messages << reply(RPL_MOTDSTART, ":MOTD")
messages << reply(RPL_MOTD, ":Fetching channel list from campfire...")
end
end
|
#send_nowaway ⇒ Object
43
44
45
|
# File 'lib/flamethrower/irc/commands.rb', line 43
def send_nowaway
send_message reply(RPL_NOWAWAY, ":You have been marked as being away")
end
|
#send_part(user, channel) ⇒ Object
76
77
78
|
# File 'lib/flamethrower/irc/commands.rb', line 76
def send_part(user, channel)
send_message ":#{user.to_s} PART #{channel.name}"
end
|
#send_pong(hostname) ⇒ Object
64
65
66
|
# File 'lib/flamethrower/irc/commands.rb', line 64
def send_pong(hostname)
send_message "PONG :#{hostname}"
end
|
#send_rename(from, to) ⇒ Object
39
40
41
|
# File 'lib/flamethrower/irc/commands.rb', line 39
def send_rename(from, to)
send_message ":#{from} NICK #{to}"
end
|
#send_topic(channel) ⇒ Object
17
18
19
|
# File 'lib/flamethrower/irc/commands.rb', line 17
def send_topic(channel)
send_message reply(RPL_TOPIC, "#{channel.name} :#{channel.topic}")
end
|
#send_unaway ⇒ Object
47
48
49
|
# File 'lib/flamethrower/irc/commands.rb', line 47
def send_unaway
send_message reply(RPL_UNAWAY, ":You are no longer marked as being away")
end
|
#send_user_mode ⇒ Object
68
69
70
|
# File 'lib/flamethrower/irc/commands.rb', line 68
def send_user_mode
send_message reply(RPL_UMODEIS, @current_user.mode)
end
|
#send_userlist(channel) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/flamethrower/irc/commands.rb', line 31
def send_userlist(channel)
send_messages do |messages|
display_users = (["@#{@current_user.nickname}"] + channel.users.map(&:nickname)).join("\s")
messages << reply(RPL_NAMEREPLY, "= #{channel.name} :#{display_users}")
messages << reply(RPL_ENDOFNAMES, "#{channel.name} :/End of /NAMES list")
end
end
|
#send_welcome ⇒ Object
6
7
8
|
# File 'lib/flamethrower/irc/commands.rb', line 6
def send_welcome
send_message reply(RPL_WLCM, ":Welcome to Flamethrower")
end
|
#send_who(channel) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/flamethrower/irc/commands.rb', line 51
def send_who(channel)
send_messages do |messages|
channel.users.each do |user|
messages << reply(RPL_WHOREPLY, "#{channel.name} #{user.nickname} #{user.hostname} localhost #{user.nickname} H :0 #{user.nickname}")
end
messages << reply(RPL_ENDOFWHO, "#{channel.name} :/End of /WHO list")
end
end
|