cinch 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require 'cinch/bot'
2
2
 
3
3
  module Cinch
4
- VERSION = '1.1.1'
4
+ VERSION = '1.1.2'
5
5
 
6
6
  # @return [String]
7
7
  # @todo Handle mIRC color codes more gracefully.
@@ -0,0 +1,371 @@
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 <version>
230
+ # is the version of the software being used (including any patchlevel
231
+ # revisions) and the <debuglevel> is used to indicate if the
232
+ # server is running in "debug mode".
233
+ #
234
+ #The "comments" field may contain any comments about the version or
235
+ # further version details.
236
+ RPL_VERSION = 351
237
+ RPL_WHOREPLY = 352
238
+
239
+ # The RPL_WHOREPLY and RPL_ENDOFWHO pair are used to answer a WHO
240
+ # message. The RPL_WHOREPLY is only sent if there is an appropriate
241
+ # match to the WHO query. If there is a list of parameters supplied
242
+ # with a WHO message, a RPL_ENDOFWHO must be sent after processing
243
+ # each list item with <name> being the item.
244
+ RPL_ENDOFWHO = 315
245
+ RPL_NAMREPLY = 353
246
+ RPL_NAMEREPLY = RPL_NAMREPLY
247
+
248
+ # To reply to a NAMES message, a reply pair consisting of RPL_NAMREPLY
249
+ # and RPL_ENDOFNAMES is sent by the server back to the client. If
250
+ # there is no channel found as in the query, then only RPL_ENDOFNAMES
251
+ # is returned. The exception to this is when a NAMES message is sent
252
+ # with no parameters and all visible channels and contents are sent
253
+ # back in a series of RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to
254
+ # mark the end.
255
+ RPL_ENDOFNAMES = 366
256
+ RPL_LINKS = 364
257
+
258
+ # In replying to the LINKS message, a server must send replies back
259
+ # using the RPL_LINKS numeric and mark the end of the list using an
260
+ # RPL_ENDOFLINKS reply.
261
+ RPL_ENDOFLINKS = 365
262
+ RPL_BANLIST = 367
263
+
264
+ # When listing the active 'bans' for a given channel, a server is
265
+ # required to send the list back using the RPL_BANLIST and
266
+ # RPL_ENDOFBANLIST messages. A separate RPL_BANLIST is sent for each
267
+ # active banid. After the banids have been listed (or if none present)
268
+ # a RPL_ENDOFBANLIST must be sent.
269
+ RPL_ENDOFBANLIST = 368
270
+ RPL_INFO = 371
271
+
272
+ # A server responding to an INFO message is required to send all its
273
+ # 'info' in a series of RPL_INFO messages with a RPL_ENDOFINFO reply
274
+ # to indicate the end of the replies.
275
+ RPL_ENDOFINFO = 374
276
+ RPL_MOTDSTART = 375
277
+ RPL_MOTD = 372
278
+
279
+ # When responding to the MOTD message and the MOTD file is found, the
280
+ # file is displayed line by line, with each line no longer than 80
281
+ # characters, using RPL_MOTD format replies. These should be
282
+ # surrounded by a RPL_MOTDSTART (before the RPL_MOTDs) and an
283
+ # RPL_ENDOFMOTD (after).
284
+ RPL_ENDOFMOTD = 376
285
+
286
+ # RPL_YOUREOPER is sent back to a client which has just successfully
287
+ # issued an OPER message and gained operator status.
288
+ RPL_YOUREOPER = 381
289
+
290
+ # If the REHASH option is used and an operator sends a REHASH message,
291
+ # an RPL_REHASHING is sent back to the operator.
292
+ RPL_REHASHING = 382
293
+
294
+ # When replying to the TIME message, a server must send the reply
295
+ # using the RPL_TIME format above. The string showing the time need
296
+ # only contain the correct day and time there. There is no further
297
+ # requirement for the time string.
298
+ RPL_TIME = 391
299
+ RPL_USERSSTART = 392
300
+ RPL_USERS = 393
301
+ RPL_ENDOFUSERS = 394
302
+
303
+ # If the USERS message is handled by a server, the replies
304
+ # RPL_USERSTART, RPL_USERS, RPL_ENDOFUSERS and RPL_NOUSERS are used.
305
+ # RPL_USERSSTART must be sent first, following by either a sequence of
306
+ # RPL_USERS or a single RPL_NOUSER. Following this is RPL_ENDOFUSERS.
307
+ RPL_NOUSERS = 395
308
+ RPL_TRACELINK = 200
309
+ RPL_TRACECONNECTING = 201
310
+ RPL_TRACEHANDSHAKE = 202
311
+ RPL_TRACEUNKNOWN = 203
312
+ RPL_TRACEOPERATOR = 204
313
+ RPL_TRACEUSER = 205
314
+ RPL_TRACESERVER = 206
315
+ RPL_TRACENEWTYPE = 208
316
+
317
+ # The RPL_TRACE* are all returned by the server in response to the
318
+ # TRACE message. How many are returned is dependent on the the TRACE
319
+ # message and whether it was sent by an operator or not. There is no
320
+ # predefined order for which occurs first. Replies RPL_TRACEUNKNOWN,
321
+ # RPL_TRACECONNECTING and RPL_TRACEHANDSHAKE are all used for
322
+ # connections which have not been fully established and are either
323
+ # unknown, still attempting to connect or in the process of completing
324
+ # the 'server handshake'. RPL_TRACELINK is sent by any server which
325
+ # handles a TRACE message and has to pass it on to another server. The
326
+ # list of RPL_TRACELINKs sent in response to a TRACE command
327
+ # traversing the IRC network should reflect the actual connectivity of
328
+ # the servers themselves along that path. RPL_TRACENEWTYPE is to be
329
+ # used for any connection which does not fit in the other categories
330
+ # but is being displayed anyway.
331
+ RPL_TRACELOG = 261
332
+ RPL_STATSLINKINFO = 211
333
+ RPL_STATSCOMMANDS = 212
334
+ RPL_STATSCLINE = 213
335
+ RPL_STATSNLINE = 214
336
+ RPL_STATSILINE = 215
337
+ RPL_STATSKLINE = 216
338
+ RPL_STATSYLINE = 218
339
+ RPL_ENDOFSTATS = 219
340
+ RPL_STATSLLINE = 241
341
+ RPL_STATSUPTIME = 242
342
+ RPL_STATSOLINE = 243
343
+ RPL_STATSHLINE = 244
344
+
345
+ # To answer a query about a client's own mode, RPL_UMODEIS is sent
346
+ # back.
347
+ RPL_UMODEIS = 221
348
+ RPL_LUSERCLIENT = 251
349
+ RPL_LUSEROP = 252
350
+ RPL_LUSERUNKNOWN = 253
351
+ RPL_LUSERCHANNELS = 254
352
+
353
+ # In processing an LUSERS message, the server sends a set of replies
354
+ # from RPL_LUSERCLIENT, RPL_LUSEROP, RPL_USERUNKNOWN,
355
+ # RPL_LUSERCHANNELS and RPL_LUSERME. When replying, a server must send
356
+ # back RPL_LUSERCLIENT and RPL_LUSERME. The other replies are only
357
+ # sent back if a non-zero count is found for them.
358
+ RPL_LUSERME = 255
359
+ RPL_ADMINME = 256
360
+ RPL_ADMINLOC1 = 257
361
+ RPL_ADMINLOC2 = 258
362
+
363
+ # When replying to an ADMIN message, a server is expected to use
364
+ # replies RLP_ADMINME through to RPL_ADMINEMAIL and provide a text
365
+ # message with each. For RPL_ADMINLOC1 a description of what city,
366
+ # state and country the server is in is expected, followed by details
367
+ # of the university and department (RPL_ADMINLOC2) and finally the
368
+ # administrative contact for the server (an email address here is
369
+ # required) in RPL_ADMINEMAIL.
370
+ RPL_ADMINEMAIL = 259
371
+ end
@@ -494,6 +494,7 @@ module Cinch
494
494
  :nick => "cinch",
