cinch 0.3.5 → 1.0.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 (82) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +192 -0
  3. data/Rakefile +53 -43
  4. data/examples/basic/autovoice.rb +32 -0
  5. data/examples/basic/google.rb +35 -0
  6. data/examples/basic/hello.rb +15 -0
  7. data/examples/basic/join_part.rb +38 -0
  8. data/examples/basic/memo.rb +39 -0
  9. data/examples/basic/msg.rb +16 -0
  10. data/examples/basic/seen.rb +36 -0
  11. data/examples/basic/urban_dict.rb +35 -0
  12. data/examples/basic/url_shorten.rb +35 -0
  13. data/examples/plugins/autovoice.rb +40 -0
  14. data/examples/plugins/custom_prefix.rb +23 -0
  15. data/examples/plugins/google.rb +37 -0
  16. data/examples/plugins/hello.rb +22 -0
  17. data/examples/plugins/join_part.rb +42 -0
  18. data/examples/plugins/memo.rb +50 -0
  19. data/examples/plugins/msg.rb +22 -0
  20. data/examples/plugins/multiple_matches.rb +41 -0
  21. data/examples/plugins/seen.rb +45 -0
  22. data/examples/plugins/urban_dict.rb +30 -0
  23. data/examples/plugins/url_shorten.rb +32 -0
  24. data/lib/cinch.rb +7 -20
  25. data/lib/cinch/ban.rb +41 -0
  26. data/lib/cinch/bot.rb +479 -0
  27. data/lib/cinch/callback.rb +11 -0
  28. data/lib/cinch/channel.rb +419 -0
  29. data/lib/cinch/constants.rb +369 -0
  30. data/lib/cinch/exceptions.rb +25 -0
  31. data/lib/cinch/helpers.rb +21 -0
  32. data/lib/cinch/irc.rb +344 -38
  33. data/lib/cinch/isupport.rb +96 -0
  34. data/lib/cinch/logger/formatted_logger.rb +80 -0
  35. data/lib/cinch/logger/logger.rb +44 -0
  36. data/lib/cinch/logger/null_logger.rb +18 -0
  37. data/lib/cinch/mask.rb +46 -0
  38. data/lib/cinch/message.rb +183 -0
  39. data/lib/cinch/message_queue.rb +62 -0
  40. data/lib/cinch/plugin.rb +205 -0
  41. data/lib/cinch/rubyext/infinity.rb +1 -0
  42. data/lib/cinch/rubyext/module.rb +18 -0
  43. data/lib/cinch/rubyext/queue.rb +19 -0
  44. data/lib/cinch/rubyext/string.rb +24 -0
  45. data/lib/cinch/syncable.rb +55 -0
  46. data/lib/cinch/user.rb +325 -0
  47. data/spec/bot_spec.rb +5 -0
  48. data/spec/channel_spec.rb +5 -0
  49. data/spec/cinch_spec.rb +5 -0
  50. data/spec/irc_spec.rb +5 -0
  51. data/spec/message_spec.rb +5 -0
  52. data/spec/plugin_spec.rb +5 -0
  53. data/spec/{helper.rb → spec_helper.rb} +0 -0
  54. data/spec/user_spec.rb +5 -0
  55. metadata +69 -51
  56. data/README.rdoc +0 -195
  57. data/examples/autovoice.rb +0 -32
  58. data/examples/custom_patterns.rb +0 -19
  59. data/examples/custom_prefix.rb +0 -25
  60. data/examples/google.rb +0 -31
  61. data/examples/hello.rb +0 -13
  62. data/examples/join_part.rb +0 -26
  63. data/examples/memo.rb +0 -40
  64. data/examples/msg.rb +0 -14
  65. data/examples/named-param-types.rb +0 -19
  66. data/examples/seen.rb +0 -41
  67. data/examples/urban_dict.rb +0 -31
  68. data/examples/url_shorten.rb +0 -34
  69. data/lib/cinch/base.rb +0 -368
  70. data/lib/cinch/irc/message.rb +0 -135
  71. data/lib/cinch/irc/parser.rb +0 -141
  72. data/lib/cinch/irc/socket.rb +0 -329
  73. data/lib/cinch/names.rb +0 -54
  74. data/lib/cinch/rules.rb +0 -171
  75. data/spec/base_spec.rb +0 -94
  76. data/spec/irc/helper.rb +0 -8
  77. data/spec/irc/message_spec.rb +0 -61
  78. data/spec/irc/parser_spec.rb +0 -103
  79. data/spec/irc/socket_spec.rb +0 -90
  80. data/spec/names_spec.rb +0 -393
  81. data/spec/options_spec.rb +0 -45
  82. data/spec/rules_spec.rb +0 -109
