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,51 @@
|
|
|
1
|
+
module IRCParser::Messages
|
|
2
|
+
define_message :ErrNoSuchNick , '401', :nick, :error_nick, "No such nick/channel"
|
|
3
|
+
define_message :ErrNoSuchServer , '402', :nick, :server, "No such server"
|
|
4
|
+
define_message :ErrNoSuchChannel , '403', :nick, :channel, "No such channel"
|
|
5
|
+
define_message :ErrCannotSendToChan , '404', :nick, :channel, "Cannot send to channel"
|
|
6
|
+
define_message :ErrTooManyChannels , '405', :nick, :channel, "You have joined too many channels"
|
|
7
|
+
define_message :ErrWasNoSuchNick , '406', :nick, :error_nick, "There was no such nickname"
|
|
8
|
+
define_message :ErrTooManyTargets , '407', :nick, :target, "Duplicate recipients. No message delivered"
|
|
9
|
+
define_message :ErrNoOrigin , '409', :nick, "No origin specified"
|
|
10
|
+
define_message :ErrNoRecipient , '411', :nick, "No recipient given (%{command})"
|
|
11
|
+
define_message :ErrNoTextToSend , '412', :nick, "No text to send"
|
|
12
|
+
define_message :ErrNoTopLevel , '413', :nick, :mask, "No toplevel domain specified"
|
|
13
|
+
define_message :ErrWildTopLevel , '414', :nick, :mask, "Wildcard in toplevel domain"
|
|
14
|
+
define_message :ErrUnknownCommand , '421', :command, "Unknown command"
|
|
15
|
+
define_message :ErrNoMotd , '422', :nick, "MOTD File is missing"
|
|
16
|
+
define_message :ErrNoAdminInfo , '423', :nick, :server, "No administrative info available"
|
|
17
|
+
define_message :ErrFileError , '424', :nick, "File error doing %{fileop} on %{file}"
|
|
18
|
+
define_message :ErrNoNickNameGiven , '431', :nick, "No nickname given"
|
|
19
|
+
define_message :ErrErroneusNickName , '432', :nick, :error_nick, "Erroneus nickname"
|
|
20
|
+
define_message :ErrNickNameInUse , '433', :nick, :error_nick, "Nickname is already in use"
|
|
21
|
+
define_message :ErrNickCollision , '436', :nick, :error_nick, "Nickname collision KILL"
|
|
22
|
+
define_message :ErrUserNotInChannel , '441', :nick, :error_nick, :channel, "They aren't on that channel"
|
|
23
|
+
define_message :ErrNotOnChannel , '442', :nick, :channel, "You're not on that channel"
|
|
24
|
+
define_message :ErrUserOnChannel , '443', :nick, :user, :channel, "is already on channel"
|
|
25
|
+
define_message :ErrNoLogin , '444', :nick, :user, "User not logged in"
|
|
26
|
+
define_message :ErrSummonDisabled , '445', :nick, "SUMMON has been disabled"
|
|
27
|
+
define_message :ErrUsersDisabled , '446', :nick, "USERS has been disabled"
|
|
28
|
+
define_message :ErrNotRegistered , '451', :nick, "You have not registered"
|
|
29
|
+
define_message :ErrNeedMoreParams , '461', :nick, :command, "Not enough parameters"
|
|
30
|
+
define_message :ErrAlreadyRegistred , '462', :nick, "You may not reregister"
|
|
31
|
+
define_message :ErrNoPermForHost , '463', :nick, "Your host isn't among the privileged"
|
|
32
|
+
define_message :ErrPasswdMismatch , '464', :nick, "Password incorrect"
|
|
33
|
+
define_message :ErrYouReBannedCreep , '465', :nick, "You are banned from this server"
|
|
34
|
+
define_message :ErrKeySet , '467', :nick, :channel, "Channel key already set"
|
|
35
|
+
define_message :ErrChannelIsFull , '471', :nick, :channel, "Cannot join channel (+l)"
|
|
36
|
+
define_message :ErrUnknownMode , '472', :nick, :char, "is unknown mode char to me"
|
|
37
|
+
define_message :ErrInviteOnLYChan , '473', :nick, :channel, "Cannot join channel (+i)"
|
|
38
|
+
define_message :ErrBannedFromChan , '474', :nick, :channel, "Cannot join channel (+b)"
|
|
39
|
+
define_message :ErrBadChannelKey , '475', :nick, :channel, "Cannot join channel (+k)"
|
|
40
|
+
define_message :ErrNoPrivileges , '481', :nick, "Permission Denied- You're not an IRC operator"
|
|
41
|
+
define_message :ErrChanOPrivsNeeded , '482', :nick, :channel, "You're not channel operator"
|
|
42
|
+
define_message :ErrCantKillServer , '483', :nick, "You cant kill a server!"
|
|
43
|
+
define_message :ErrNoOperHost , '491', :nick, "No O-lines for your host"
|
|
44
|
+
define_message :ErrUModeUnknownFlag , '501', :nick, "Unknown MODE flag"
|
|
45
|
+
define_message :ErrUsersDontMatch , '502', :nick, "Cant change mode for other users"
|
|
46
|
+
|
|
47
|
+
# Not Used / Reserved ( http://tools.ietf.org/html/rfc1459#section-6.3
|
|
48
|
+
# :YouWillBeBanned
|
|
49
|
+
# :BadChanMask
|
|
50
|
+
# :NoServiceHost
|
|
51
|
+
end
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
module IRCParser::Messages
|
|
2
|
+
define_message :RplWelcome , "001", :nick, "%{welcome} %{user}"
|
|
3
|
+
define_message :RplYourHost , "002", :nick, "Your host is %{server_name} running version %{version}"
|
|
4
|
+
define_message :RplCreated , "003", :nick, "This server was created %{date}"
|
|
5
|
+
define_message :RplMyInfo , "004", :nick, :server_name, :version, :available_user_modes, :available_channel_modes
|
|
6
|
+
define_message :RplBounce , "005", :nick, "Try server %{server_name} port %{port}"
|
|
7
|
+
define_message :RplTraceLink , '200', :nick, "Link", :version, :destination, :next_server
|
|
8
|
+
define_message :RplTraceConnecting , '201', :nick, "Try.", :klass, :server
|
|
9
|
+
define_message :RplTraceHandshake , '202', :nick, "H.S.", :klass, :server
|
|
10
|
+
define_message :RplTraceUnknown , '203', :nick, "????", :klass, :ip_address
|
|
11
|
+
define_message :RplTraceOperator , '204', :nick, "Oper", :klass, :user_nick
|
|
12
|
+
define_message :RplTraceUser , '205', :nick, "User", :klass, :user_nick
|
|
13
|
+
define_message :RplTraceServer , '206', :nick, "Serv", :klass, :intS, :intC, :server, :identity
|
|
14
|
+
define_message :RplTraceNewType , '208', :nick, :new_type, "0", :client_name
|
|
15
|
+
define_message :RplStatsLinkInfo , '211', :nick, :linkname, :sendq, :sent_messages, :sent_bytes, :received_messages, :received_bytes, :time_open
|
|
16
|
+
define_message :RplStatsCommands , '212', :nick, :command, :count
|
|
17
|
+
define_message :RplStatsCLine , '213', :nick, "C", :host, "*", :name_param, :port, :klass
|
|
18
|
+
define_message :RplStatsNLine , '214', :nick, "N", :host, "*", :name_param, :port, :klass
|
|
19
|
+
define_message :RplStatsILine , '215', :nick, "I", :host, "*", :second_host, :port, :klass
|
|
20
|
+
define_message :RplStatsKLine , '216', :nick, "K", :host, "*", :username, :port, :klass
|
|
21
|
+
define_message :RplStatsYLine , '218', :nick, "Y", :klass, :ping_frequency, :connect_frequency, :max_sendq
|
|
22
|
+
define_message :RplEndOfStats , '219', :nick, :stats_letter, "End of /STATS report"
|
|
23
|
+
define_message :RplUModeIs , '221', :nick, :user_nick, :flags
|
|
24
|
+
define_message :RplStatsLLine , '241', :nick, "L", :host_mask, "*", :server_name, :max_depth
|
|
25
|
+
define_message :RplStatsUptime , '242', :nick, "Server Up %{days} days %{time}" # time format : %d:%02d:%02d
|
|
26
|
+
define_message :RplStatsOLine , '243', :nick, "O", :host_mask, "*", :name_param
|
|
27
|
+
define_message :RplStatsHLine , '244', :nick, "H", :host_mask, "*", :server_name
|
|
28
|
+
define_message :RplStatsDLine , '250', :nick, "Highest connection count: %{connections} (%{clients}) (%{connections_received} connections received"
|
|
29
|
+
define_message :RplLUserClient , '251', :nick, "There are %{users_count} users and %{invisible_count} invisible on %{servers} servers"
|
|
30
|
+
define_message :RplLUserOp , '252', :nick, :operator_count, "operator(s) online"
|
|
31
|
+
define_message :RplLUserUnknown , '253', :nick, :connections, "unknown connection(s)"
|
|
32
|
+
define_message :RplLUserChannels , '254', :nick, :channels_count, "channels formed"
|
|
33
|
+
define_message :RplLUserMe , '255', :nick, "I have %{clients_count} clients and %{servers_count} servers"
|
|
34
|
+
define_message :RplAdminMe , '256', :nick, :server, "Administrative info"
|
|
35
|
+
define_message :RplAdminLoc1 , '257', :nick, :info => :postfix
|
|
36
|
+
define_message :RplAdminLoc2 , '258', :nick, :info => :postfix
|
|
37
|
+
define_message :RplAdminEmail , '259', :nick, :info => :postfix
|
|
38
|
+
define_message :RplTraceLog , '261', :nick, "File", :logfile, :debug_level
|
|
39
|
+
define_message :RplNone , "300", :nick
|
|
40
|
+
define_message :RplUserHost , "302", :nick, "%{users} = %{host_with_sign}"
|
|
41
|
+
define_message :RplAway , "301", :nick, :away_nick, :message => :postfix
|
|
42
|
+
define_message :RplUnAway , '305', :nick, "You are no longer marked as being away"
|
|
43
|
+
define_message :RplNowAway , '306', :nick, "You have been marked as being away"
|
|
44
|
+
define_message :RplWhoIsUser , '311', :nick, :user_nick, :user, :ip, "*", :realname => :postfix
|
|
45
|
+
define_message :RplWhoIsServer , '312', :nick, :user, :server, :info => :postfix
|
|
46
|
+
define_message :RplWhoIsOperator , '313', :nick, :user, "is an IRC operator"
|
|
47
|
+
define_message :RplWhoWasUser , '314', :nick, :user, :host, "*", :realname => :postfix
|
|
48
|
+
define_message :RplEndOfWho , '315', :nick, :pattern, "End of /WHO list"
|
|
49
|
+
define_message :RplWhoIsIdle , '317', :nick, :user, :seconds, "seconds idle"
|
|
50
|
+
define_message :RplEndOfWhoIs , '318', :nick, :user_nick, "End of /WHOIS list"
|
|
51
|
+
define_message :RplListStart , '321', :nick, "Channel", "Users Name"
|
|
52
|
+
define_message :RplList , '322', :nick, :channel, :visible, :topic => :postfix
|
|
53
|
+
define_message :RplListEnd , '323', :nick, "End of /LIST"
|
|
54
|
+
define_message :RplChannelModeIs , '324', :nick, :channel, :mode
|
|
55
|
+
define_message :RplInviting , '341', :nick, :channel, :nick_inv
|
|
56
|
+
define_message :RplSummoning , '342', :nick, :user, "Summoning user to IRC"
|
|
57
|
+
define_message :RplVersion , '351', :nick, :version, :server, :comments => :postfix
|
|
58
|
+
define_message :RplLinks , '364', :nick, :mask, :server, "%{hopcount} %{server_info}"
|
|
59
|
+
define_message :RplEndOfLinks , '365', :nick, :mask, "End of /LINKS list"
|
|
60
|
+
define_message :RplBanList , '367', :nick, :channel, :ban_id
|
|
61
|
+
define_message :RplEndOfBanList , '368', :nick, :channel, "End of channel ban list"
|
|
62
|
+
define_message :RplEndOfWhoWas , '369', :nick, "End of WHOWAS"
|
|
63
|
+
define_message :RplInfo , '371', :nick, :info => :postfix
|
|
64
|
+
define_message :RplEndOfInfo , '374', :nick, "End of /INFO list"
|
|
65
|
+
define_message :RplMotdStart , '375', :nick, "-%{server} %{message}-"
|
|
66
|
+
define_message :RplMotd , '372', :nick, "-%{motd}"
|
|
67
|
+
define_message :RplEndOfMotd , '376', :nick, "End of /MOTD command"
|
|
68
|
+
define_message :RplYouReOper , '381', :nick, "You are now an IRC operator"
|
|
69
|
+
define_message :RplRehashing , '382', :nick, :config_file, "Rehashing"
|
|
70
|
+
define_message :RplTime , '391', :nick, :server, :local_time => :postfix
|
|
71
|
+
define_message :RplUsersStart , '392', :nick, "UserID Terminal Host"
|
|
72
|
+
define_message :RplUsers , '393', :nick, "%{username} %{ttyline} %{hostname}"
|
|
73
|
+
define_message :RplEndOfUsers , '394', :nick, "End of users"
|
|
74
|
+
define_message :RplNoUsers , '395', :nick, "Nobody logged in"
|
|
75
|
+
|
|
76
|
+
define_message :RplIsOn, "303", :nick, :nicks => :postfix do
|
|
77
|
+
def nicks
|
|
78
|
+
postfix.split(" ")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def nicks=(nicks)
|
|
82
|
+
self.postfix = Array(nicks).join(" ")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
define_message :RplWhoIsChannels, "319", :nick, :user, :channels => :postfix do
|
|
87
|
+
def channels
|
|
88
|
+
postfix.split(" ")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def channels=(val)
|
|
92
|
+
self.postfix = Array(val).join(" ")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# This message does not appear in the RFCs afaict
|
|
97
|
+
# http://www.mirc.net/raws/?view=265
|
|
98
|
+
define_message :RplLUserCount, '265', :nick, :current, :max, "Current local users"
|
|
99
|
+
|
|
100
|
+
# This message does not appear in the RFCs afaict
|
|
101
|
+
# http://www.mirc.net/raws/?view=266
|
|
102
|
+
define_message :RplGlobalLUserCount, '266', :nick, :current, :max, "Current global users"
|
|
103
|
+
|
|
104
|
+
# http://www.mirc.net/raws/?view=328
|
|
105
|
+
# This is sent to you by ChanServ when you join a registered channel.
|
|
106
|
+
# :services. 328 emmanueloga #chef :http://www.opscode.com
|
|
107
|
+
define_message :RplChannelServices, '328', :nick, :channel, :comment
|
|
108
|
+
|
|
109
|
+
# http://www.mirc.net/raws/?view=329
|
|
110
|
+
# name given by me. This does not appear in the rfcs.
|
|
111
|
+
# :gibson.freenode.net 329 emmanueloga #canal 1263942709
|
|
112
|
+
define_message :RplChannelTimestamp, '329', :nick, :channel, :timestamp
|
|
113
|
+
|
|
114
|
+
# http://mirc.net/raws/?view=331
|
|
115
|
+
# 331 nick #hello :No topic is set
|
|
116
|
+
# Looks like the nick needs to be present on the message, despite what mirc.net says.
|
|
117
|
+
define_message :RplNoTopic, '331', :nick, :channel, "No topic is set"
|
|
118
|
+
|
|
119
|
+
# http://www.mirc.net/raws/?view=332
|
|
120
|
+
# 332 nick #peace&protection :Peace & Protection 3.14abcd, it kicks more ass then that damn taco bell dog on speed
|
|
121
|
+
# Looks like the nick needs to be present on the message, despite what mirc.net says.
|
|
122
|
+
define_message :RplTopic, '332', :nick, :channel, :topic => :postfix
|
|
123
|
+
|
|
124
|
+
# Raw Numeric 333
|
|
125
|
+
# This is returned for a TOPIC request or when you JOIN, if the channel has a topic.
|
|
126
|
+
# :gibson.freenode.net 333 emmanuel_oga #RubyOnRails wmoxam!~wmoxam@cmr-208-124-190-170.cr.net.cable.rogers.com 1285016759
|
|
127
|
+
# http://www.mirc.net/raws/?view=333
|
|
128
|
+
define_message :RplTopicWithTimestamp, '333', :nick, :channel, :inviter_prefix, :timestamp
|
|
129
|
+
|
|
130
|
+
# http://www.mirc.net/raws/?view=352
|
|
131
|
+
# Example:
|
|
132
|
+
# 352 channel username address server nick flags :hops info
|
|
133
|
+
# 352 #peace&protection IsaacHayes sdn-ar-004mokcitP324.dialsprint.net NewBrunswick.NJ.US.Undernet.Org DrDthmtch H+ :4 Isaac Hayes (QuickScript.ml.org)
|
|
134
|
+
# Flags: <H|G>[*][@|+] (here, gone)
|
|
135
|
+
define_message :RplWhoReply, "352", :channel, :user, :host, :server, :user_nick, :flags, "%{hopcount} %{realname}" do
|
|
136
|
+
FLAGS_INDEX_ON_PARAMS = 6
|
|
137
|
+
|
|
138
|
+
FLAGS = {
|
|
139
|
+
0 => { :here => "H", :gone => "G" },
|
|
140
|
+
1 => { :ircop => "*" },
|
|
141
|
+
2 => { :opped => "@", :voiced => "+" },
|
|
142
|
+
3 => { :deaf => "d" }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
def initialize(prefix, params = [])
|
|
146
|
+
super(prefix, *params)
|
|
147
|
+
|
|
148
|
+
@flags = Array.new(FLAGS.size)
|
|
149
|
+
|
|
150
|
+
if params
|
|
151
|
+
original_flags = params[FLAGS_INDEX_ON_PARAMS] || ""
|
|
152
|
+
|
|
153
|
+
FLAGS.each do |index, setters|
|
|
154
|
+
setters.each do |flag, pattern|
|
|
155
|
+
send "#{flag}!", true if original_flags.index(pattern)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
FLAGS.each do |index, flags|
|
|
162
|
+
flags.each do |flag, pattern|
|
|
163
|
+
define_method("#{flag}?") do
|
|
164
|
+
not self.flags.index(pattern).nil?
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
define_method("#{flag}!") do |val|
|
|
168
|
+
on = flags[flag]; off = (flags.values - [on]).first
|
|
169
|
+
update_flags(index, val ? on : off)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def update_flags(index, val)
|
|
175
|
+
@flags[index] = val
|
|
176
|
+
self.flags = @flags.join
|
|
177
|
+
end
|
|
178
|
+
private :update_flags
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# http://www.mirc.net/raws/?view=353
|
|
182
|
+
# :rpl_nam_reply >> :sendak.freenode.net 353 emmanuel @ #pipita2 :@emmanuel
|
|
183
|
+
# each nick should include flags [[@|+]#{nick}
|
|
184
|
+
define_message :RplNamReply, '353', :nick, "@", :channel do
|
|
185
|
+
def nicks_with_flags
|
|
186
|
+
postfix.split(" ") if postfix
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def nicks_with_flags=(nicks)
|
|
190
|
+
self.postfix= Array(nicks).join(" ")
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# http://www.mirc.net/raws/?view=366
|
|
195
|
+
# :rpl_end_of_names >> :sendak.freenode.net 366 emmanuel #pipita2 :End of /NAMES list.
|
|
196
|
+
define_message :RplEndOfNames, '366', :channel, "End of /NAMES list"
|
|
197
|
+
|
|
198
|
+
# Not Used / Reserved ( http://tools.ietf.org/html/rfc1459#section-6.3
|
|
199
|
+
# RplTraceClass , '209'
|
|
200
|
+
# RplStatsQLine , '217'
|
|
201
|
+
# RplServiceInfo , '231'
|
|
202
|
+
# RplEndOfServices , '232'
|
|
203
|
+
# RplService , '233'
|
|
204
|
+
# RplServList , '234'
|
|
205
|
+
# RplServListend , '235'
|
|
206
|
+
# RplWhoIsChanOp , '316'
|
|
207
|
+
# RplKillDone , '361'
|
|
208
|
+
# RplClosing , '362'
|
|
209
|
+
# RplCloseend , '363'
|
|
210
|
+
# RplInfoStart , '373'
|
|
211
|
+
# RplMyPortIs , '384'
|
|
212
|
+
end
|
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
|
|
2
|
+
# line 1 "lib/irc_parser/parser.rl"
|
|
3
|
+
|
|
4
|
+
# line 45 "lib/irc_parser/parser.rl"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module IRCParser
|
|
8
|
+
class ParserError < RuntimeError; end
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# line 12 "lib/irc_parser/parser.rb"
|
|
12
|
+
class << self
|
|
13
|
+
attr_accessor :_irc_parser_trans_keys
|
|
14
|
+
private :_irc_parser_trans_keys, :_irc_parser_trans_keys=
|
|
15
|
+
end
|
|
16
|
+
self._irc_parser_trans_keys = [
|
|
17
|
+
0, 0, 48, 122, 48, 57,
|
|
18
|
+
48, 57, 13, 32, 10,
|
|
19
|
+
10, 1, 127, 1, 127,
|
|
20
|
+
1, 127, -128, 13, -128, -65,
|
|
21
|
+
-128, 13, -128, -65, -128,
|
|
22
|
+
-65, 45, 122, 32, 122,
|
|
23
|
+
32, 122, 13, 122, 32, 126,
|
|
24
|
+
1, 127, 1, 127, 45,
|
|
25
|
+
122, 32, 126, 0, 0,
|
|
26
|
+
0
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
class << self
|
|
30
|
+
attr_accessor :_irc_parser_key_spans
|
|
31
|
+
private :_irc_parser_key_spans, :_irc_parser_key_spans=
|
|
32
|
+
end
|
|
33
|
+
self._irc_parser_key_spans = [
|
|
34
|
+
0, 75, 10, 10, 20, 1, 127, 127,
|
|
35
|
+
127, 142, 64, 142, 64, 64, 78, 91,
|
|
36
|
+
91, 110, 95, 127, 127, 78, 95, 0
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
class << self
|
|
40
|
+
attr_accessor :_irc_parser_index_offsets
|
|
41
|
+
private :_irc_parser_index_offsets, :_irc_parser_index_offsets=
|
|
42
|
+
end
|
|
43
|
+
self._irc_parser_index_offsets = [
|
|
44
|
+
0, 0, 76, 87, 98, 119, 121, 249,
|
|
45
|
+
377, 505, 648, 713, 856, 921, 986, 1065,
|
|
46
|
+
1157, 1249, 1360, 1456, 1584, 1712, 1791, 1887
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
class << self
|
|
50
|
+
attr_accessor :_irc_parser_indicies
|
|
51
|
+
private :_irc_parser_indicies, :_irc_parser_indicies=
|
|
52
|
+
end
|
|
53
|
+
self._irc_parser_indicies = [
|
|
54
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
|
55
|
+
0, 0, 2, 1, 1, 1, 1, 1,
|
|
56
|
+
1, 3, 3, 3, 3, 3, 3, 3,
|
|
57
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
58
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
59
|
+
3, 3, 3, 1, 1, 1, 1, 1,
|
|
60
|
+
1, 3, 3, 3, 3, 3, 3, 3,
|
|
61
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
62
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
63
|
+
3, 3, 3, 1, 4, 4, 4, 4,
|
|
64
|
+
4, 4, 4, 4, 4, 4, 1, 5,
|
|
65
|
+
5, 5, 5, 5, 5, 5, 5, 5,
|
|
66
|
+
5, 1, 6, 1, 1, 1, 1, 1,
|
|
67
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
68
|
+
1, 1, 1, 1, 1, 7, 1, 8,
|
|
69
|
+
1, 9, 9, 9, 9, 9, 9, 9,
|
|
70
|
+
9, 9, 1, 9, 9, 10, 9, 9,
|
|
71
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
72
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
73
|
+
11, 9, 9, 9, 9, 9, 9, 9,
|
|
74
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
75
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
76
|
+
9, 9, 12, 9, 9, 9, 9, 9,
|
|
77
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
78
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
79
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
80
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
81
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
82
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
83
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
84
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
85
|
+
1, 13, 13, 13, 13, 13, 13, 13,
|
|
86
|
+
13, 13, 1, 13, 13, 14, 13, 13,
|
|
87
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
88
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
89
|
+
15, 13, 13, 13, 13, 13, 13, 13,
|
|
90
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
91
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
92
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
93
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
94
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
95
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
96
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
97
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
98
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
99
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
100
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
|
101
|
+
1, 9, 9, 9, 9, 9, 9, 9,
|
|
102
|
+
9, 9, 1, 9, 9, 1, 9, 9,
|
|
103
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
104
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
105
|
+
16, 9, 9, 9, 9, 9, 9, 9,
|
|
106
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
107
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
108
|
+
9, 9, 12, 9, 9, 9, 9, 9,
|
|
109
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
110
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
111
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
112
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
113
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
114
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
115
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
116
|
+
9, 9, 9, 9, 9, 9, 9, 9,
|
|
117
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
118
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
119
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
120
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
121
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
122
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
123
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
124
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
125
|
+
1, 1, 1, 17, 17, 17, 17, 17,
|
|
126
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
|
127
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
|
128
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
|
129
|
+
17, 18, 18, 18, 18, 18, 18, 18,
|
|
130
|
+
18, 18, 18, 18, 18, 18, 18, 18,
|
|
131
|
+
18, 19, 19, 19, 19, 19, 1, 1,
|
|
132
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
133
|
+
1, 1, 20, 20, 20, 20, 20, 20,
|
|
134
|
+
20, 20, 20, 1, 20, 20, 21, 20,
|
|
135
|
+
22, 22, 22, 22, 22, 22, 22, 22,
|
|
136
|
+
22, 22, 22, 22, 22, 22, 22, 22,
|
|
137
|
+
22, 22, 22, 22, 22, 22, 22, 22,
|
|
138
|
+
22, 22, 22, 22, 22, 22, 22, 22,
|
|
139
|
+
22, 22, 22, 22, 22, 22, 22, 22,
|
|
140
|
+
22, 22, 22, 22, 22, 22, 22, 22,
|
|
141
|
+
22, 22, 22, 22, 22, 22, 22, 22,
|
|
142
|
+
22, 22, 22, 22, 22, 22, 22, 22,
|
|
143
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
144
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
145
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
146
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
147
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
148
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
149
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
150
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
151
|
+
1, 1, 1, 23, 23, 23, 23, 23,
|
|
152
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
153
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
154
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
155
|
+
23, 24, 24, 24, 24, 24, 24, 24,
|
|
156
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
|
157
|
+
24, 25, 25, 25, 25, 25, 1, 1,
|
|
158
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
159
|
+
1, 1, 22, 22, 22, 22, 22, 22,
|
|
160
|
+
22, 22, 22, 1, 22, 22, 14, 22,
|
|
161
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
162
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
163
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
164
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
165
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
166
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
167
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
168
|
+
23, 23, 23, 23, 23, 23, 23, 23,
|
|
169
|
+
1, 24, 24, 24, 24, 24, 24, 24,
|
|
170
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
|
171
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
|
172
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
|
173
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
|
174
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
|
175
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
|
176
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
|
177
|
+
24, 1, 26, 26, 1, 26, 26, 26,
|
|
178
|
+
26, 26, 26, 26, 26, 26, 26, 1,
|
|
179
|
+
1, 1, 1, 1, 1, 1, 27, 27,
|
|
180
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
|
181
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
|
182
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
|
183
|
+
1, 1, 1, 1, 1, 1, 27, 27,
|
|
184
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
|
185
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
|
186
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
|
187
|
+
1, 28, 1, 1, 1, 1, 1, 1,
|
|
188
|
+
1, 1, 1, 1, 1, 1, 29, 29,
|
|
189
|
+
1, 29, 29, 29, 29, 29, 29, 29,
|
|
190
|
+
29, 29, 29, 1, 1, 1, 1, 1,
|
|
191
|
+
1, 1, 29, 29, 29, 29, 29, 29,
|
|
192
|
+
29, 29, 29, 29, 29, 29, 29, 29,
|
|
193
|
+
29, 29, 29, 29, 29, 29, 29, 29,
|
|
194
|
+
29, 29, 29, 29, 1, 1, 1, 1,
|
|
195
|
+
1, 1, 29, 29, 29, 29, 29, 29,
|
|
196
|
+
29, 29, 29, 29, 29, 29, 29, 29,
|
|
197
|
+
29, 29, 29, 29, 29, 29, 29, 29,
|
|
198
|
+
29, 29, 29, 29, 1, 30, 1, 1,
|
|
199
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
200
|
+
1, 1, 1, 1, 1, 0, 0, 0,
|
|
201
|
+
0, 0, 0, 0, 0, 0, 0, 1,
|
|
202
|
+
1, 1, 1, 1, 1, 1, 3, 3,
|
|
203
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
204
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
205
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
206
|
+
1, 1, 1, 1, 1, 1, 3, 3,
|
|
207
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
208
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
209
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
|
210
|
+
1, 6, 1, 1, 1, 1, 1, 1,
|
|
211
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
212
|
+
1, 1, 1, 1, 7, 1, 1, 1,
|
|
213
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
214
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
215
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
|
216
|
+
1, 1, 1, 1, 1, 31, 31, 31,
|
|
217
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
|
218
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
|
219
|
+
31, 31, 31, 31, 31, 31, 31, 1,
|
|
220
|
+
1, 1, 1, 1, 1, 31, 31, 31,
|
|
221
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
|
222
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
|
223
|
+
31, 31, 31, 31, 31, 31, 31, 1,
|
|
224
|
+
28, 32, 1, 1, 1, 1, 1, 1,
|
|
225
|
+
1, 1, 1, 1, 1, 33, 29, 1,
|
|
226
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
|
227
|
+
33, 33, 1, 1, 1, 1, 1, 1,
|
|
228
|
+
34, 33, 33, 33, 33, 33, 33, 33,
|
|
229
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
|
230
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
|
231
|
+
33, 33, 33, 35, 35, 35, 35, 35,
|
|
232
|
+
35, 33, 33, 33, 33, 33, 33, 33,
|
|
233
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
|
234
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
|
235
|
+
33, 33, 33, 35, 1, 35, 35, 1,
|
|
236
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
237
|
+
36, 1, 36, 36, 1, 36, 36, 36,
|
|
238
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
239
|
+
36, 36, 36, 36, 36, 36, 36, 1,
|
|
240
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
241
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
242
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
243
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
244
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
245
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
246
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
247
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
248
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
249
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
250
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
251
|
+
36, 36, 36, 36, 36, 36, 36, 1,
|
|
252
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
253
|
+
36, 1, 36, 36, 1, 36, 36, 36,
|
|
254
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
255
|
+
36, 36, 36, 36, 36, 36, 36, 28,
|
|
256
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
257
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
258
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
259
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
260
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
261
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
262
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
263
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
264
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
265
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
266
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
|
267
|
+
36, 36, 36, 36, 36, 36, 36, 1,
|
|
268
|
+
29, 29, 1, 29, 29, 29, 29, 29,
|
|
269
|
+
29, 29, 29, 29, 29, 1, 1, 1,
|
|
270
|
+
1, 1, 1, 1, 29, 29, 29, 29,
|
|
271
|
+
29, 29, 29, 29, 29, 29, 29, 29,
|
|
272
|
+
29, 29, 29, 29, 29, 29, 29, 29,
|
|
273
|
+
29, 29, 29, 29, 29, 29, 1, 1,
|
|
274
|
+
1, 1, 1, 1, 29, 29, 29, 29,
|
|
275
|
+
29, 29, 29, 29, 29, 29, 29, 29,
|
|
276
|
+
29, 29, 29, 29, 29, 29, 29, 29,
|
|
277
|
+
29, 29, 29, 29, 29, 29, 1, 28,
|
|
278
|
+
32, 1, 1, 1, 1, 1, 1, 1,
|
|
279
|
+
1, 1, 1, 1, 35, 1, 1, 35,
|
|
280
|
+
35, 35, 35, 35, 35, 35, 35, 35,
|
|
281
|
+
35, 1, 1, 1, 1, 1, 1, 34,
|
|
282
|
+
35, 35, 35, 35, 35, 35, 35, 35,
|
|
283
|
+
35, 35, 35, 35, 35, 35, 35, 35,
|
|
284
|
+
35, 35, 35, 35, 35, 35, 35, 35,
|
|
285
|
+
35, 35, 35, 35, 35, 35, 35, 35,
|
|
286
|
+
35, 35, 35, 35, 35, 35, 35, 35,
|
|
287
|
+
35, 35, 35, 35, 35, 35, 35, 35,
|
|
288
|
+
35, 35, 35, 35, 35, 35, 35, 35,
|
|
289
|
+
35, 35, 35, 1, 35, 35, 1, 1,
|
|
290
|
+
0
|
|
291
|
+
]
|
|
292
|
+
|
|
293
|
+
class << self
|
|
294
|
+
attr_accessor :_irc_parser_trans_targs
|
|
295
|
+
private :_irc_parser_trans_targs, :_irc_parser_trans_targs=
|
|
296
|
+
end
|
|
297
|
+
self._irc_parser_trans_targs = [
|
|
298
|
+
2, 0, 14, 17, 3, 4, 5, 6,
|
|
299
|
+
23, 7, 5, 6, 9, 7, 5, 8,
|
|
300
|
+
8, 10, 12, 13, 11, 5, 11, 10,
|
|
301
|
+
12, 13, 15, 18, 16, 15, 16, 17,
|
|
302
|
+
19, 18, 21, 22, 20
|
|
303
|
+
]
|
|
304
|
+
|
|
305
|
+
class << self
|
|
306
|
+
attr_accessor :_irc_parser_trans_actions
|
|
307
|
+
private :_irc_parser_trans_actions, :_irc_parser_trans_actions=
|
|
308
|
+
end
|
|
309
|
+
self._irc_parser_trans_actions = [
|
|
310
|
+
1, 0, 0, 1, 0, 0, 2, 2,
|
|
311
|
+
0, 1, 0, 0, 0, 0, 3, 3,
|
|
312
|
+
0, 1, 1, 1, 1, 4, 0, 0,
|
|
313
|
+
0, 0, 1, 1, 5, 0, 0, 0,
|
|
314
|
+
0, 0, 0, 0, 0
|
|
315
|
+
]
|
|
316
|
+
|
|
317
|
+
class << self
|
|
318
|
+
attr_accessor :irc_parser_start
|
|
319
|
+
end
|
|
320
|
+
self.irc_parser_start = 1;
|
|
321
|
+
class << self
|
|
322
|
+
attr_accessor :irc_parser_first_final
|
|
323
|
+
end
|
|
324
|
+
self.irc_parser_first_final = 23;
|
|
325
|
+
class << self
|
|
326
|
+
attr_accessor :irc_parser_error
|
|
327
|
+
end
|
|
328
|
+
self.irc_parser_error = 0;
|
|
329
|
+
|
|
330
|
+
class << self
|
|
331
|
+
attr_accessor :irc_parser_en_main
|
|
332
|
+
end
|
|
333
|
+
self.irc_parser_en_main = 1;
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
# line 51 "lib/irc_parser/parser.rl"
|
|
337
|
+
|
|
338
|
+
CLASS_FROM_PARSE = Hash.new { |h,k| h[k] = Messages::ALL[k] } # This hash will be smaller than Messages::ALL, and hence faster.
|
|
339
|
+
|
|
340
|
+
def parse(message)
|
|
341
|
+
data = message.unpack("c*")
|
|
342
|
+
|
|
343
|
+
prefix, command, params = nil, nil, []
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
# line 347 "lib/irc_parser/parser.rb"
|
|
347
|
+
begin
|
|
348
|
+
p ||= 0
|
|
349
|
+
pe ||= data.length
|
|
350
|
+
cs = irc_parser_start
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# line 60 "lib/irc_parser/parser.rl"
|
|
354
|
+
|
|
355
|
+
# line 356 "lib/irc_parser/parser.rb"
|
|
356
|
+
begin
|
|
357
|
+
testEof = false
|
|
358
|
+
_slen, _trans, _keys, _inds, _acts, _nacts = nil
|
|
359
|
+
_goto_level = 0
|
|
360
|
+
_resume = 10
|
|
361
|
+
_eof_trans = 15
|
|
362
|
+
_again = 20
|
|
363
|
+
_test_eof = 30
|
|
364
|
+
_out = 40
|
|
365
|
+
while true
|
|
366
|
+
if _goto_level <= 0
|
|
367
|
+
if p == pe
|
|
368
|
+
_goto_level = _test_eof
|
|
369
|
+
next
|
|
370
|
+
end
|
|
371
|
+
if cs == 0
|
|
372
|
+
_goto_level = _out
|
|
373
|
+
next
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
if _goto_level <= _resume
|
|
377
|
+
_keys = cs << 1
|
|
378
|
+
_inds = _irc_parser_index_offsets[cs]
|
|
379
|
+
_slen = _irc_parser_key_spans[cs]
|
|
380
|
+
_trans = if ( _slen > 0 &&
|
|
381
|
+
_irc_parser_trans_keys[_keys] <= data[p] &&
|
|
382
|
+
data[p] <= _irc_parser_trans_keys[_keys + 1]
|
|
383
|
+
) then
|
|
384
|
+
_irc_parser_indicies[ _inds + data[p] - _irc_parser_trans_keys[_keys] ]
|
|
385
|
+
else
|
|
386
|
+
_irc_parser_indicies[ _inds + _slen ]
|
|
387
|
+
end
|
|
388
|
+
cs = _irc_parser_trans_targs[_trans]
|
|
389
|
+
if _irc_parser_trans_actions[_trans] != 0
|
|
390
|
+
case _irc_parser_trans_actions[_trans]
|
|
391
|
+
when 1 then
|
|
392
|
+
# line 32 "lib/irc_parser/parser.rl"
|
|
393
|
+
begin
|
|
394
|
+
mark = p end
|
|
395
|
+
when 5 then
|
|
396
|
+
# line 33 "lib/irc_parser/parser.rl"
|
|
397
|
+
begin
|
|
398
|
+
prefix = data[mark..(p-1)].pack("c*") end
|
|
399
|
+
when 2 then
|
|
400
|
+
# line 34 "lib/irc_parser/parser.rl"
|
|
401
|
+
begin
|
|
402
|
+
command = data[mark..(p-1)].pack("c*") end
|
|
403
|
+
when 3 then
|
|
404
|
+
# line 35 "lib/irc_parser/parser.rl"
|
|
405
|
+
begin
|
|
406
|
+
params << data[mark..(p-1)].pack("c*") end
|
|
407
|
+
when 4 then
|
|
408
|
+
# line 32 "lib/irc_parser/parser.rl"
|
|
409
|
+
begin
|
|
410
|
+
mark = p end
|
|
411
|
+
# line 35 "lib/irc_parser/parser.rl"
|
|
412
|
+
begin
|
|
413
|
+
params << data[mark..(p-1)].pack("c*") end
|
|
414
|
+
# line 415 "lib/irc_parser/parser.rb"
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
end
|
|
418
|
+
if _goto_level <= _again
|
|
419
|
+
if cs == 0
|
|
420
|
+
_goto_level = _out
|
|
421
|
+
next
|
|
422
|
+
end
|
|
423
|
+
p += 1
|
|
424
|
+
if p != pe
|
|
425
|
+
_goto_level = _resume
|
|
426
|
+
next
|
|
427
|
+
end
|
|
428
|
+
end
|
|
429
|
+
if _goto_level <= _test_eof
|
|
430
|
+
end
|
|
431
|
+
if _goto_level <= _out
|
|
432
|
+
break
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
# line 61 "lib/irc_parser/parser.rl"
|
|
438
|
+
|
|
439
|
+
if cs >= irc_parser_first_final
|
|
440
|
+
klass = CLASS_FROM_PARSE[command]
|
|
441
|
+
raise ParserError, "Message not recognized: #{message.inspect}" unless klass
|
|
442
|
+
klass.new(prefix, params)
|
|
443
|
+
elsif message !~ /\r\n$/
|
|
444
|
+
raise ParserError, "Message must finish with \\r\\n"
|
|
445
|
+
else
|
|
446
|
+
raise ParserError, message
|
|
447
|
+
end
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def parse_raw(message)
|
|
451
|
+
data = message.unpack("c*")
|
|
452
|
+
|
|
453
|
+
prefix, command, params = nil, nil, []
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
# line 457 "lib/irc_parser/parser.rb"
|
|
457
|
+
begin
|
|
458
|
+
p ||= 0
|
|
459
|
+
pe ||= data.length
|
|
460
|
+
cs = irc_parser_start
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
# line 79 "lib/irc_parser/parser.rl"
|
|
464
|
+
|
|
465
|
+
# line 466 "lib/irc_parser/parser.rb"
|
|
466
|
+
begin
|
|
467
|
+
testEof = false
|
|
468
|
+
_slen, _trans, _keys, _inds, _acts, _nacts = nil
|
|
469
|
+
_goto_level = 0
|
|
470
|
+
_resume = 10
|
|
471
|
+
_eof_trans = 15
|
|
472
|
+
_again = 20
|
|
473
|
+
_test_eof = 30
|
|
474
|
+
_out = 40
|
|
475
|
+
while true
|
|
476
|
+
if _goto_level <= 0
|
|
477
|
+
if p == pe
|
|
478
|
+
_goto_level = _test_eof
|
|
479
|
+
next
|
|
480
|
+
end
|
|
481
|
+
if cs == 0
|
|
482
|
+
_goto_level = _out
|
|
483
|
+
next
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
if _goto_level <= _resume
|
|
487
|
+
_keys = cs << 1
|
|
488
|
+
_inds = _irc_parser_index_offsets[cs]
|
|
489
|
+
_slen = _irc_parser_key_spans[cs]
|
|
490
|
+
_trans = if ( _slen > 0 &&
|
|
491
|
+
_irc_parser_trans_keys[_keys] <= data[p] &&
|
|
492
|
+
data[p] <= _irc_parser_trans_keys[_keys + 1]
|
|
493
|
+
) then
|
|
494
|
+
_irc_parser_indicies[ _inds + data[p] - _irc_parser_trans_keys[_keys] ]
|
|
495
|
+
else
|
|
496
|
+
_irc_parser_indicies[ _inds + _slen ]
|
|
497
|
+
end
|
|
498
|
+
cs = _irc_parser_trans_targs[_trans]
|
|
499
|
+
if _irc_parser_trans_actions[_trans] != 0
|
|
500
|
+
case _irc_parser_trans_actions[_trans]
|
|
501
|
+
when 1 then
|
|
502
|
+
# line 32 "lib/irc_parser/parser.rl"
|
|
503
|
+
begin
|
|
504
|
+
mark = p end
|
|
505
|
+
when 5 then
|
|
506
|
+
# line 33 "lib/irc_parser/parser.rl"
|
|
507
|
+
begin
|
|
508
|
+
prefix = data[mark..(p-1)].pack("c*") end
|
|
509
|
+
when 2 then
|
|
510
|
+
# line 34 "lib/irc_parser/parser.rl"
|
|
511
|
+
begin
|
|
512
|
+
command = data[mark..(p-1)].pack("c*") end
|
|
513
|
+
when 3 then
|
|
514
|
+
# line 35 "lib/irc_parser/parser.rl"
|
|
515
|
+
begin
|
|
516
|
+
params << data[mark..(p-1)].pack("c*") end
|
|
517
|
+
when 4 then
|
|
518
|
+
# line 32 "lib/irc_parser/parser.rl"
|
|
519
|
+
begin
|
|
520
|
+
mark = p end
|
|
521
|
+
# line 35 "lib/irc_parser/parser.rl"
|
|
522
|
+
begin
|
|
523
|
+
params << data[mark..(p-1)].pack("c*") end
|
|
524
|
+
# line 525 "lib/irc_parser/parser.rb"
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
end
|
|
528
|
+
if _goto_level <= _again
|
|
529
|
+
if cs == 0
|
|
530
|
+
_goto_level = _out
|
|
531
|
+
next
|
|
532
|
+
end
|
|
533
|
+
p += 1
|
|
534
|
+
if p != pe
|
|
535
|
+
_goto_level = _resume
|
|
536
|
+
next
|
|
537
|
+
end
|
|
538
|
+
end
|
|
539
|
+
if _goto_level <= _test_eof
|
|
540
|
+
end
|
|
541
|
+
if _goto_level <= _out
|
|
542
|
+
break
|
|
543
|
+
end
|
|
544
|
+
end
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
# line 80 "lib/irc_parser/parser.rl"
|
|
548
|
+
|
|
549
|
+
if cs >= irc_parser_first_final
|
|
550
|
+
return prefix, command, params
|
|
551
|
+
elsif message !~ /\r\n$/
|
|
552
|
+
raise ParserError, "Message must finish with \\r\\n"
|
|
553
|
+
else
|
|
554
|
+
raise ParserError, message
|
|
555
|
+
end
|
|
556
|
+
end
|
|
557
|
+
end
|