495
495
  :nicks => nil,
496
496
  :realname => "cinch",
497
+ :user => "cinch",
497
498
  :verbose => true,
498
499
  :messages_per_second => 0.5,
499
500
  :server_queue_size => 10,
@@ -107,7 +107,8 @@ module Cinch
107
107
  # @param [User, String] user An {User}-object or a nickname
108
108
  # @return [Boolean] Check if a user is in the channel
109
109
  def has_user?(user)
110
- @users.has_key?(User(user))
110
+ user = @bot.user_manager.find_ensured(user) unless user.is_a?(User)
111
+ @users.has_key?(user)
111
112
  end
112
113
 
113
114
 
@@ -66,7 +66,7 @@ module Cinch
66
66
  @queue = MessageQueue.new(@socket, @bot)
67
67
  message "PASS #{@bot.config.password}" if @bot.config.password
68
68
  message "NICK #{@bot.generate_next_nick}"
69
- message "USER #{@bot.config.nick} 0 * :#{@bot.config.realname}"
69
+ message "USER #{@bot.config.user} 0 * :#{@bot.config.realname}"
70
70
 
71
71
  reading_thread = Thread.new do
72
72
  begin
@@ -11,7 +11,7 @@ module Cinch
11
11
  def initialize(mask)
12
12
  @mask = mask