@@ -0,0 +1,11 @@
1
+ module Cinch
2
+ # @api private
3
+ class Callback
4
+ include Helpers
5
+
6
+ attr_reader :bot
7
+ def initialize(bot)
8
+ @bot = bot
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,419 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "set"
3
+
4
+ module Cinch
5
+ class Channel
6
+ include Syncable
7
+ @channels = {}
8
+
9
+ class << self
10
+ # Finds or creates a channel.
11
+ #
12
+ # @param [String] name name of a channel
13
+ # @param [Bot] bot a bot
14
+ # @return [Channel]
15
+ # @see Bot#Channel
16
+ def find_ensured(name, bot)
17
+ downcased_name = name.irc_downcase(bot.irc.isupport["CASEMAPPING"])
18
+ @channels[downcased_name] ||= new(name, bot)
19
+ @channels[downcased_name]
20
+ end
21
+
22
+ # Finds a channel.
23
+ #
24
+ # @param [String] name name of a channel
25
+ # @return [Channel, nil]
26
+ def find(name)
27
+ @channels[name]
28
+ end
29
+
30
+ # @return [Array<Channel>] Returns all channels
31
+ def all
32
+ @channels.values
33
+ end
34
+ end
35
+
36
+ # @return [Bot]
37
+ attr_reader :bot
38
+
39
+ # @return [String]
40
+ attr_reader :name
41
+
42
+ # @return [Array<User>]
43
+ attr_reader :users
44
+ synced_attr_reader :users
45
+
46
+ # @return [String]
47
+ attr_accessor :topic
48
+ synced_attr_reader :topic
49
+
50
+ # @return [Array<Ban>]
51
+ attr_reader :bans
52
+ synced_attr_reader :bans
53
+
54
+ # @return [Array<String>]
55
+ attr_reader :modes
56
+ synced_attr_reader :modes
57
+ def initialize(name, bot)
58
+ @bot = bot
59
+ @name = name
60
+ @users = {}
61
+ @bans = []
62
+
63
+ @modes = {}
64
+ # TODO raise if not a channel
65
+
66
+ @topic = nil
67
+
68
+ @in_channel = false
69
+
70
+ @synced_attributes = Set.new
71
+ @when_requesting_synced_attribute = lambda {|attr|
72
+ unless @in_channel
73
+ unsync(attr)
74
+ case attr
75
+ when :users
76
+ @bot.raw "NAMES #@name"
77
+ when :topic
78
+ @bot.raw "TOPIC #@name"
79
+ when :bans
80
+ @bot.raw "MODE #@name +b"
81
+ when :modes
82
+ @bot.raw "MODE #@name"
83
+ end
84
+ end
85
+ }
86
+ end
87
+
88
+ attr_accessor :limit
89
+ # @return [Number]
90
+ def limit
91
+ @modes["l"].to_i
92
+ end
93
+
94
+ def limit=(val)
95
+ if val == -1 or val.nil?
96
+ mode "-l"
97
+ else
98
+ mode "+l #{val}"
99
+ end
100
+ end
101
+
102
+ # @return [Boolean] true if the channel is secret (+s)
103
+ attr_accessor :secret
104
+ undef_method "secret"
105
+ undef_method "secret="
106
+ def secret
107
+ @modes["s"]
108
+ end
109
+ alias_method :secret?, :secret
110
+
111
+ def secret=(bool)
112
+ if bool
113
+ mode "+s"
114
+ else
115
+ mode "-s"
116
+ end
117
+ end
118
+
119
+ # @return [Boolean] true if the channel is moderated (only users
120
+ # with +o and +v are able to send messages)
121
+ attr_accessor :moderated
122
+ undef_method "moderated"
123
+ undef_method "moderated="
124
+ def moderated
125
+ @modes["m"]
126
+ end
127
+ alias_method :moderated?, :moderated
128
+
129
+ def moderated=(val)
130
+ if bool
131
+ mode "+m"
132
+ else
133
+ mode "-m"
134
+ end
135
+ end
136
+
137
+ # @return [Boolean] true if the channel is invite only (+i)
138
+ attr_accessor :invite_only
139
+ undef_method "invite_only"
140
+ undef_method "invite_only="
141
+ def invite_only
142
+ @modes["i"]
143
+ end
144
+ alias_method :invite_only?, :invite_only
145
+
146
+ def invite_only=(bool)
147
+ if bool
148
+ mode "+i"
149
+ else
150
+ mode "-i"
151
+ end
152
+ end
153
+
154
+ # @return [String, nil]
155
+ attr_accessor :key
156
+ undef_method "key"
157
+ undef_method "key="
158
+ def key
159
+ @modes["k"]
160
+ end
161
+
162
+ def key=(new_key)
163
+ if new_key.nil?
164
+ mode "-k #{key}"
165
+ else
166
+ mode "+k #{new_key}"
167
+ end
168
+ end
169
+
170
+ # Sets or unsets modes. Most of the time you won't need this but
171
+ # use setter methods like {Channel#invite_only=}.
172
+ #
173
+ # @param [String] s a mode string
174
+ # @return [void]
175
+ # @example
176
+ # channel.mode "+n"
177
+ def mode(s)
178
+ @bot.raw "MODE #@name #{s}"
179
+ end
180
+
181
+ # @api private
182
+ # @return [void]
183
+ def sync_modes(all = true)
184
+ unsync :users
185
+ unsync :bans
186
+ unsync :modes
187
+ @bot.raw "NAMES #@name" if all
188
+ @bot.raw "MODE #@name +b" # bans
189
+ @bot.raw "MODE #@name"
190
+ end
191
+
192
+ # @return [Boolean] true if `user` is opped in the channel
193
+ def opped?(user)
194
+ user = User.find_ensured(user, @bot) unless user.is_a?(User)
195
+ @users[user] == "@"
196
+ end
197
+
198
+ # @return [Boolean] true if `user` is voiced in the channel
199
+ def voiced?(user)
200
+ user = User.find_ensured(user, @bot) unless user.is_a?(User)
201
+ @users[user] == "+"
202
+ end
203
+
204
+ # Bans someone from the channel.
205
+ #
206
+ # @param [Ban, Mask, User, String] target the mask to ban
207
+ # @return [Mask] the mask used for banning
208
+ def ban(target)
209
+ mask = Mask.from(target)
210
+
211
+ @bot.raw "MODE #@name +b #{mask}"
212
+ mask
213
+ end
214
+
215
+ # Unbans someone from the channel.
216
+ #
217
+ # @param [Ban, Mask, User, String] target the mask to unban
218
+ # @return [Mask] the mask used for unbanning
219
+ def unban(target)
220
+ mask = Mask.from(target)
221
+
222
+ @bot.raw "MODE #@name -b #{mask}"
223
+ mask
224
+ end
225
+
226
+ # @param [String, User] user the user to op
227
+ # @return [void]
228
+ def op(user)
229
+ @bot.raw "MODE #@name +o #{user}"
230
+ end
231
+
232
+ # @param [String, User] user the user to deop
233
+ # @return [void]
234
+ def deop(user)
235
+ @bot.raw "MODE #@name -o #{user}"
236
+ end
237
+
238
+ # @param [String, User] user the user to voice
239
+ # @return [void]
240
+ def voice(user)
241
+ @bot.raw "MODE #@name +v #{user}"
242
+ end
243
+
244
+ # @param [String, User] user the user to devoice
245
+ # @return [void]
246
+ def devoice(user)
247
+ @bot.raw "MODE #@name -v #{user}"
248
+ end
249
+
250
+ # @api private
251
+ # @return [void]
252
+ def add_user(user, mode = nil)
253
+ @in_channel = true if user == @bot
254
+ @users[user] = mode # TODO can a user have more than one mode?
255
+ end
256
+
257
+ # @api private
258
+ # @return [void]
259
+ def remove_user(user)
260
+ @in_channel = false if user == @bot
261
+ @users.delete(user)
262
+ end
263
+
264
+ # Removes all users
265
+ #
266
+ # @api private
267
+ # @return [void]
268
+ def clear_users
269
+ @users.clear
270
+ end
271
+
272
+ # Send a message to the channel.
273
+ #
274
+ # @param [String] message the message
275
+ # @return [void]
276
+ # @see #safe_send
277
+ def send(message)
278
+ @bot.msg(@name, message)
279
+ end
280
+ alias_method :privmsg, :send
281
+ alias_method :msg, :send
282
+
283
+ # Send a message to the channel, but remove any non-printable
284
+ # characters. The purpose of this method is to send text from
285
+ # untrusted sources, like other users or feeds.
286
+ #
287
+ # Note: this will **break** any mIRC color codes embedded in the
288
+ # string.
289
+ #
290
+ # @param (see #send)
291
+ # @return (see #send)
292
+ # @see #send
293
+ # @todo Handle mIRC color codes more gracefully.
294
+ def safe_send(message)
295
+ @bot.safe_msg(@name, message)
296
+ end
297
+ alias_method :safe_privmsg, :safe_send
298
+ alias_method :safe_msg, :safe_send
299
+
300
+
301
+
302
+ # Send a CTCP to the channel.
303
+ #
304
+ # @param [String] message the ctcp message
305
+ # @return [void]
306
+ def ctcp(message)
307
+ send "\001#{message}\001"
308
+ end
309
+
310
+ # Invoke an action (/me) in the channel.
311
+ #
312
+ # @param [String] message the message
313
+ # @return [void]
314
+ # @see #safe_action
315
+ def action(message)
316
+ @bot.action(@name, message)
317
+ end
318
+
319
+ # Invoke an action (/me) in the channel but remove any
320
+ # non-printable characters. The purpose of this method is to send
321
+ # text from untrusted sources, like other users or feeds.
322
+ #
323
+ # Note: this will **break** any mIRC color codes embedded in the
324
+ # string.
325
+ #
326
+ # @param (see #action)
327
+ # @return (see #action)
328
+ # @see #action
329
+ # @todo Handle mIRC color codes more gracefully.
330
+ def safe_action(message)
331
+ @bot.safe_action(@name, message)
332
+ end
333
+
334
+
335
+ # Invites a user to the channel.
336
+ #
337
+ # @param [String, User] user the user to invite
338
+ # @return [void]
339
+ def invite(user)
340
+ @bot.raw("INVITE #{user} #@name")
341
+ end
342
+
343
+ # Sets the topic.
344
+ #
345
+ # @param [String] new_topic the new topic
346
+ # @raise [Exceptions::TopicTooLong]
347
+ def topic=(new_topic)
348
+ if new_topic.size > @bot.irc.isupport["TOPICLEN"] && @bot.strict?
349
+ raise Exceptions::TopicTooLong, new_topic
350
+ end
351
+
352
+ @bot.raw "TOPIC #@name :#{new_topic}"
353
+ end
354
+
355
+ # Kicks a user from the channel.
356
+ #
357
+ # @param [String, User] user the user to kick
358
+ # @param [String] a reason for the kick
359
+ # @raise [Exceptions::KickReasonTooLong]
360
+ # @return [void]
361
+ def kick(user, reason = nil)
362
+ if reason.to_s.size > @bot.irc.isupport["KICKLEN"] && @bot.strict?
363
+ raise Exceptions::KickReasonTooLong, reason
364
+ end
365
+
366
+ @bot.raw("KICK #@name #{user} :#{reason}")
367
+ end
368
+
369
+ # Invites a user to the channel.
370
+ #
371
+ # @param [String, User] user the user to invite
372
+ # @return [void]
373
+ def invite(user)
374
+ @bot.raw "INVITE #{user} #@name"
375
+ end
376
+
377
+ # Causes the bot to part from the channel.
378
+ #
379
+ # @param [String] message the part message.
380
+ # @return [void]
381
+ def part(message = nil)
382
+ @bot.raw "PART #@name :#{message}"
383
+ end
384
+
385
+ # Joins the channel
386
+ #
387
+ # @param [String] key the channel key, if any. If none is
388
+ # specified but @key is set, @key will be used
389
+ # @return [void]
390
+ def join(key = nil)
391
+ if key.nil? and self.key != true
392
+ key = self.key
393
+ end
394
+ @bot.raw "JOIN #{[@name, key].compact.join(" ")}"
395
+ end
396
+
397
+ # @return [Boolean]
398
+ def ==(other)
399
+ @name == other.to_s
400
+ end
401
+ alias_method :eql?, "=="
402
+
403
+ # @return [Fixnum]
404
+ def hash
405
+ @name.hash
406
+ end
407
+
408
+ # @return [String]
409
+ def to_s
410
+ @name
411
+ end
412
+ alias_method :to_str, :to_s
413
+
414
+ # @return [String]
415
+ def inspect
416
+ "#<Channel name=#{@name.inspect}>"
417
+ end
418
+ end
419
+ end
@@ -0,0 +1,369 @@
1
+ module Cinch
2
+ # Used to indicate the nickname parameter supplied to a command is
3
+ # currently unused.
4
+ ERR_NOSUCHNICK = 401
5
+
6
+ # Used to indicate the server name given currently doesn't exist.
7
+ ERR_NOSUCHSERVER = 402
8
+
9
+ # Used to indicate the given channel name is invalid.
10
+ ERR_NOSUCHCHANNEL = 403
11
+
12
+ # Sent to a user who is either
13
+ # - not on a channel which is mode +n
14
+ # - not a chanop (or mode +v) on a channel which has mode +m set
15
+ # and is trying to send a PRIVMSG message to that channel.
16
+ ERR_CANNOTSENDTOCHAN = 404
17
+
18
+ # Sent to a user when they have joined the maximum number of allowed
19
+ # channels and they try to join another channel.
20
+ ERR_TOOMANYCHANNELS = 405
21
+
22
+ # Returned by WHOWAS to indicate there is no history information for
23
+ # that nickname.
24
+ ERR_WASNOSUCHNICK = 406
25
+
26
+ # Returned to a client which is attempting to send PRIVMSG/NOTICE
27
+ # using the user@host destination format and for a user@host which has
28
+ # several occurrences.
29
+ ERR_TOOMANYTARGETS = 407
30
+
31
+ # PING or PONG message missing the originator parameter which is
32
+ # required since these commands must work without valid prefixes.
33
+ ERR_NOORIGIN = 409
34
+ ERR_NORECIPIENT = 411
35
+ ERR_NOTEXTTOSEND = 412
36
+ ERR_NOTOPLEVEL = 413
37
+
38
+ # 412 - 414 are returned by PRIVMSG to indicate that the message
39
+ # wasn't delivered for some reason. ERR_NOTOPLEVEL and
40
+ # ERR_WILDTOPLEVEL are errors that are returned when an invalid use of
41
+ # "PRIVMSG $<server>" or "PRIVMSG #<host>" is attempted.
42
+ ERR_WILDTOPLEVEL = 414
43
+
44
+ # Returned to a registered client to indicate that the command sent is
45
+ # unknown by the server.
46
+ ERR_UNKNOWNCOMMAND = 421
47
+
48
+ # Server's MOTD file could not be opened by the server.
49
+ ERR_NOMOTD = 422
50
+
51
+ # Returned by a server in response to an ADMIN message when there is
52
+ # an error in finding the appropriate information.
53
+ ERR_NOADMININFO = 423
54
+
55
+ # Generic error message used to report a failed file operation during
56
+ # the processing of a message.
57
+ ERR_FILEERROR = 424
58
+
59
+ # Returned when a nickname parameter expected for a command and isn't
60
+ # found.
61
+ ERR_NONICKNAMEGIVEN = 431
62
+
63
+ # Returned after receiving a NICK message which contains characters
64
+ # which do not fall in the defined set.
65
+ ERR_ERRONEUSNICKNAME = 432
66
+
67
+ # Returned when a NICK message is processed that results in an attempt
68
+ # to change to a currently existing nickname.
69
+ ERR_NICKNAMEINUSE = 433
70
+
71
+ # Returned by a server to a client when it detects a nickname
72
+ # collision (registered of a NICK that already exists by another
73
+ # server).
74
+ ERR_NICKCOLLISION = 436
75
+
76
+ # Returned by the server to indicate that the target user of the
77
+ # command is not on the given channel.
78
+ ERR_USERNOTINCHANNEL = 441
79
+
80
+ # Returned by the server whenever a client tries to perform a channel
81
+ # effecting command for which the client isn't a member.
82
+ ERR_NOTONCHANNEL = 442
83
+
84
+ # Returned when a client tries to invite a user to a channel they are
85
+ # already on.
86
+ ERR_USERONCHANNEL = 443
87
+
88
+ # Returned by the summon after a SUMMON command for a user was unable
89
+ # to be performed since they were not logged in.
90
+ ERR_NOLOGIN = 444
91
+
92
+ # Returned as a response to the SUMMON command. Must be returned by
93
+ # any server which does not implement it.
94
+ ERR_SUMMONDISABLED = 445
95
+
96
+ # Returned as a response to the USERS command. Must be returned by any
97
+ # server which does not implement it.
98
+ ERR_USERSDISABLED = 446
99
+
100
+ # Returned by the server to indicate that the client must be
101
+ # registered before the server will allow it to be parsed in detail.
102
+ ERR_NOTREGISTERED = 451
103
+
104
+ # Returned by the server by numerous commands to indicate to the
105
+ # client that it didn't supply enough parameters.
106
+ ERR_NEEDMOREPARAMS = 461
107
+
108
+ # Returned by the server to any link which tries to change part of the
109
+ # registered details (such as password or user details from second
110
+ # USER message).
111
+ ERR_ALREADYREGISTRED = 462
112
+
113
+ # Returned to a client which attempts to register with a server which
114
+ # does not been setup to allow connections from the host the attempted
115
+ # connection is tried.
116
+ ERR_NOPERMFORHOST = 463
117
+
118
+ # Returned to indicate a failed attempt at registering a connection
119
+ # for which a password was required and was either not given or
120
+ # incorrect.
121
+ ERR_PASSWDMISMATCH = 464
122
+
123
+ # Returned after an attempt to connect and register yourself with a
124
+ # server which has been setup to explicitly deny connections to you.
125
+ ERR_YOUREBANNEDCREEP = 465
126
+ ERR_KEYSET = 467
127
+ ERR_CHANNELISFULL = 471
128
+ ERR_UNKNOWNMODE = 472
129
+ ERR_INVITEONLYCHAN = 473
130
+ ERR_BANNEDFROMCHAN = 474
131
+ ERR_BADCHANNELKEY = 475
132
+
133
+ # Any command requiring operator privileges to operate must return
134
+ # this error to indicate the attempt was unsuccessful.
135
+ ERR_NOPRIVILEGES = 481
136
+
137
+ # Any command requiring 'chanop' privileges (such as MODE messages)
138
+ # must return this error if the client making the attempt is not a
139
+ # chanop on the specified channel.
140
+ ERR_CHANOPRIVSNEEDED = 482
141
+
142
+ # Any attempts to use the KILL command on a server are to be refused
143
+ # and this error returned directly to the client.
144
+ ERR_CANTKILLSERVER = 483
145
+
146
+ # If a client sends an OPER message and the server has not been
147
+ # configured to allow connections from the client's host as an
148
+ # operator, this error must be returned.
149
+ ERR_NOOPERHOST = 491
150
+
151
+ # Returned by the server to indicate that a MODE message was sent with
152
+ # a nickname parameter and that the a mode flag sent was not
153
+ # recognized.
154
+ ERR_UMODEUNKNOWNFLAG = 501
155
+
156
+ # Error sent to any user trying to view or change the user mode for a
157
+ # user other than themselves.
158
+ ERR_USERSDONTMATCH = 502
159
+ RPL_NONE = 300
160
+
161
+ # Reply format used by USERHOST to list replies to the query list.
162
+ RPL_USERHOST = 302
163
+
164
+ # Reply format used by ISON to list replies to the query list.
165
+ RPL_ISON = 303
166
+
167
+ # RPL_AWAY is sent to any client sending a PRIVMSG to a client which
168
+ # is away. RPL_AWAY is only sent by the server to which the client is
169
+ # connected.
170
+ RPL_AWAY = 301
171
+
172
+ # Replies RPL_UNAWAY and RPL_NOWAWAY are sent when the client removes
173
+ # and sets an AWAY message
174
+ RPL_UNAWAY = 305
175
+
176
+ # Replies RPL_UNAWAY and RPL_NOWAWAY are sent when the client removes
177
+ # and sets an AWAY message
178
+ RPL_NOWAWAY = 306
179
+ RPL_WHOISUSER = 311
180
+ RPL_WHOISSERVER = 312
181
+ RPL_WHOISOPERATOR = 313
182
+ RPL_WHOISIDLE = 317
183
+ RPL_ENDOFWHOIS = 318
184
+
185
+ # Replies 311 - 313, 317 - 319 are all replies generated in response
186
+ # to a WHOIS message. Given that there are enough parameters present,
187
+ # the answering server must either formulate a reply out of the above
188
+ # numerics (if the query nick is found) or return an error reply. The
189
+ # '*' in RPL_WHOISUSER is there as the literal character and not as a
190
+ # wild card. For each reply set, only RPL_WHOISCHANNELS may appear
191
+ # more than once (for long lists of channel names). The '@' and '+'
192
+ # characters next to the channel name indicate whether a client is a
193
+ # channel operator or has been granted permission to speak on a
194
+ # moderated channel. The RPL_ENDOFWHOIS reply is used to mark the end
195
+ # of processing a WHOIS message.
196
+ RPL_WHOISCHANNELS = 319
197
+ RPL_WHOWASUSER = 314
198
+
199
+ # When replying to a WHOWAS message, a server must use the replies
200
+ # RPL_WHOWASUSER, RPL_WHOISSERVER or ERR_WASNOSUCHNICK for each
201
+ # nickname in the presented list. At the end of all reply batches,
202
+ # there must be RPL_ENDOFWHOWAS (even if there was only one reply and
203
+ # it was an error).
204
+ RPL_ENDOFWHOWAS = 369
205
+ RPL_LISTSTART = 321
206
+ RPL_LIST = 322
207
+
208
+ # Replies RPL_LISTSTART, RPL_LIST, RPL_LISTEND mark the start, actual
209
+ # replies with data and end of the server's response to a LIST
210
+ # command. If there are no channels available to return, only the
211
+ # start and end reply must be sent.
212
+ RPL_LISTEND = 323
213
+ RPL_CHANNELMODEIS = 324
214
+ RPL_NOTOPIC = 331
215
+
216
+ # When sending a TOPIC message to determine the channel topic, one of
217
+ # two replies is sent. If the topic is set, RPL_TOPIC is sent back
218
+ # else RPL_NOTOPIC.
219
+ RPL_TOPIC = 332
220
+
221
+ # Returned by the server to indicate that the attempted INVITE message
222
+ # was successful and is being passed onto the end client.
223
+ RPL_INVITING = 341
224
+
225
+ # Returned by a server answering a SUMMON message to indicate that it
226
+ # is summoning that user.
227
+ RPL_SUMMONING = 342
228
+
229
+ # Reply by the server showing its version details. The &lt;version&gt;
230
+ # is the version of the software being used (including any patchlevel
231
+ # revisions) and the &lt;debuglevel&gt; is used to indicate if the
232
+ # server is running in "debug mode".<BR> The "comments" field may
233
+ # contain any comments about the version or further version details.
234
+ RPL_VERSION = 351
235
+ RPL_WHOREPLY = 352
236
+
237
+ # The RPL_WHOREPLY and RPL_ENDOFWHO pair are used to answer a WHO
238
+ # message. The RPL_WHOREPLY is only sent if there is an appropriate
239
+ # match to the WHO query. If there is a list of parameters supplied
240
+ # with a WHO message, a RPL_ENDOFWHO must be sent after processing
241
+ # each list item with <name> being the item.
242
+ RPL_ENDOFWHO = 315
243
+ RPL_NAMREPLY = 353
244
+ RPL_NAMEREPLY = RPL_NAMREPLY
245
+
246
+ # To reply to a NAMES message, a reply pair consisting of RPL_NAMREPLY
247
+ # and RPL_ENDOFNAMES is sent by the server back to the client. If
248
+ # there is no channel found as in the query, then only RPL_ENDOFNAMES
249
+ # is returned. The exception to this is when a NAMES message is sent
250
+ # with no parameters and all visible channels and contents are sent
251
+ # back in a series of RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to
252
+ # mark the end.
253
+ RPL_ENDOFNAMES = 366
254
+ RPL_LINKS = 364
255
+
256
+ # In replying to the LINKS message, a server must send replies back
257
+ # using the RPL_LINKS numeric and mark the end of the list using an
258
+ # RPL_ENDOFLINKS reply.
259
+ RPL_ENDOFLINKS = 365
260
+ RPL_BANLIST = 367
261
+
262
+ # When listing the active 'bans' for a given channel, a server is
263
+ # required to send the list back using the RPL_BANLIST and
264
+ # RPL_ENDOFBANLIST messages. A separate RPL_BANLIST is sent for each
265
+ # active banid. After the banids have been listed (or if none present)
266
+ # a RPL_ENDOFBANLIST must be sent.
267
+ RPL_ENDOFBANLIST = 368
268
+ RPL_INFO = 371
269
+
270
+ # A server responding to an INFO message is required to send all its
271
+ # 'info' in a series of RPL_INFO messages with a RPL_ENDOFINFO reply
272
+ # to indicate the end of the replies.
273
+ RPL_ENDOFINFO = 374
274
+ RPL_MOTDSTART = 375
275
+ RPL_MOTD = 372
276
+
277
+ # When responding to the MOTD message and the MOTD file is found, the
278
+ # file is displayed line by line, with each line no longer than 80
279
+ # characters, using RPL_MOTD format replies. These should be
280
+ # surrounded by a RPL_MOTDSTART (before the RPL_MOTDs) and an
281
+ # RPL_ENDOFMOTD (after).
282
+ RPL_ENDOFMOTD = 376
283
+
284
+ # RPL_YOUREOPER is sent back to a client which has just successfully
285
+ # issued an OPER message and gained operator status.
286
+ RPL_YOUREOPER = 381
287
+
288
+ # If the REHASH option is used and an operator sends a REHASH message,
289
+ # an RPL_REHASHING is sent back to the operator.
290
+ RPL_REHASHING = 382
291
+
292
+ # When replying to the TIME message, a server must send the reply
293
+ # using the RPL_TIME format above. The string showing the time need
294
+ # only contain the correct day and time there. There is no further
295
+ # requirement for the time string.
296
+ RPL_TIME = 391
297
+ RPL_USERSSTART = 392
298
+ RPL_USERS = 393
299
+ RPL_ENDOFUSERS = 394
300
+
301
+ # If the USERS message is handled by a server, the replies
302
+ # RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and RPL_NOUSERS are used.
303
+ # RPL_USERSSTART must be sent first, following by either a sequence of
304
+ # RPL_USERS or a single RPL_NOUSER. Following this is RPL_ENDOFUSERS.
305
+ RPL_NOUSERS = 395
306
+ RPL_TRACELINK = 200
307
+ RPL_TRACECONNECTING = 201
308
+ RPL_TRACEHANDSHAKE = 202
309
+ RPL_TRACEUNKNOWN = 203
310
+ RPL_TRACEOPERATOR = 204
311
+ RPL_TRACEUSER = 205
312
+ RPL_TRACESERVER = 206
313
+ RPL_TRACENEWTYPE = 208
314
+
315
+ # The RPL_TRACE* are all returned by the server in response to the
316
+ # TRACE message. How many are returned is dependent on the the TRACE
317
+ # message and whether it was sent by an operator or not. There is no
318
+ # predefined order for which occurs first. Replies RPL_TRACEUNKNOWN,
319
+ # RPL_TRACECONNECTING and RPL_TRACEHANDSHAKE are all used for
320
+ # connections which have not been fully established and are either
321
+ # unknown, still attempting to connect or in the process of completing
322
+ # the 'server handshake'. RPL_TRACELINK is sent by any server which
323
+ # handles a TRACE message and has to pass it on to another server. The
324
+ # list of RPL_TRACELINKs sent in response to a TRACE command
325
+ # traversing the IRC network should reflect the actual connectivity of
326
+ # the servers themselves along that path. RPL_TRACENEWTYPE is to be
327
+ # used for any connection which does not fit in the other categories
328
+ # but is being displayed anyway.
329
+ RPL_TRACELOG = 261
330
+ RPL_STATSLINKINFO = 211
331
+ RPL_STATSCOMMANDS = 212
332
+ RPL_STATSCLINE = 213
333
+ RPL_STATSNLINE = 214
334
+ RPL_STATSILINE = 215
335
+ RPL_STATSKLINE = 216
336
+ RPL_STATSYLINE = 218
337
+ RPL_ENDOFSTATS = 219
338
+ RPL_STATSLLINE = 241
339
+ RPL_STATSUPTIME = 242
340
+ RPL_STATSOLINE = 243
341
+ RPL_STATSHLINE = 244
342
+
343
+ # To answer a query about a client's own mode, RPL_UMODEIS is sent
344
+ # back.
345
+ RPL_UMODEIS = 221
346
+ RPL_LUSERCLIENT = 251
347
+ RPL_LUSEROP = 252
348
+ RPL_LUSERUNKNOWN = 253
349
+ RPL_LUSERCHANNELS = 254
350
+
351
+ # In processing an LUSERS message, the server sends a set of replies
352
+ # from RPL_LUSERCLIENT, RPL_LUSEROP, RPL_USERUNKNOWN,
353
+ # RPL_LUSERCHANNELS and RPL_LUSERME. When replying, a server must send
354
+ # back RPL_LUSERCLIENT and RPL_LUSERME. The other replies are only
355
+ # sent back if a non-zero count is found for them.
356
+ RPL_LUSERME = 255
357
+ RPL_ADMINME = 256
358
+ RPL_ADMINLOC1 = 257
359
+ RPL_ADMINLOC2 = 258
360
+
361
+ # When replying to an ADMIN message, a server is expected to use
362
+ # replies RLP_ADMINME through to RPL_ADMINEMAIL and provide a text
363
+ # message with each. For RPL_ADMINLOC1 a description of what city,
364
+ # state and country the server is in is expected, followed by details
365
+ # of the university and department (RPL_ADMINLOC2) and finally the
366
+ # administrative contact for the server (an email address here is
367
+ # required) in RPL_ADMINEMAIL.
368
+ RPL_ADMINEMAIL = 259
369
+ end