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.
- data/LICENSE +21 -0
- data/README.md +105 -0
- data/Rakefile +155 -0
- data/extra/benchmark.rb +41 -0
- data/irc_parser.gemspec +98 -0
- data/lib/irc_parser.rb +25 -0
- data/lib/irc_parser/factory.erb +53 -0
- data/lib/irc_parser/helper.rb +71 -0
- data/lib/irc_parser/messages.rb +96 -0
- data/lib/irc_parser/messages/commands.rb +274 -0
- data/lib/irc_parser/messages/errors.rb +51 -0
- data/lib/irc_parser/messages/replies.rb +212 -0
- data/lib/irc_parser/parser.rb +557 -0
- data/lib/irc_parser/parser.rl +89 -0
- data/spec/fixtures/from_weechat.rb +24 -0
- data/spec/fixtures/inbound.log +3959 -0
- data/spec/irc_parser/helper_spec.rb +32 -0
- data/spec/irc_parser/irc_parser_spec.rb +12 -0
- data/spec/irc_parser/messages_spec.rb +195 -0
- data/spec/irc_parser/parser_spec.rb +9 -0
- data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_1_password_message_spec.rb +28 -0
- data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_2_nick_message_spec.rb +35 -0
- data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_3_user_message_spec.rb +47 -0
- data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_4_server_message_spec.rb +33 -0
- data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_5_oper_spec.rb +17 -0
- data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_6_quit_spec.rb +17 -0
- data/spec/irc_parser/rfc1459/4_1_connection_registration/4_1_7_server_quit_message_spec.rb +32 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_1_join_message_spec.rb +65 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_2_part_message_spec.rb +23 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_3_1_channel_modes_spec.rb +159 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_3_2_user_modes_spec.rb +55 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_4_topic_message_spec.rb +36 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_5_names_message_spec.rb +25 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_6_list_message_spec.rb +23 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_7_invite_message_spec.rb +31 -0
- data/spec/irc_parser/rfc1459/4_2_channel_operations/4_2_8_kick_command_spec.rb +56 -0
- data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_1_version_message_spec.rb +30 -0
- data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_2_stats_message_spec.rb +32 -0
- data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_3_links_message_spec.rb +31 -0
- data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_4_time_message_spec.rb +34 -0
- data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_5_connect_message_spec.rb +32 -0
- data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_6_trace_message_spec.rb +28 -0
- data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_7_admin_command_spec.rb +28 -0
- data/spec/irc_parser/rfc1459/4_3_server_queries_and_commands/4_3_8_info_command_spec.rb +38 -0
- data/spec/irc_parser/rfc1459/4_4_sending_messages/4_4_1_private_messages_spec.rb +63 -0
- data/spec/irc_parser/rfc1459/4_4_sending_messages/4_4_2_notice_spec.rb +63 -0
- data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_1_who_query_spec.rb +27 -0
- data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_2_whois_query_spec.rb +27 -0
- data/spec/irc_parser/rfc1459/4_5_user_based_queries/4_5_3_whowas_spec.rb +40 -0
- data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_1_kill_message_spec.rb +20 -0
- data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_2_ping_message_spec.rb +35 -0
- data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_3_pong_message_spec.rb +26 -0
- data/spec/irc_parser/rfc1459/4_6_miscellaneous_messages/4_6_4_error_spec.rb +26 -0
- data/spec/irc_parser/rfc1459/5_0_optionals/5_1_0_away_spec.rb +25 -0
- data/spec/irc_parser/rfc1459/5_0_optionals/5_2_0_rehash_message_spec.rb +14 -0
- data/spec/irc_parser/rfc1459/5_0_optionals/5_3_0_restart_message_spec.rb +14 -0
- data/spec/irc_parser/rfc1459/5_0_optionals/5_4_0_summon_message_spec.rb +28 -0
- data/spec/irc_parser/rfc1459/5_0_optionals/5_5_0_users_spec.rb +27 -0
- data/spec/irc_parser/rfc1459/5_0_optionals/5_6_0_operwall_message_spec.rb +17 -0
- data/spec/irc_parser/rfc1459/5_0_optionals/5_7_0_userhost_message_spec.rb +16 -0
- data/spec/irc_parser/rfc1459/5_0_optionals/5_8_0_ison_message_spec.rb +16 -0
- data/spec/irc_parser/rfc1459/6_0_replies/6_1_error_parsing_spec.rb +488 -0
- data/spec/irc_parser/rfc1459/6_0_replies/6_2_command_responses_generation_spec.rb +934 -0
- data/spec/irc_parser/rfc2812/5_1_command_responses/5_1_command_responses_spec.rb +63 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/messages_helper.rb +24 -0
- data/spec/support/simplecov.rb +12 -0
- metadata +185 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing join msg" do
|
|
4
|
+
|
|
5
|
+
it_parses "JOIN #foobar" do |msg|
|
|
6
|
+
msg.channels.should == ["#foobar"]
|
|
7
|
+
msg.keys.should == []
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it_parses "JOIN &foo fubar" do |msg|
|
|
11
|
+
msg.channels.should == ["&foo"]
|
|
12
|
+
msg.keys.should == ["fubar"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it_parses "JOIN #foo,&bar fubar" do |msg|
|
|
16
|
+
msg.channels.should == ["#foo", "&bar"]
|
|
17
|
+
msg.keys.should == ["fubar"]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it_parses "JOIN #foo,#bar fubar,foobar" do |msg|
|
|
21
|
+
msg.channels.should == ["#foo", "#bar"]
|
|
22
|
+
msg.keys.should == ["fubar", "foobar"]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it_parses "JOIN #foo,#bar" do |msg|
|
|
26
|
+
msg.channels.should == ["#foo", "#bar"]
|
|
27
|
+
msg.keys.should == []
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it_parses ":WiZ JOIN #Twilight_zone" do |msg|
|
|
31
|
+
msg.channels.should == ["#Twilight_zone"]
|
|
32
|
+
msg.keys.should == []
|
|
33
|
+
msg.prefix.should == "WiZ"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#-------------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
it_generates IRCParser::Messages::Join, "JOIN #foobar" do |msg|
|
|
39
|
+
msg.channels= ["#foobar"]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it_generates IRCParser::Messages::Join, "JOIN &foo fubar" do |msg|
|
|
43
|
+
msg.channels= ["&foo"]
|
|
44
|
+
msg.keys= ["fubar"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it_generates IRCParser::Messages::Join, "JOIN #foo,&bar fubar" do |msg|
|
|
48
|
+
msg.channels= ["#foo", "&bar"]
|
|
49
|
+
msg.keys= ["fubar"]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it_generates IRCParser::Messages::Join, "JOIN #foo,#bar fubar,foobar" do |msg|
|
|
53
|
+
msg.channels= ["#foo", "#bar"]
|
|
54
|
+
msg.keys= ["fubar", "foobar"]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it_generates IRCParser::Messages::Join, "JOIN #foo,#bar" do |msg|
|
|
58
|
+
msg.channels= ["#foo", "#bar"]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it_generates IRCParser::Messages::Join, ":WiZ JOIN #Twilight_zone" do |msg|
|
|
62
|
+
msg.channels= ["#Twilight_zone"]
|
|
63
|
+
msg.prefix= "WiZ"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing part msg" do
|
|
4
|
+
|
|
5
|
+
it_parses "PART #twilight_zone" do |msg|
|
|
6
|
+
msg.channels.should == ["#twilight_zone"]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it_parses "PART #oz-ops,&group5" do |msg|
|
|
10
|
+
msg.channels.should == ["#oz-ops", "&group5"]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
#-------------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
it_generates IRCParser::Messages::Part, "PART #twilight_zone" do |msg|
|
|
16
|
+
msg.channels= ["#twilight_zone"]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it_generates IRCParser::Messages::Part, "PART #oz-ops,&group5" do |msg|
|
|
20
|
+
msg.channels= ["#oz-ops", "&group5"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing channel modes" do
|
|
4
|
+
|
|
5
|
+
# ; Makes #Finnish channel moderated and 'invite-only'.
|
|
6
|
+
it_parses "MODE #Finnish +im" do |msg|
|
|
7
|
+
msg.target.should == "#Finnish"
|
|
8
|
+
msg.user.should be_nil
|
|
9
|
+
|
|
10
|
+
msg.flags.should == "+im"
|
|
11
|
+
msg.should be_chan_flags_include_invite_only
|
|
12
|
+
msg.should be_chan_invite_only
|
|
13
|
+
msg.should be_chan_flags_include_moderated
|
|
14
|
+
msg.should be_chan_moderated
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# ; Gives 'chanop' privileges to Kilroy on channel #Finnish.
|
|
18
|
+
it_parses "MODE #Finnish +o Kilroy" do |msg|
|
|
19
|
+
msg.target.should == "#Finnish"
|
|
20
|
+
msg.user.should == "Kilroy"
|
|
21
|
+
|
|
22
|
+
msg.flags.should == "+o"
|
|
23
|
+
msg.should be_chan_flags_include_operator
|
|
24
|
+
msg.should be_chan_operator
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# ; Allow WiZ to speak on #Finnish.
|
|
28
|
+
it_parses "MODE #Finnish +v Wiz" do |msg|
|
|
29
|
+
msg.target.should == "#Finnish"
|
|
30
|
+
msg.user.should == "Wiz"
|
|
31
|
+
|
|
32
|
+
msg.flags.should == "+v"
|
|
33
|
+
msg.should be_chan_flags_include_speaker
|
|
34
|
+
msg.should be_chan_speaker
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# ; Removes 'secret' flag from channel #Fins.
|
|
38
|
+
it_parses "MODE #Fins -s" do |msg|
|
|
39
|
+
msg.target.should == "#Fins"
|
|
40
|
+
msg.user.should be_nil
|
|
41
|
+
|
|
42
|
+
msg.flags.should == "-s"
|
|
43
|
+
msg.should be_chan_flags_include_secret
|
|
44
|
+
msg.should_not be_chan_secret
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# ; Set the channel limit to "oulu".
|
|
48
|
+
it_parses "MODE #42 +k oulu" do |msg|
|
|
49
|
+
msg.target.should == "#42"
|
|
50
|
+
msg.limit.should == "oulu"
|
|
51
|
+
|
|
52
|
+
msg.flags.should == "+k"
|
|
53
|
+
msg.should be_chan_flags_include_password
|
|
54
|
+
msg.should be_chan_password
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# ; Set the limit for the number of users on channel to 10.
|
|
58
|
+
it_parses "MODE #eu-opers +l 10" do |msg|
|
|
59
|
+
msg.target.should == "#eu-opers"
|
|
60
|
+
msg.limit.should == "10"
|
|
61
|
+
|
|
62
|
+
msg.flags.should == "+l"
|
|
63
|
+
msg.should be_chan_flags_include_users_limit
|
|
64
|
+
msg.should be_chan_users_limit
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# ; list ban masks set for target.
|
|
68
|
+
it_parses "MODE &oulu +b" do |msg|
|
|
69
|
+
msg.target.should == "&oulu"
|
|
70
|
+
msg.limit.should be_nil
|
|
71
|
+
|
|
72
|
+
msg.flags.should == "+b"
|
|
73
|
+
msg.should be_chan_flags_include_ban_mask
|
|
74
|
+
msg.should be_chan_ban_mask
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# ; prevent all users from joining.
|
|
78
|
+
it_parses "MODE &oulu +b *!*@*" do |msg|
|
|
79
|
+
msg.target.should == "&oulu"
|
|
80
|
+
msg.ban_mask.should == "*!*@*"
|
|
81
|
+
|
|
82
|
+
msg.flags.should == "+b"
|
|
83
|
+
msg.should be_chan_flags_include_ban_mask
|
|
84
|
+
msg.should be_chan_ban_mask
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# ; prevent any user from a hostname matching *.edu from joining.
|
|
88
|
+
it_parses "MODE &oulu +b *!*@*.edu" do |msg|
|
|
89
|
+
msg.target.should == "&oulu"
|
|
90
|
+
msg.ban_mask.should == "*!*@*.edu"
|
|
91
|
+
|
|
92
|
+
msg.flags.should == "+b"
|
|
93
|
+
msg.should be_chan_flags_include_ban_mask
|
|
94
|
+
msg.should be_chan_ban_mask
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
#-------------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
it_generates IRCParser::Messages::Mode, "MODE #Finnish +im" do |msg|
|
|
100
|
+
msg.target = "#Finnish"
|
|
101
|
+
msg.positive_flags!
|
|
102
|
+
msg.chan_invite_only!
|
|
103
|
+
msg.chan_moderated!
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it_generates IRCParser::Messages::Mode, "MODE #Finnish +o Kilroy" do |msg|
|
|
107
|
+
msg.target = "#Finnish"
|
|
108
|
+
msg.user= "Kilroy"
|
|
109
|
+
msg.positive_flags!
|
|
110
|
+
msg.chan_operator!
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it_generates IRCParser::Messages::Mode, "MODE #Finnish +v Wiz" do |msg|
|
|
114
|
+
msg.target = "#Finnish"
|
|
115
|
+
msg.user= "Wiz"
|
|
116
|
+
msg.positive_flags!
|
|
117
|
+
msg.chan_speaker!
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it_generates IRCParser::Messages::Mode, "MODE #Fins -s" do |msg|
|
|
121
|
+
msg.target = "#Fins"
|
|
122
|
+
msg.negative_flags!
|
|
123
|
+
msg.chan_secret!
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it_generates IRCParser::Messages::Mode, "MODE #42 +k oulu" do |msg|
|
|
127
|
+
msg.target = "#42"
|
|
128
|
+
msg.limit= "oulu"
|
|
129
|
+
msg.positive_flags!
|
|
130
|
+
msg.chan_password!
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it_generates IRCParser::Messages::Mode, "MODE #eu-opers +l 10" do |msg|
|
|
134
|
+
msg.target = "#eu-opers"
|
|
135
|
+
msg.limit= "10"
|
|
136
|
+
msg.positive_flags!
|
|
137
|
+
msg.chan_users_limit!
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it_generates IRCParser::Messages::Mode, "MODE &oulu +b" do |msg|
|
|
141
|
+
msg.target = "&oulu"
|
|
142
|
+
msg.positive_flags!
|
|
143
|
+
msg.chan_ban_mask!
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it_generates IRCParser::Messages::Mode, "MODE &oulu +b *!*@*" do |msg|
|
|
147
|
+
msg.target = "&oulu"
|
|
148
|
+
msg.ban_mask= "*!*@*"
|
|
149
|
+
msg.positive_flags!
|
|
150
|
+
msg.chan_ban_mask!
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it_generates IRCParser::Messages::Mode, "MODE &oulu +b *!*@*.edu" do |msg|
|
|
154
|
+
msg.target = "&oulu"
|
|
155
|
+
msg.ban_mask= "*!*@*.edu"
|
|
156
|
+
msg.positive_flags!
|
|
157
|
+
msg.chan_ban_mask!
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing user modes" do
|
|
4
|
+
|
|
5
|
+
it_parses "MODE WiZ -w" do |msg| # ; turns reception of WALLOPS messages off for WiZ.
|
|
6
|
+
msg.target.should == "WiZ"
|
|
7
|
+
|
|
8
|
+
msg.flags.should == "-w"
|
|
9
|
+
msg.should be_user_flags_include_wallops_receptor
|
|
10
|
+
msg.should_not be_user_wallops_receptor
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it_parses ":Angel MODE Angel +i" do |msg| # ; Message from Angel to make themselves invisible.
|
|
14
|
+
msg.target.should == "Angel"
|
|
15
|
+
msg.prefix.should == "Angel"
|
|
16
|
+
|
|
17
|
+
msg.flags.should == "+i"
|
|
18
|
+
msg.should be_user_flags_include_invisible
|
|
19
|
+
msg.should be_user_invisible
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# ; WiZ 'deopping' (removing operator status). The plain reverse of this command
|
|
23
|
+
# ("MODE WiZ +o") must not be allowed from users since would bypass the OPER command.
|
|
24
|
+
it_parses "MODE WiZ -o" do |msg|
|
|
25
|
+
msg.target.should == "WiZ"
|
|
26
|
+
|
|
27
|
+
msg.flags.should == "-o"
|
|
28
|
+
msg.should be_user_flags_include_operator
|
|
29
|
+
msg.should_not be_user_operator
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
#------------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
it_generates IRCParser::Messages::Mode, "MODE WiZ -w" do |msg| # ; turns reception of WALLOPS messages off for WiZ.
|
|
35
|
+
msg.target= "WiZ"
|
|
36
|
+
msg.negative_flags!
|
|
37
|
+
msg.user_wallops_receptor!
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it_generates IRCParser::Messages::Mode, ":Angel MODE Angel +i" do |msg| # ; Message from Angel to make themselves invisible.
|
|
41
|
+
msg.prefix = "Angel"
|
|
42
|
+
msg.target= "Angel"
|
|
43
|
+
|
|
44
|
+
msg.positive_flags!
|
|
45
|
+
msg.user_invisible!
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it_generates IRCParser::Messages::Mode, "MODE WiZ -o" do |msg|
|
|
49
|
+
msg.target= "WiZ"
|
|
50
|
+
|
|
51
|
+
msg.negative_flags!
|
|
52
|
+
msg.user_operator!
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing topic msg" do
|
|
4
|
+
|
|
5
|
+
it_parses ":Wiz TOPIC #test :New topic" do |msg| # ;User Wiz setting the topic.
|
|
6
|
+
msg.channel.should == "#test"
|
|
7
|
+
msg.topic.should == "New topic"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it_parses "TOPIC #test :another topic" do |msg| # ;set the topic on #test to "anothe topic".
|
|
11
|
+
msg.channel.should == "#test"
|
|
12
|
+
msg.topic.should == "another topic"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it_parses "TOPIC #test" do |msg| # ; check the topic for #test.
|
|
16
|
+
msg.channel.should == "#test"
|
|
17
|
+
msg.topic.should be_nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#------------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
it_generates IRCParser::Messages::Topic, ":Wiz TOPIC #test :New topic" do |msg| # ;User Wiz setting the topic.
|
|
23
|
+
msg.prefix= "Wiz"
|
|
24
|
+
msg.channel= "#test"
|
|
25
|
+
msg.topic= "New topic"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it_generates IRCParser::Messages::Topic, "TOPIC #test :another topic" do |msg| # ;set the topic on #test to "anothe topic".
|
|
29
|
+
msg.channel= "#test"
|
|
30
|
+
msg.topic= "another topic"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it_generates IRCParser::Messages::Topic, "TOPIC #test" do |msg| # ; check the topic for #test.
|
|
34
|
+
msg.channel= "#test"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing names msg" do
|
|
4
|
+
|
|
5
|
+
# ; list visible users on #twilight_zone and #42 if the channels are visible to you.
|
|
6
|
+
it_parses "NAMES #twilight_zone,#42" do |msg|
|
|
7
|
+
msg.channels.should == ["#twilight_zone", "#42"]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# ; list all visible channels and users
|
|
11
|
+
it_parses "NAMES" do |msg|
|
|
12
|
+
msg.channels.should == []
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#------------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
# ; list visible users on #twilight_zone and #42 if the channels are visible to you.
|
|
18
|
+
it_generates IRCParser::Messages::Names, "NAMES #twilight_zone,#42" do |msg|
|
|
19
|
+
msg.channels= ["#twilight_zone", "#42"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# ; list all visible channels and users
|
|
23
|
+
it_generates IRCParser::Messages::Names, "NAMES" do |msg|
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing list msg" do
|
|
4
|
+
|
|
5
|
+
# ; List all channels.
|
|
6
|
+
it_parses "LIST" do |msg|
|
|
7
|
+
msg.channels.should == []
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# ; List channels #twilight_zone and #42
|
|
11
|
+
it_parses "LIST #twilight_zone,#42" do |msg|
|
|
12
|
+
msg.channels.should == ["#twilight_zone", "#42"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#------------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
it_generates IRCParser::Messages::List, "LIST" do |msg|
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it_generates IRCParser::Messages::List, "LIST #twilight_zone,#42" do |msg|
|
|
21
|
+
msg.channels= ["#twilight_zone", "#42"]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing invite msg" do
|
|
4
|
+
|
|
5
|
+
# ; User Angel inviting WiZ to channel #Dust
|
|
6
|
+
it_parses ":Angel INVITE Wiz #Dust" do |msg|
|
|
7
|
+
msg.channel.should == "#Dust"
|
|
8
|
+
msg.prefix.should == "Angel"
|
|
9
|
+
msg.to_nick.should == "Wiz"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# ; Command to invite WiZ to #Twilight_zone
|
|
13
|
+
it_parses "INVITE Wiz #Twilight_Zone" do |msg|
|
|
14
|
+
msg.channel.should == "#Twilight_Zone"
|
|
15
|
+
msg.prefix.should be_nil
|
|
16
|
+
msg.to_nick.should == "Wiz"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
#------------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
it_generates IRCParser::Messages::Invite, ":Angel INVITE Wiz #Dust" do |msg|
|
|
22
|
+
msg.channel= "#Dust"
|
|
23
|
+
msg.prefix= "Angel"
|
|
24
|
+
msg.to_nick= "Wiz"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it_generates IRCParser::Messages::Invite, "INVITE Wiz #Twilight_Zone" do |msg|
|
|
28
|
+
msg.channel= "#Twilight_Zone"
|
|
29
|
+
msg.to_nick= "Wiz"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe IRCParser, "parsing kick command" do
|
|
4
|
+
|
|
5
|
+
# ; Kick Matthew from &Melbourne
|
|
6
|
+
it_parses "KICK &Melbourne Matthew" do |msg|
|
|
7
|
+
msg.channels.should == ["&Melbourne"]
|
|
8
|
+
msg.users.should == ["Matthew"]
|
|
9
|
+
msg.kick_message.should be_nil
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# ; Kick Matthew and Jason from &Melbourne and #other
|
|
13
|
+
it_parses "KICK &Melbourne,#other Matthew,Jason" do |msg|
|
|
14
|
+
msg.channels.should == ["&Melbourne", "#other"]
|
|
15
|
+
msg.users.should == ["Matthew", "Jason"]
|
|
16
|
+
msg.kick_message.should be_nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# ; Kick John from #Finnish using "Speaking English" as the reason (comment).
|
|
20
|
+
it_parses "KICK #Finnish John :Speaking English" do |msg|
|
|
21
|
+
msg.channels.should == ["#Finnish"]
|
|
22
|
+
msg.users.should == ["John"]
|
|
23
|
+
msg.kick_message.should == "Speaking English"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# ; KICK msg from WiZ to remove John from channel #Finnish
|
|
27
|
+
it_parses ":WiZ KICK #Finnish John" do |msg|
|
|
28
|
+
msg.prefix.should == "WiZ"
|
|
29
|
+
msg.channels.should == ["#Finnish"]
|
|
30
|
+
msg.users.should == ["John"]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#------------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
it_generates IRCParser::Messages::Kick, "KICK &Melbourne Matthew" do |msg|
|
|
36
|
+
msg.channels= ["&Melbourne"]
|
|
37
|
+
msg.users= ["Matthew"]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it_generates IRCParser::Messages::Kick, "KICK &Melbourne,#other Matthew,Jason" do |msg|
|
|
41
|
+
msg.channels= ["&Melbourne", "#other"]
|
|
42
|
+
msg.users= ["Matthew", "Jason"]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it_generates IRCParser::Messages::Kick, "KICK #Finnish John :Speaking English" do |msg|
|
|
46
|
+
msg.channels = "#Finnish"
|
|
47
|
+
msg.users = "John"
|
|
48
|
+
msg.kick_message = "Speaking English"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it_generates IRCParser::Messages::Kick, ":WiZ KICK #Finnish John" do |msg|
|
|
52
|
+
msg.prefix= "WiZ"
|
|
53
|
+
msg.channels= ["#Finnish"]
|
|
54
|
+
msg.users= ["John"]
|
|
55
|
+
end
|
|
56
|
+
end
|