13
13
  @nick, @user, @host = mask.match(/(.+)!(.+)@(.+)/)[1..-1]
14
- @regexp = Regexp.new("^" + Regexp.escape(mask).gsub("\\*", ".*") + "$")
14
+ @regexp = Regexp.new("^" + Regexp.escape(mask).gsub("\\*", ".*").gsub("\\?", ".?") + "$")
15
15
  end
16
16
 
17
17
  # @return [Boolean]
@@ -28,10 +28,10 @@ module Cinch
28
28
  @mask.hash
29
29
  end
30
30
 
31
- # @param [User] user
31
+ # @param [Ban, Mask, User, String] target
32
32
  # @return [Boolean]
33
- def match(user)
34
- return user.mask =~ @regexp
33
+ def match(target)
34
+ return self.class.from(target).mask =~ @regexp
35
35
 
36
36
  # TODO support CIDR (freenode)
37
37
  end
@@ -252,7 +252,8 @@ module Cinch
252
252
 
253
253
  if @__cinch_help_message
254
254
  bot.debug "[plugin] #{plugin_name}: Registering help message"
255
- bot.on(:message, "#{prefix}help #{plugin_name}", @__cinch_help_message) do |message, help_message|
255
+ help_pattern = Pattern.new(prefix, "help #{plugin_name}", suffix)
256
+ bot.on(:message, help_pattern, @__cinch_help_message) do |message, help_message|
256
257
  message.reply(help_message)
257
258
  end
258
259
  end
@@ -294,7 +295,7 @@ module Cinch
294
295
  #
295
296
  # @return [Hash] A hash of options
296
297
  def config
297
- @bot.config.plugins.options[self.class]
298
+ @bot.config.plugins.options[self.class] || {}
298
299
  end
299
300
 
300
301
  def self.included(by)
@@ -40,7 +40,7 @@ module Cinch
40
40
  else
41
41
  raise ArgumentError
42
42
  end
43
- downcased_nick = nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"])
43
+ downcased_nick = nick.irc_downcase(bot.irc.isupport["CASEMAPPING"])
44
44
  @users[downcased_nick] = args.last.user_manager.find_ensured(*args[0..-2])
45
45
  # note: the complete case statement and the assignment to
46
46
  # @users is only for keeping compatibility with older
@@ -412,6 +412,14 @@ module Cinch
412
412
  end
413
413
  end
414
414
 
415
+ def respond_to?(m)
416
+ if m.to_s =~ /^(.+)_unsynced$/
417
+ m = $1.to_sym
418
+ end
419
+
420
+ return @data.has_key?(m) || super
421
+ end
422
+
415
423
  # @return [Boolean]
416
424
  def ==(other)
417
425
  return case other
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 1
9
- version: 1.1.1
8
+ - 2
9
+ version: 1.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lee Jarvis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-18 00:00:00 +01:00
18
+ date: 2011-03-02 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -53,6 +53,7 @@ files:
53
53
  - lib/cinch/mode_parser.rb
54
54
  - lib/cinch/helpers.rb
55
55
  - lib/cinch/ban.rb
56
+ - lib/cinch/#constants.rb#
56
57
  - lib/cinch/plugin.rb
57
58
  - lib/cinch/user_manager.rb
58
59
  - lib/cinch/isupport.rb