irc_parser 0.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.
Files changed (68) hide show
  1. data/LICENSE +21 -0
  2. data/README.md +105 -0
  3. data/Rakefile +155 -0
  4. data/extra/benchmark.rb +41 -0
  5. data/irc_parser.gemspec +98 -0
  6. data/lib/irc_parser.rb +25 -0
  7. data/lib/irc_parser/factory.erb +53 -0
  8. data/lib/irc_parser/helper.rb +71 -0
  9. data/lib/irc_parser/messages.rb +96 -0
  10. data/lib/irc_parser/messages/commands.rb +274 -0
  11. data/lib/irc_parser/messages/errors.rb +51 -0
  12. data/lib/irc_parser/messages/replies.rb +212 -0
  13. data/lib/irc_parser/parser.rb +557 -0
  14. data/lib/irc_parser/parser.rl +89 -0
  15. data/spec/fixtures/from_weechat.rb +24 -0
  16. data/spec/fixtures/inbound.log +3959 -0
  17. data/spec/irc_parser/helper_spec.rb +32 -0
  18. data/spec/irc_parser/irc_parser_spec.rb +12 -0
  19. data/spec/irc_parser/messages_spec.rb +195 -0
  20. data/spec/irc_parser/parser_spec.rb +9 -0
  21. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_1_password_message_spec.rb +28 -0
  22. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_2_nick_message_spec.rb +35 -0
  23. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_3_user_message_spec.rb +47 -0
  24. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_4_server_message_spec.rb +33 -0
  25. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_5_oper_spec.rb +17 -0
  26. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_6_quit_spec.rb +17 -0
  27. data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_7_server_quit_message_spec.rb +32 -0
  28. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_1_join_message_spec.rb +65 -0
  29. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_2_part_message_spec.rb +23 -0
  30. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_3_1_channel_modes_spec.rb +159 -0
  31. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_3_2_user_modes_spec.rb +55 -0
  32. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_4_topic_message_spec.rb +36 -0
  33. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_5_names_message_spec.rb +25 -0
  34. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_6_list_message_spec.rb +23 -0
  35. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_7_invite_message_spec.rb +31 -0
  36. data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_8_kick_command_spec.rb +56 -0
  37. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_1_version_message_spec.rb +30 -0
  38. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_2_stats_message_spec.rb +32 -0
  39. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_3_links_message_spec.rb +31 -0
  40. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_4_time_message_spec.rb +34 -0
  41. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_5_connect_message_spec.rb +32 -0
  42. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_6_trace_message_spec.rb +28 -0
  43. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_7_admin_command_spec.rb +28 -0
  44. data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_8_info_command_spec.rb +38 -0
  45. data/spec/irc_parser/rfc1459/4_4_sending_messages/4_4_1_private_messages_spec.rb +63 -0
  46. data/spec/irc_parser/rfc1459/4_4_sending_messages/4_4_2_notice_spec.rb +63 -0
  47. data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_1_who_query_spec.rb +27 -0
  48. data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_2_whois_query_spec.rb +27 -0
  49. data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_3_whowas_spec.rb +40 -0
  50. data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_1_kill_message_spec.rb +20 -0
  51. data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_2_ping_message_spec.rb +35 -0
  52. data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_3_pong_message_spec.rb +26 -0
  53. data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_4_error_spec.rb +26 -0
  54. data/spec/irc_parser/rfc1459/5_0_optionals/5_1_0_away_spec.rb +25 -0
  55. data/spec/irc_parser/rfc1459/5_0_optionals/5_2_0_rehash_message_spec.rb +14 -0
  56. data/spec/irc_parser/rfc1459/5_0_optionals/5_3_0_restart_message_spec.rb +14 -0
  57. data/spec/irc_parser/rfc1459/5_0_optionals/5_4_0_summon_message_spec.rb +28 -0
  58. data/spec/irc_parser/rfc1459/5_0_optionals/5_5_0_users_spec.rb +27 -0
  59. data/spec/irc_parser/rfc1459/5_0_optionals/5_6_0_operwall_message_spec.rb +17 -0
  60. data/spec/irc_parser/rfc1459/5_0_optionals/5_7_0_userhost_message_spec.rb +16 -0
  61. data/spec/irc_parser/rfc1459/5_0_optionals/5_8_0_ison_message_spec.rb +16 -0
  62. data/spec/irc_parser/rfc1459/6_0_replies/6_1_error_parsing_spec.rb +488 -0
  63. data/spec/irc_parser/rfc1459/6_0_replies/6_2_command_responses_generation_spec.rb +934 -0
  64. data/spec/irc_parser/rfc2812/5_1_command_responses/5_1_command_responses_spec.rb +63 -0
  65. data/spec/spec_helper.rb +12 -0
  66. data/spec/support/messages_helper.rb +24 -0
  67. data/spec/support/simplecov.rb +12 -0
  68. metadata +185 -0
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing whowas" do
4
+ # Parameters: <nickname> [<count> [<server>]]
5
+
6
+ # ; return all information in the nick history about nick "WiZ";
7
+ it_parses "WHOWAS Wiz" do |msg|
8
+ msg.nick.should == "Wiz"
9
+ end
10
+
11
+ # ; return at most, the 9 most recent entries in the nick history for "Mermaid";
12
+ it_parses "WHOWAS Mermaid 9" do |msg|
13
+ msg.nick.should == "Mermaid"
14
+ msg.count.should == 9
15
+ end
16
+
17
+ # ; return the most recent history for "Trillian" from the first server found to match "*.edu".
18
+ it_parses "WHOWAS Trillian 1 *.edu" do |msg|
19
+ msg.nick.should == "Trillian"
20
+ msg.count.should == 1
21
+ msg.server.should == "*.edu"
22
+ end
23
+
24
+ #------------------------------------------------------------------------------
25
+
26
+ it_generates IRCParser::Messages::WhoWas, "WHOWAS Wiz" do |msg|
27
+ msg.nick= "Wiz"
28
+ end
29
+
30
+ it_generates IRCParser::Messages::WhoWas, "WHOWAS Mermaid 9" do |msg|
31
+ msg.nick= "Mermaid"
32
+ msg.count= 9
33
+ end
34
+
35
+ it_generates IRCParser::Messages::WhoWas, "WHOWAS Trillian 1 *.edu" do |msg|
36
+ msg.nick= "Trillian"
37
+ msg.count= 1
38
+ msg.server= "*.edu"
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing kill msg" do
4
+ # Parameters: <nickname> <comment>
5
+
6
+ # ; Nickname collision between csd.bu.edu and tolson.oulu.fi"
7
+ # NOTE I added the colon, I don't think it makes sense to have this single
8
+ # case of space-aware parameter...
9
+ it_parses "KILL David :(csd.bu.edu <- tolsun.oulu.fi)" do |msg|
10
+ msg.nick.should == "David"
11
+ msg.kill_message.should == "(csd.bu.edu <- tolsun.oulu.fi)"
12
+ end
13
+
14
+ #------------------------------------------------------------------------------
15
+
16
+ it_generates IRCParser::Messages::Kill, "KILL David :(csd.bu.edu <- tolsun.oulu.fi)" do |msg|
17
+ msg.nick= "David"
18
+ msg.kill_message= "(csd.bu.edu <- tolsun.oulu.fi)"
19
+ end
20
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing ping msg" do
4
+ # Parameters: <target1> [<target2>]
5
+
6
+ # ; target sending a PING msg to another target to indicate it is still alive.
7
+ it_parses "PING tolsun.oulu.fi" do |msg|
8
+ msg.target.should == "tolsun.oulu.fi"
9
+ end
10
+
11
+ it_parses "PING tolsun.oulu.fi other.com" do |msg|
12
+ msg.target.should == "tolsun.oulu.fi"
13
+ msg.final_target.should == "other.com"
14
+ end
15
+
16
+ # ; PING msg being sent to nick WiZ
17
+ it_parses "PING WiZ" do |msg|
18
+ msg.target.should == "WiZ"
19
+ end
20
+
21
+ #------------------------------------------------------------------------------
22
+
23
+ it_generates IRCParser::Messages::Ping, "PING tolsun.oulu.fi" do |msg|
24
+ msg.target= "tolsun.oulu.fi"
25
+ end
26
+
27
+ it_generates IRCParser::Messages::Ping, "PING tolsun.oulu.fi other.com" do |msg|
28
+ msg.target= "tolsun.oulu.fi"
29
+ msg.final_target= "other.com"
30
+ end
31
+
32
+ it_generates IRCParser::Messages::Ping, "PING WiZ" do |msg|
33
+ msg.target= "WiZ"
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing pong msg" do
4
+ # Parameters: <daemon> [<daemon2>]
5
+
6
+ it_parses "PONG irc.test.host" do |msg|
7
+ msg.server.should == "irc.test.host"
8
+ end
9
+
10
+ # ; PONG msg from csd.bu.edu to tolsun.oulu.fi
11
+ it_parses "PONG csd.bu.edu tolsun.oulu.fi" do |msg|
12
+ msg.server.should == "csd.bu.edu"
13
+ msg.target.should == "tolsun.oulu.fi"
14
+ end
15
+
16
+ #------------------------------------------------------------------------------
17
+
18
+ it_generates IRCParser::Messages::Pong, "PONG irc.test.host" do |msg|
19
+ msg.server= "irc.test.host"
20
+ end
21
+
22
+ it_generates IRCParser::Messages::Pong, "PONG csd.bu.edu tolsun.oulu.fi" do |msg|
23
+ msg.server= "csd.bu.edu"
24
+ msg.target= "tolsun.oulu.fi"
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing error" do
4
+
5
+ # ; ERROR msg to the other server which caused this error.
6
+ it_parses "ERROR :Server *.fi already exists" do |msg|
7
+ msg.error_message.should == "Server *.fi already exists"
8
+ end
9
+
10
+ # ; Same ERROR msg as above but sent to user WiZ on the other server.
11
+ it_parses "NOTICE WiZ :ERROR from csd.bu.edu -- Server *.fi already exists" do |msg|
12
+ msg.target.should == "WiZ"
13
+ msg.body.should == "ERROR from csd.bu.edu -- Server *.fi already exists"
14
+ end
15
+
16
+ #------------------------------------------------------------------------------
17
+
18
+ it_generates IRCParser::Messages::Error, "ERROR :Server *.fi already exists" do |msg|
19
+ msg.error_message= "Server *.fi already exists"
20
+ end
21
+
22
+ it_generates IRCParser::Messages::Notice, "NOTICE WiZ :ERROR from csd.bu.edu -- Server *.fi already exists" do |msg|
23
+ msg.target = "WiZ"
24
+ msg.body = "ERROR from csd.bu.edu -- Server *.fi already exists"
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing away" do
4
+ # Parameters: [msg]
5
+
6
+ # ; set away msg to "Gone to lunch. Back in 5".
7
+ it_parses "AWAY :Gone to lunch. Back in 5" do |msg|
8
+ msg.away_message.should == "Gone to lunch. Back in 5"
9
+ end
10
+
11
+ # ; unmark WiZ as being away.
12
+ it_parses ":WiZ AWAY" do |msg|
13
+ msg.prefix.should == "WiZ"
14
+ end
15
+
16
+ #------------------------------------------------------------------------------
17
+
18
+ it_generates IRCParser::Messages::Away, "AWAY :Gone to lunch. Back in 5" do |msg|
19
+ msg.away_message= "Gone to lunch. Back in 5"
20
+ end
21
+
22
+ it_generates IRCParser::Messages::Away, ":WiZ AWAY" do |msg|
23
+ msg.prefix= "WiZ"
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing rehash msg" do
4
+ # Parameters: None
5
+
6
+ # ; msg from client with operator status to server asking it to reread its configuration file.
7
+ it_parses "REHASH" do
8
+ end
9
+
10
+ #------------------------------------------------------------------------------
11
+
12
+ it_generates IRCParser::Messages::Rehash, "REHASH" do
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing restart msg" do
4
+ # Parameters: None
5
+
6
+ it_parses "RESTART" do
7
+ end
8
+
9
+ #------------------------------------------------------------------------------
10
+
11
+ it_generates IRCParser::Messages::Restart, "RESTART" do
12
+ end
13
+ end
14
+
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing summon msg" do
4
+ # Parameters: <user> [<server>]
5
+
6
+ # ; summon user jto on the server's host
7
+ it_parses "SUMMON jto" do |msg|
8
+ msg.nick.should == "jto"
9
+ msg.server.should be_nil
10
+ end
11
+
12
+ # ; summon user jto on the host which a server named "tolsun.oulu.fi" is running.
13
+ it_parses "SUMMON jto tolsun.oulu.fi" do |msg|
14
+ msg.nick.should == "jto"
15
+ msg.server.should == "tolsun.oulu.fi"
16
+ end
17
+
18
+ #------------------------------------------------------------------------------
19
+
20
+ it_generates IRCParser::Messages::Summon, "SUMMON jto" do |msg|
21
+ msg.nick= "jto"
22
+ end
23
+
24
+ it_generates IRCParser::Messages::Summon, "SUMMON jto tolsun.oulu.fi" do |msg|
25
+ msg.nick= "jto"
26
+ msg.server= "tolsun.oulu.fi"
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing users" do
4
+ # Parameters: [<server>]
5
+
6
+ # ; request a list of users logged in on server eff.org
7
+ it_parses "USERS eff.org" do |msg|
8
+ msg.target.should == "eff.org"
9
+ end
10
+
11
+ # ; request from John for a list of users logged in on server tolsun.oulu.fi
12
+ it_parses ":John USERS tolsun.oulu.fi" do |msg|
13
+ msg.prefix.should == "John"
14
+ msg.target.should == "tolsun.oulu.fi"
15
+ end
16
+
17
+ #------------------------------------------------------------------------------
18
+
19
+ it_generates IRCParser::Messages::Users, "USERS eff.org" do |msg|
20
+ msg.target= "eff.org"
21
+ end
22
+
23
+ it_generates IRCParser::Messages::Users, ":John USERS tolsun.oulu.fi" do |msg|
24
+ msg.prefix= "John"
25
+ msg.target= "tolsun.oulu.fi"
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing operwall msg" do
4
+
5
+ # ; WALLOPS msg from csd.bu.edu announcing a CONNECT message it received and acted upon from Joshua.
6
+ it_parses ":csd.bu.edu WALLOPS :Connect '*.uiuc.edu 6667' from Joshua" do |msg|
7
+ msg.prefix.should == "csd.bu.edu"
8
+ msg.wall_message.should == "Connect '*.uiuc.edu 6667' from Joshua"
9
+ end
10
+
11
+ #------------------------------------------------------------------------------
12
+
13
+ it_generates IRCParser::Messages::WallOps, ":csd.bu.edu WALLOPS :Connect '*.uiuc.edu 6667' from Joshua" do |msg|
14
+ msg.prefix= "csd.bu.edu"
15
+ msg.wall_message= "Connect '*.uiuc.edu 6667' from Joshua"
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing userhost msg" do
4
+ # Parameters: <nickname>{<space><nickname>}
5
+
6
+ # ; USERHOST request for information on nicks "Wiz", "Michael", "Marty" and "p"
7
+ it_parses "USERHOST Wiz Michael Marty p" do |msg|
8
+ msg.nicks.should == %w|Wiz Michael Marty p|
9
+ end
10
+
11
+ #------------------------------------------------------------------------------
12
+
13
+ it_generates IRCParser::Messages::UserHost, "USERHOST Wiz Michael Marty p" do |msg|
14
+ msg.nicks= %w|Wiz Michael Marty p|
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "parsing ison msg" do
4
+ # Parameters: <nickname>{<space><nickname>}
5
+
6
+ # ; Sample ISON request for 7 nicks.
7
+ it_parses "ISON phone trillian WiZ jarlek Avalon Angel Monstah" do |msg|
8
+ msg.nicks.should == %w|phone trillian WiZ jarlek Avalon Angel Monstah|
9
+ end
10
+
11
+ #------------------------------------------------------------------------------
12
+
13
+ it_generates IRCParser::Messages::IsOn, "ISON phone trillian WiZ jarlek Avalon Angel Monstah" do |msg|
14
+ msg.nicks = %w|phone trillian WiZ jarlek Avalon Angel Monstah|
15
+ end
16
+ end
@@ -0,0 +1,488 @@
1
+ require 'spec_helper'
2
+
3
+ describe IRCParser, "error replies" do
4
+ include IRCParser
5
+
6
+ # Used to indicate the nickname parameter supplied to a command is currently unused.
7
+ it_parses "401 Wiz Tony :No such nick/channel" do |msg|
8
+ msg.nick.should == "Wiz"
9
+ msg.error_nick.should == "Tony"
10
+ end
11
+
12
+ # Used to indicate the server name given currently doesn't exist.
13
+ it_parses "402 Wiz oga.com :No such server" do |msg|
14
+ msg.nick.should == "Wiz"
15
+ msg.server.should == "oga.com"
16
+ end
17
+
18
+ # Used to indicate the given channel name is invalid.
19
+ it_parses "403 Wiz #Carlitos :No such channel" do |msg|
20
+ msg.nick.should == "Wiz"
21
+ msg.channel.should == "#Carlitos"
22
+ end
23
+
24
+ # Sent to a user who is either (a) not on a channel which is mode +n or (b)
25
+ # not a chanop (or mode +v) on a channel which has mode +m set and is trying
26
+ # to send a PRIVMSG msg to that channel.
27
+ it_parses "404 Wiz #something :Cannot send to channel" do |msg|
28
+ msg.nick.should == "Wiz"
29
+ msg.channel.should == "#something"
30
+ end
31
+
32
+ # Sent to a user when they have joined the maximum number of allowed channels
33
+ # and they try to join another channel.
34
+ it_parses "405 Wiz #room :You have joined too many channels" do |msg|
35
+ msg.nick.should == "Wiz"
36
+ msg.channel.should == "#room"
37
+ end
38
+
39
+ # Returned by WHOWAS to indicate there is no history information for that nickname.
40
+ it_parses "406 Wiz John :There was no such nickname" do |msg|
41
+ msg.nick.should == "Wiz"
42
+ msg.error_nick.should == "John"
43
+ end
44
+
45
+ # Returned to a client which is attempting to send a PRIVMSG/NOTICE using the
46
+ # user@host destination format and for a user@host which has several
47
+ # occurrences.
48
+ it_parses "407 Wiz target :Duplicate recipients. No msg delivered" do |msg|
49
+ msg.nick.should == "Wiz"
50
+ msg.target.should == "target"
51
+ end
52
+
53
+ # PING or PONG msg missing the originator parameter which is required
54
+ # since these commands must work without valid prefixes.
55
+ it_parses "409 Wiz :No origin specified" do |msg|
56
+ msg.nick.should == "Wiz"
57
+ end
58
+
59
+ # 412 - 414 (and 411?) are returned by PRIVMSG to indicate that the msg wasn't
60
+ # delivered for some reason. ERR_NOTOPLEVEL and ERR_WILDTOPLEVEL are errors
61
+ # that are returned when an invalid use of "PRIVMSG $<server>" or "PRIVMSG
62
+ # #<host>" is attempted.
63
+ it_parses "411 Wiz :No recipient given (PRIVMSG)" do |msg|
64
+ msg.nick.should == "Wiz"
65
+ msg.postfix.should == "No recipient given (PRIVMSG)"
66
+ end
67
+
68
+ it_parses "412 Wiz :No text to send" do |msg|
69
+ msg.nick.should == "Wiz"
70
+ end
71
+
72
+ it_parses "413 Wiz mask :No toplevel domain specified" do |msg|
73
+ msg.nick.should == "Wiz"
74
+ msg.mask.should == "mask"
75
+ end
76
+
77
+ it_parses "414 Wiz mask :Wildcard in toplevel domain" do |msg|
78
+ msg.nick.should == "Wiz"
79
+ msg.mask.should == "mask"
80
+ end
81
+
82
+ # Returned to a registered client to indicate that the command sent is
83
+ # unknown by the server.
84
+ it_parses "421 PILDONGA :Unknown command" do |msg|
85
+ msg.command.should == "PILDONGA"
86
+ end
87
+
88
+ # Server's MOTD file could not be opened by the server.
89
+ it_parses "422 Wiz :MOTD File is missing" do |msg|
90
+ msg.nick.should == "Wiz"
91
+ end
92
+
93
+ # Returned by a server in response to an ADMIN msg when there is an error
94
+ # in finding the appropriate information.
95
+ it_parses "423 Wiz oulu.fi :No administrative info available" do |msg|
96
+ msg.nick.should == "Wiz"
97
+ msg.server.should == "oulu.fi"
98
+ end
99
+
100
+ # Generic error msg used to report a failed file operation during the
101
+ # processing of a msg.
102
+ it_parses "424 Wiz :File error doing rm on readme.txt" do |msg|
103
+ msg.nick.should == "Wiz"
104
+ msg.postfix.should == "File error doing rm on readme.txt"
105
+ end
106
+
107
+ # Returned when a nickname parameter expected for a command and isn't found.
108
+ it_parses "431 Wiz :No nickname given" do |msg|
109
+ msg.nick.should == "Wiz"
110
+ end
111
+
112
+ # Returned after receiving a NICK msg which contains characters which do
113
+ # not fall in the defined set.
114
+ it_parses "432 Wiz nick :Erroneus nickname" do |msg|
115
+ msg.nick.should == "Wiz"
116
+ msg.error_nick.should == "nick"
117
+ end
118
+
119
+ # Returned when a NICK msg is processed that results in an attempt to
120
+ # change to a currently existing nickname.
121
+ it_parses "433 Wiz nick :Nickname is already in use" do |msg|
122
+ msg.nick.should == "Wiz"
123
+ msg.error_nick.should == "nick"
124
+ end
125
+
126
+ # Returned by a server to a client when it detects a nickname collision
127
+ # (registered of a NICK that already exists by another server).
128
+ it_parses "436 Wiz nick :Nickname collision KILL" do |msg|
129
+ msg.nick.should == "Wiz"
130
+ msg.error_nick.should == "nick"
131
+ end
132
+
133
+ # Returned by the server to indicate that the target user of the command is
134
+ # not on the given channel.
135
+ it_parses "441 Wiz nick #channel :They aren't on that channel" do |msg|
136
+ msg.nick.should == "Wiz"
137
+ msg.error_nick.should == "nick"
138
+ msg.channel.should == "#channel"
139
+ end
140
+
141
+ # Returned by the server whenever a client tries to perform a channel
142
+ # effecting command for which the client isn't a member.
143
+ it_parses "442 Wiz #channel :You're not on that channel" do |msg|
144
+ msg.nick.should == "Wiz"
145
+ msg.channel.should == "#channel"
146
+ end
147
+
148
+ # Returned when a client tries to invite a user to a channel they are already
149
+ # on.
150
+ it_parses "443 Wiz user #channel :is already on channel" do |msg|
151
+ msg.nick.should == "Wiz"
152
+ msg.user.should == "user"
153
+ msg.channel.should == "#channel"
154
+ end
155
+
156
+ # Returned by the summon after a SUMMON command for a user was unable to be
157
+ # performed since they were not logged in.
158
+ it_parses "444 Wiz user :User not logged in" do |msg|
159
+ msg.nick.should == "Wiz"
160
+ msg.user.should == "user"
161
+ end
162
+
163
+ # Returned as a response to the SUMMON command. Must be returned by any
164
+ # server which does not implement it.
165
+ it_parses "445 Wiz :SUMMON has been disabled" do |msg|
166
+ msg.nick.should == "Wiz"
167
+ end
168
+
169
+ # Returned as a response to the USERS command. Must be returned by any
170
+ # server which does not implement it.
171
+ it_parses "446 Wiz :USERS has been disabled" do |msg|
172
+ msg.nick.should == "Wiz"
173
+ end
174
+
175
+ # Returned by the server to indicate that the client must be registered
176
+ # before the server will allow it to be parsed in detail.
177
+ it_parses "451 Wiz :You have not registered" do |msg|
178
+ msg.nick.should == "Wiz"
179
+ end
180
+
181
+ # Returned by the server by numerous commands to indicate to the client that
182
+ # it didn't supply enough parameters.
183
+ it_parses "461 Wiz PRIVMSG :Not enough parameters" do |msg|
184
+ msg.nick.should == "Wiz"
185
+ msg.command.should == "PRIVMSG"
186
+ end
187
+
188
+ # Returned by the server to any link which tries to change part of the
189
+ # registered details (such as password or user details from second USER
190
+ # msg).
191
+ it_parses "462 Wiz :You may not reregister" do |msg|
192
+ msg.nick.should == "Wiz"
193
+ end
194
+
195
+ # Returned to a client which attempts to register with a server which does
196
+ # not been setup to allow connections from the host the attempted connection is
197
+ # tried.
198
+ it_parses "463 Wiz :Your host isn't among the privileged" do |msg|
199
+ msg.nick.should == "Wiz"
200
+ end
201
+
202
+ # Returned to indicate a failed attempt at registering a connection for which
203
+ # a password was required and was either not given or incorrect.
204
+ it_parses "464 Wiz :Password incorrect" do |msg|
205
+ msg.nick.should == "Wiz"
206
+ end
207
+
208
+ # Returned after an attempt to connect and register yourself with a server
209
+ # which has been setup to explicitly deny connections to you.
210
+ it_parses "465 Wiz :You are banned from this server" do |msg|
211
+ msg.nick.should == "Wiz"
212
+ end
213
+
214
+ it_parses "467 Wiz #channel :Channel key already set" do |msg|
215
+ msg.nick.should == "Wiz"
216
+ msg.channel.should == "#channel"
217
+ end
218
+
219
+ it_parses "471 Wiz #channel :Cannot join channel (+l)" do |msg|
220
+ msg.nick.should == "Wiz"
221
+ msg.channel.should == "#channel"
222
+ end
223
+
224
+ it_parses "472 Wiz c :is unknown mode char to me" do |msg|
225
+ msg.nick.should == "Wiz"
226
+ msg.char.should == "c"
227
+ end
228
+
229
+ it_parses "473 Wiz #channel :Cannot join channel (+i)" do |msg|
230
+ msg.nick.should == "Wiz"
231
+ msg.channel.should == "#channel"
232
+ end
233
+
234
+ it_parses "474 Wiz #channel :Cannot join channel (+b)" do |msg|
235
+ msg.nick.should == "Wiz"
236
+ msg.channel.should == "#channel"
237
+ end
238
+
239
+ it_parses "475 Wiz #channel :Cannot join channel (+k)" do |msg|
240
+ msg.nick.should == "Wiz"
241
+ msg.channel.should == "#channel"
242
+ end
243
+
244
+ # Any command requiring operator privileges to operate must return this error
245
+ # to indicate the attempt was unsuccessful.
246
+ it_parses "481 Wiz :Permission Denied- You're not an IRC operator" do |msg|
247
+ msg.nick.should == "Wiz"
248
+ end
249
+
250
+ # Any command requiring 'chanop' privileges (such as MODE msgs) must
251
+ # return this error if the client making the attempt is not a chanop on the
252
+ # specified channel.
253
+ it_parses "482 Wiz #channel :You're not channel operator" do |msg|
254
+ msg.nick.should == "Wiz"
255
+ msg.channel.should == "#channel"
256
+ end
257
+
258
+ # Any attempts to use the KILL command on a server are to be refused and this
259
+ # error returned directly to the client.
260
+ it_parses "483 Wiz :You cant kill a server!" do |msg|
261
+ msg.nick.should == "Wiz"
262
+ end
263
+
264
+ # If a client sends an OPER msg and the server has not been configured to
265
+ # allow connections from the client's host as an operator, this error must be
266
+ # returned.
267
+ it_parses "491 Wiz :No O-lines for your host" do |msg|
268
+ msg.nick.should == "Wiz"
269
+ end
270
+
271
+ # Returned by the server to indicate that a MODE msg was sent with a
272
+ # nickname parameter and that the a mode flag sent was not recognized.
273
+ it_parses "501 Wiz :Unknown MODE flag" do |msg|
274
+ msg.nick.should == "Wiz"
275
+ end
276
+
277
+ # Error sent to any user trying to view or change the user mode for a user
278
+ # other than themselves.
279
+ it_parses "502 Wiz :Cant change mode for other users" do |msg|
280
+ msg.nick.should == "Wiz"
281
+ end
282
+
283
+ #------------------------------------------------------------------------------
284
+
285
+ it_generates IRCParser::Messages::ErrNoSuchNick, "401 Wiz Tony :No such nick/channel" do |msg|
286
+ msg.nick= "Wiz"
287
+ msg.error_nick= "Tony"
288
+ end
289
+
290
+ it_generates IRCParser::Messages::ErrNoSuchServer, "402 Wiz oga.com :No such server" do |msg|
291
+ msg.nick= "Wiz"
292
+ msg.server= "oga.com"
293
+ end
294
+
295
+ it_generates IRCParser::Messages::ErrNoSuchChannel, "403 Wiz #Carlitos :No such channel" do |msg|
296
+ msg.nick= "Wiz"
297
+ msg.channel= "#Carlitos"
298
+ end
299
+
300
+ it_generates IRCParser::Messages::ErrCannotSendToChan, "404 Wiz #something :Cannot send to channel" do |msg|
301
+ msg.nick= "Wiz"
302
+ msg.channel= "#something"
303
+ end
304
+
305
+ it_generates IRCParser::Messages::ErrTooManyChannels, "405 Wiz #room :You have joined too many channels" do |msg|
306
+ msg.nick= "Wiz"
307
+ msg.channel= "#room"
308
+ end
309
+
310
+ it_generates IRCParser::Messages::ErrWasNoSuchNick, "406 Wiz John :There was no such nickname" do |msg|
311
+ msg.nick= "Wiz"
312
+ msg.error_nick= "John"
313
+ end
314
+
315
+ it_generates IRCParser::Messages::ErrTooManyTargets, "407 Wiz target :Duplicate recipients. No message delivered" do |msg|
316
+ msg.nick= "Wiz"
317
+ msg.target= "target"
318
+ end
319
+
320
+ it_generates IRCParser::Messages::ErrNoOrigin, "409 Wiz :No origin specified" do |msg|
321
+ msg.nick= "Wiz"
322
+ end
323
+
324
+ it_generates IRCParser::Messages::ErrNoRecipient, "411 Wiz :No recipient given (PRIVMSG)" do |msg|
325
+ msg.nick= "Wiz"
326
+ msg.format_postfix(:command => "PRIVMSG")
327
+ end
328
+
329
+ it_generates IRCParser::Messages::ErrNoTextToSend, "412 Wiz :No text to send" do |msg|
330
+ msg.nick= "Wiz"
331
+ end
332
+
333
+ it_generates IRCParser::Messages::ErrNoTopLevel, "413 Wiz mask :No toplevel domain specified" do |msg|
334
+ msg.nick= "Wiz"
335
+ msg.mask= "mask"
336
+ end
337
+
338
+ it_generates IRCParser::Messages::ErrWildTopLevel, "414 Wiz mask :Wildcard in toplevel domain" do |msg|
339
+ msg.nick= "Wiz"
340
+ msg.mask= "mask"
341
+ end
342
+
343
+ it_generates IRCParser::Messages::ErrUnknownCommand, "421 PILDONGA :Unknown command" do |msg|
344
+ msg.command= "PILDONGA"
345
+ end
346
+
347
+ it_generates IRCParser::Messages::ErrNoMotd, "422 Wiz :MOTD File is missing" do |msg|
348
+ msg.nick= "Wiz"
349
+ end
350
+
351
+ it_generates IRCParser::Messages::ErrNoAdminInfo, "423 Wiz oulu.fi :No administrative info available" do |msg|
352
+ msg.nick= "Wiz"
353
+ msg.server= "oulu.fi"
354
+ end
355
+
356
+ it_generates IRCParser::Messages::ErrFileError, "424 Wiz :File error doing rm on readme.txt" do |msg|
357
+ msg.nick= "Wiz"
358
+ msg.format_postfix(:fileop => "rm", :file => "readme.txt")
359
+ end
360
+
361
+ it_generates IRCParser::Messages::ErrNoNickNameGiven, "431 Wiz :No nickname given" do |msg|
362
+ msg.nick= "Wiz"
363
+ end
364
+
365
+ it_generates IRCParser::Messages::ErrErroneusNickName, "432 Wiz nick :Erroneus nickname" do |msg|
366
+ msg.nick= "Wiz"
367
+ msg.error_nick= "nick"
368
+ end
369
+
370
+ it_generates IRCParser::Messages::ErrNickNameInUse, "433 Wiz nick :Nickname is already in use" do |msg|
371
+ msg.nick= "Wiz"
372
+ msg.error_nick= "nick"
373
+ end
374
+
375
+ it_generates IRCParser::Messages::ErrNickCollision, "436 Wiz nick :Nickname collision KILL" do |msg|
376
+ msg.nick= "Wiz"
377
+ msg.error_nick= "nick"
378
+ end
379
+
380
+ it_generates IRCParser::Messages::ErrUserNotInChannel, "441 Wiz nick #channel :They aren't on that channel" do |msg|
381
+ msg.nick= "Wiz"
382
+ msg.error_nick= "nick"
383
+ msg.channel= "#channel"
384
+ end
385
+ it_generates IRCParser::Messages::ErrNotOnChannel, "442 Wiz #channel :You're not on that channel" do |msg|
386
+ msg.nick= "Wiz"
387
+ msg.channel= "#channel"
388
+ end
389
+
390
+ it_generates IRCParser::Messages::ErrUserOnChannel, "443 Wiz user #channel :is already on channel" do |msg|
391
+ msg.nick= "Wiz"
392
+ msg.user= "user"
393
+ msg.channel= "#channel"
394
+ end
395
+
396
+ it_generates IRCParser::Messages::ErrNoLogin, "444 Wiz user :User not logged in" do |msg|
397
+ msg.nick= "Wiz"
398
+ msg.user= "user"
399
+ end
400
+
401
+ it_generates IRCParser::Messages::ErrSummonDisabled, "445 Wiz :SUMMON has been disabled" do |msg|
402
+ msg.nick= "Wiz"
403
+ end
404
+
405
+ it_generates IRCParser::Messages::ErrUsersDisabled, "446 Wiz :USERS has been disabled" do |msg|
406
+ msg.nick= "Wiz"
407
+ end
408
+
409
+ it_generates IRCParser::Messages::ErrNotRegistered, "451 Wiz :You have not registered" do |msg|
410
+ msg.nick= "Wiz"
411
+ end
412
+
413
+ it_generates IRCParser::Messages::ErrNeedMoreParams, "461 Wiz PRIVMSG :Not enough parameters" do |msg|
414
+ msg.nick= "Wiz"
415
+ msg.command= "PRIVMSG"
416
+ end
417
+
418
+ it_generates IRCParser::Messages::ErrAlreadyRegistred, "462 Wiz :You may not reregister" do |msg|
419
+ msg.nick= "Wiz"
420
+ end
421
+
422
+ it_generates IRCParser::Messages::ErrNoPermForHost, "463 Wiz :Your host isn't among the privileged" do |msg|
423
+ msg.nick= "Wiz"
424
+ end
425
+
426
+ it_generates IRCParser::Messages::ErrPasswdMismatch, "464 Wiz :Password incorrect" do |msg|
427
+ msg.nick= "Wiz"
428
+ end
429
+
430
+ it_generates IRCParser::Messages::ErrYouReBannedCreep, "465 Wiz :You are banned from this server" do |msg|
431
+ msg.nick= "Wiz"
432
+ end
433
+
434
+ it_generates IRCParser::Messages::ErrKeySet, "467 Wiz #channel :Channel key already set" do |msg|
435
+ msg.nick= "Wiz"
436
+ msg.channel= "#channel"
437
+ end
438
+
439
+ it_generates IRCParser::Messages::ErrChannelIsFull, "471 Wiz #channel :Cannot join channel (+l)" do |msg|
440
+ msg.nick= "Wiz"
441
+ msg.channel= "#channel"
442
+ end
443
+
444
+ it_generates IRCParser::Messages::ErrUnknownMode, "472 Wiz c :is unknown mode char to me" do |msg|
445
+ msg.nick= "Wiz"
446
+ msg.char= "c"
447
+ end
448
+
449
+ it_generates IRCParser::Messages::ErrInviteOnLYChan, "473 Wiz #channel :Cannot join channel (+i)" do |msg|
450
+ msg.nick= "Wiz"
451
+ msg.channel= "#channel"
452
+ end
453
+
454
+ it_generates IRCParser::Messages::ErrBannedFromChan, "474 Wiz #channel :Cannot join channel (+b)" do |msg|
455
+ msg.nick= "Wiz"
456
+ msg.channel= "#channel"
457
+ end
458
+
459
+ it_generates IRCParser::Messages::ErrBadChannelKey, "475 Wiz #channel :Cannot join channel (+k)" do |msg|
460
+ msg.nick= "Wiz"
461
+ msg.channel= "#channel"
462
+ end
463
+
464
+ it_generates IRCParser::Messages::ErrNoPrivileges, "481 Wiz :Permission Denied- You're not an IRC operator" do |msg|
465
+ msg.nick= "Wiz"
466
+ end
467
+
468
+ it_generates IRCParser::Messages::ErrChanOPrivsNeeded, "482 Wiz #channel :You're not channel operator" do |msg|
469
+ msg.nick= "Wiz"
470
+ msg.channel= "#channel"
471
+ end
472
+
473
+ it_generates IRCParser::Messages::ErrCantKillServer, "483 Wiz :You cant kill a server!" do |msg|
474
+ msg.nick= "Wiz"
475
+ end
476
+
477
+ it_generates IRCParser::Messages::ErrNoOperHost, "491 Wiz :No O-lines for your host" do |msg|
478
+ msg.nick= "Wiz"
479
+ end
480
+
481
+ it_generates IRCParser::Messages::ErrUModeUnknownFlag, "501 Wiz :Unknown MODE flag" do |msg|
482
+ msg.nick= "Wiz"
483
+ end
484
+
485
+ it_generates IRCParser::Messages::ErrUsersDontMatch, "502 Wiz :Cant change mode for other users" do |msg|
486
+ msg.nick= "Wiz"
487
+ end
488
+ end