ircguerilla-irc 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/irc/client/client_error.rb +35 -0
- data/lib/irc/client/command_handler.rb +113 -0
- data/lib/irc/client/connected_state.rb +95 -0
- data/lib/irc/client/connection.rb +119 -0
- data/lib/irc/client/connection_listener.rb +97 -0
- data/lib/irc/client/connection_state.rb +88 -0
- data/lib/irc/client/context.rb +250 -0
- data/lib/irc/client/disconnected_state.rb +132 -0
- data/lib/irc/client/message_handler.rb +87 -0
- data/lib/irc/client/registered_state.rb +90 -0
- data/lib/irc/client/unregistered_state.rb +113 -0
- data/lib/irc/commands/command.rb +57 -0
- data/lib/irc/commands/invalid_command.rb +35 -0
- data/lib/irc/commands/join_command.rb +122 -0
- data/lib/irc/commands/nick_command.rb +86 -0
- data/lib/irc/commands/part_command.rb +84 -0
- data/lib/irc/commands/password_command.rb +72 -0
- data/lib/irc/commands/ping_command.rb +79 -0
- data/lib/irc/commands/pong_command.rb +68 -0
- data/lib/irc/commands/quit_command.rb +77 -0
- data/lib/irc/commands/user_command.rb +105 -0
- data/lib/irc/messages/codes.rb +186 -0
- data/lib/irc/messages/error_join_message.rb +72 -0
- data/lib/irc/messages/error_message.rb +101 -0
- data/lib/irc/messages/factory.rb +122 -0
- data/lib/irc/messages/invalid_message.rb +35 -0
- data/lib/irc/messages/join_message.rb +130 -0
- data/lib/irc/messages/message.rb +110 -0
- data/lib/irc/messages/nick_message.rb +93 -0
- data/lib/irc/messages/notice_message.rb +87 -0
- data/lib/irc/messages/part_message.rb +95 -0
- data/lib/irc/messages/ping_message.rb +101 -0
- data/lib/irc/messages/pong_message.rb +89 -0
- data/lib/irc/messages/private_message.rb +121 -0
- data/lib/irc/models/bot.rb +159 -0
- data/lib/irc/models/channel.rb +158 -0
- data/lib/irc/models/network.rb +252 -0
- data/lib/irc/models/packet.rb +84 -0
- data/lib/irc/models/server.rb +116 -0
- data/lib/irc/models/user.rb +112 -0
- data/test/functional/irc/client/connection_test.rb +118 -0
- data/test/functional/irc/client/context_test.rb +126 -0
- data/test/test_helper.rb +32 -0
- data/test/unit/irc/client/command_handler_test.rb +137 -0
- data/test/unit/irc/commands/join_command_test.rb +72 -0
- data/test/unit/irc/commands/nick_command_test.rb +35 -0
- data/test/unit/irc/commands/part_command_test.rb +52 -0
- data/test/unit/irc/commands/password_command_test.rb +35 -0
- data/test/unit/irc/commands/ping_command_test.rb +36 -0
- data/test/unit/irc/commands/pong_command_test.rb +36 -0
- data/test/unit/irc/commands/quit_command_test.rb +35 -0
- data/test/unit/irc/commands/user_command_test.rb +35 -0
- data/test/unit/irc/messages/error_join_message_test.rb +45 -0
- data/test/unit/irc/messages/factory_test.rb +62 -0
- data/test/unit/irc/messages/join_message_test.rb +46 -0
- data/test/unit/irc/messages/message_test.rb +56 -0
- data/test/unit/irc/messages/nick_message_test.rb +48 -0
- data/test/unit/irc/messages/notice_message_test.rb +43 -0
- data/test/unit/irc/messages/part_message_test.rb +47 -0
- data/test/unit/irc/messages/ping_message_test.rb +57 -0
- data/test/unit/irc/messages/pong_message_test.rb +57 -0
- data/test/unit/irc/messages/private_message_test.rb +42 -0
- data/test/unit/irc/models/bot_test.rb +85 -0
- data/test/unit/irc/models/channel_test.rb +90 -0
- data/test/unit/irc/models/network_test.rb +210 -0
- data/test/unit/irc/models/packet_test.rb +38 -0
- data/test/unit/irc/models/server_test.rb +54 -0
- data/test/unit/irc/models/user_test.rb +67 -0
- metadata +111 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# $Id: nick_command.rb 85 2006-08-13 11:42:07Z roman $
|
25
|
+
#
|
26
|
+
require 'irc/commands/command'
|
27
|
+
require 'irc/commands/invalid_command'
|
28
|
+
|
29
|
+
module IRC
|
30
|
+
|
31
|
+
module Commands
|
32
|
+
|
33
|
+
# 4.1.2 Nick message
|
34
|
+
#
|
35
|
+
# Command: NICK
|
36
|
+
# Parameters: <nickname> [ <hopcount> ]
|
37
|
+
#
|
38
|
+
# NICK message is used to give user a nickname or change the previous one. The
|
39
|
+
# <hopcount> parameter is only used by servers to indicate how far away a nick
|
40
|
+
# is from its home server. A local connection has a hopcount of 0. If supplied
|
41
|
+
# by a client, it must be ignored.
|
42
|
+
#
|
43
|
+
# If a NICK message arrives at a server which already knows about an identical
|
44
|
+
# nickname for another client, a nickname collision occurs. As a result of a
|
45
|
+
# nickname collision, all instances of the nickname are removed from the server's
|
46
|
+
# database, and a KILL command is issued to remove the nickname from all other
|
47
|
+
# server's database. If the NICK message causing the collision was a nickname
|
48
|
+
# change, then the original (old) nick must be removed as well.
|
49
|
+
#
|
50
|
+
# If the server recieves an identical NICK from a client which is directly
|
51
|
+
# connected, it may issue an ERR_NICKCOLLISION to the local client, drop the NICK
|
52
|
+
# command, and not generate any kills.
|
53
|
+
#
|
54
|
+
# Numeric Replies:
|
55
|
+
#
|
56
|
+
# ERR_NONICKNAMEGIVEN
|
57
|
+
# ERR_ERRONEUSNICKNAME
|
58
|
+
# ERR_NICKNAMEINUSE
|
59
|
+
# ERR_NICKCOLLISION
|
60
|
+
#
|
61
|
+
# Example:
|
62
|
+
#
|
63
|
+
# NICK Wiz ; Introducing new nick "Wiz".
|
64
|
+
#
|
65
|
+
# :WiZ NICK Kilroy ; WiZ changed his nickname to Kilroy.
|
66
|
+
#
|
67
|
+
class NickCommand < Command
|
68
|
+
|
69
|
+
attr_reader :nick
|
70
|
+
attr_reader :hopcount
|
71
|
+
|
72
|
+
def initialize(nick, hopcount = nil)
|
73
|
+
raise InvalidCommand.new("Can't create nick command. No nick name.") unless nick
|
74
|
+
@nick = nick
|
75
|
+
@hopcount = hopcount
|
76
|
+
end
|
77
|
+
|
78
|
+
def command
|
79
|
+
return "NICK #{nick} #{hopcount ? hopcount.to_s : ''}"
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# $Id: part_command.rb 85 2006-08-13 11:42:07Z roman $
|
25
|
+
#
|
26
|
+
require 'irc/commands/command'
|
27
|
+
require 'irc/commands/invalid_command'
|
28
|
+
|
29
|
+
module IRC
|
30
|
+
|
31
|
+
module Commands
|
32
|
+
|
33
|
+
# 4.2.2 Part message
|
34
|
+
#
|
35
|
+
# Command: PART
|
36
|
+
# Parameters: <channel>{,<channel>}
|
37
|
+
#
|
38
|
+
# The PART message causes the client sending the message to be removed
|
39
|
+
# from the list of active users for all given channels listed in the
|
40
|
+
# parameter string.
|
41
|
+
#
|
42
|
+
# Numeric Replies:
|
43
|
+
#
|
44
|
+
# ERR_NEEDMOREPARAMS
|
45
|
+
# ERR_NOSUCHCHANNEL
|
46
|
+
# ERR_NOTONCHANNEL
|
47
|
+
#
|
48
|
+
# Examples:
|
49
|
+
#
|
50
|
+
# PART #twilight_zone ; leave channel "#twilight_zone"
|
51
|
+
#
|
52
|
+
# PART #oz-ops,&group5 ; leave both channels "&group5" and
|
53
|
+
# ; "#oz-ops".
|
54
|
+
#
|
55
|
+
class PartCommand < Command
|
56
|
+
|
57
|
+
attr_reader :channels
|
58
|
+
|
59
|
+
def initialize(channels)
|
60
|
+
|
61
|
+
raise InvalidCommand.new("Can't create part command. No channels.") unless channels
|
62
|
+
|
63
|
+
if channels.instance_of?(Array)
|
64
|
+
|
65
|
+
@channels = channels
|
66
|
+
|
67
|
+
else
|
68
|
+
|
69
|
+
@channels = Array.new
|
70
|
+
@channels << channels
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def command
|
77
|
+
return "PART #{channels.join(',')}"
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# $Id: password_command.rb 85 2006-08-13 11:42:07Z roman $
|
25
|
+
#
|
26
|
+
require 'irc/commands/command'
|
27
|
+
require 'irc/commands/invalid_command'
|
28
|
+
|
29
|
+
module IRC
|
30
|
+
|
31
|
+
module Commands
|
32
|
+
|
33
|
+
# 4.1.1 Password message
|
34
|
+
#
|
35
|
+
# Command: PASS
|
36
|
+
# Parameters: <password>
|
37
|
+
#
|
38
|
+
# The PASS command is used to set a 'connection password'. The password can and must
|
39
|
+
# be set before any attempt to register the connection is made. Currently this requires
|
40
|
+
# that clients send a PASS command before sending the NICK/USER combination and servers
|
41
|
+
# *must* send a PASS command before any SERVER command. The password supplied must match
|
42
|
+
# the one contained in the C/N lines (for servers) or I lines (for clients). It is
|
43
|
+
# possible to send multiple PASS commands before registering but only the last one sent
|
44
|
+
# is used for verification and it may not be changed once registered.
|
45
|
+
#
|
46
|
+
# Numeric Replies:
|
47
|
+
#
|
48
|
+
# ERR_NEEDMOREPARAMS
|
49
|
+
# ERR_ALREADYREGISTRED
|
50
|
+
#
|
51
|
+
# Example:
|
52
|
+
#
|
53
|
+
# PASS secretpasswordhere
|
54
|
+
#
|
55
|
+
class PasswordCommand < Command
|
56
|
+
|
57
|
+
attr_reader :password
|
58
|
+
|
59
|
+
def initialize(password)
|
60
|
+
raise InvalidCommand.new("Can't create password command. No password.") unless password
|
61
|
+
@password = password
|
62
|
+
end
|
63
|
+
|
64
|
+
def command
|
65
|
+
return "PASS #{password}"
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# $Id: ping_command.rb 85 2006-08-13 11:42:07Z roman $
|
25
|
+
#
|
26
|
+
require 'irc/commands/command'
|
27
|
+
require 'irc/commands/invalid_command'
|
28
|
+
|
29
|
+
module IRC
|
30
|
+
|
31
|
+
module Commands
|
32
|
+
|
33
|
+
# 4.6.2 Ping message
|
34
|
+
#
|
35
|
+
# Command: PING
|
36
|
+
# Parameters: <server1> [<server2>]
|
37
|
+
#
|
38
|
+
# The PING message is used to test the presence of an active client at the other end of
|
39
|
+
# the connection. A PING message is sent at regular intervals if no other activity detected
|
40
|
+
# coming from a connection. If a connection fails to respond to a PING command within a set
|
41
|
+
# amount of time, that connection is closed.
|
42
|
+
#
|
43
|
+
# Any client which receives a PING message must respond to <server1> (server which sent the
|
44
|
+
# PING message out) as quickly as possible with an appropriate PONG message to indicate it
|
45
|
+
# is still there and alive. Servers should not respond to PING commands but rely on PINGs
|
46
|
+
# from the other end of the connection to indicate the connection is alive. If the <server2>
|
47
|
+
# parameter is specified, the PING message gets forwarded there.
|
48
|
+
#
|
49
|
+
# Numeric Replies:
|
50
|
+
# * ERR_NOORIGIN
|
51
|
+
# * ERR_NOSUCHSERVER
|
52
|
+
#
|
53
|
+
# Examples:
|
54
|
+
#
|
55
|
+
# PING tolsun.oulu.fi ; server sending a PING message to
|
56
|
+
# another server to indicate it is still
|
57
|
+
# alive.
|
58
|
+
#
|
59
|
+
# PING WiZ ; PING message being sent to nick WiZ
|
60
|
+
#
|
61
|
+
class PingCommand < Command
|
62
|
+
|
63
|
+
attr_reader :first_server
|
64
|
+
attr_reader :second_server
|
65
|
+
|
66
|
+
def initialize(first_server, second_server = nil)
|
67
|
+
raise InvalidCommand.new("Can't create ping command. No server.") unless first_server
|
68
|
+
@first_server, @second_server = first_server, second_server
|
69
|
+
end
|
70
|
+
|
71
|
+
def command
|
72
|
+
return "PING #{first_server} #{second_server != nil ? second_server.to_s : ''}".strip
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# $Id: pong_command.rb 85 2006-08-13 11:42:07Z roman $
|
25
|
+
#
|
26
|
+
require 'irc/commands/command'
|
27
|
+
require 'irc/commands/invalid_command'
|
28
|
+
|
29
|
+
module IRC
|
30
|
+
|
31
|
+
module Commands
|
32
|
+
|
33
|
+
# 4.6.3 Pong message
|
34
|
+
#
|
35
|
+
# Command: PONG
|
36
|
+
# Parameters: <daemon> [<daemon2>]
|
37
|
+
#
|
38
|
+
# PONG message is a reply to ping message. If parameter <daemon2> is given this message must
|
39
|
+
# be forwarded to given daemon. The <daemon> parameter is the name of the daemon who has responded
|
40
|
+
# to PING message and generated this message.
|
41
|
+
#
|
42
|
+
# Numeric Replies:
|
43
|
+
# * ERR_NOORIGIN
|
44
|
+
# * ERR_NOSUCHSERVER
|
45
|
+
#
|
46
|
+
# Examples:
|
47
|
+
#
|
48
|
+
# PONG csd.bu.edu tolsun.oulu.fi ; PONG message from csd.bu.edu to
|
49
|
+
#
|
50
|
+
class PongCommand < Command
|
51
|
+
|
52
|
+
attr_reader :first_daemon
|
53
|
+
attr_reader :second_daemon
|
54
|
+
|
55
|
+
def initialize(first_daemon, second_daemon = nil)
|
56
|
+
raise InvalidCommand.new("Can't create ping command. No daemon.") unless first_daemon
|
57
|
+
@first_daemon, @second_daemon = first_daemon, second_daemon
|
58
|
+
end
|
59
|
+
|
60
|
+
def command
|
61
|
+
return "PONG #{first_daemon} #{second_daemon != nil ? second_daemon.to_s : ''}".strip
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006 Roman Scherer | IRC Guerilla | Rapid Packet Movement
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
#
|
24
|
+
# $Id: quit_command.rb 85 2006-08-13 11:42:07Z roman $
|
25
|
+
#
|
26
|
+
require 'irc/commands/command'
|
27
|
+
require 'irc/commands/invalid_command'
|
28
|
+
|
29
|
+
module IRC
|
30
|
+
|
31
|
+
module Commands
|
32
|
+
|
33
|
+
# 4.1.6 Quit
|
34
|
+
#
|
35
|
+
# Command: QUIT
|
36
|
+
# Parameters: [<Quit message>]
|
37
|
+
#
|
38
|
+
# A client session is ended with a quit message. The server must close the
|
39
|
+
# connection to a client which sends a QUIT message. If a "Quit Message" is
|
40
|
+
# given, this will be sent instead of the default message, the nickname.
|
41
|
+
#
|
42
|
+
# When netsplits (disconnecting of two servers) occur, the quit message is
|
43
|
+
# composed of the names of two servers involved, separated by a space. The
|
44
|
+
# first name is that of the server which is still connected and the second
|
45
|
+
# name is that of the server that has become disconnected.
|
46
|
+
#
|
47
|
+
# If, for some other reason, a client connection is closed without the
|
48
|
+
# client issuing a QUIT command (e.g. client dies and EOF occurs on socket),
|
49
|
+
# the server is required to fill in the quit message with some sort of message
|
50
|
+
# reflecting the nature of the event which caused it to happen.
|
51
|
+
#
|
52
|
+
# Numeric Replies:
|
53
|
+
#
|
54
|
+
# None.
|
55
|
+
#
|
56
|
+
# Examples:
|
57
|
+
#
|
58
|
+
# QUIT :Gone to have lunch ; Preferred message format.
|
59
|
+
#
|
60
|
+
class QuitCommand < Command
|
61
|
+
|
62
|
+
attr_reader :message
|
63
|
+
|
64
|
+
def initialize(message)
|
65
|
+
raise InvalidCommand.new("Can't create quit command. No quit message.") unless message
|
66
|
+
@message = message
|
67
|
+
end
|
68
|
+
|
69
|
+
def command
|
70
|
+
return "QUIT :#{message}"
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|