Module: Irc

Defined in:
lib/rbot/irc.rb,
lib/rbot/irc.rb,
lib/rbot/irc.rb,
lib/rbot/irc.rb,
lib/rbot/irc.rb,
lib/rbot/irc.rb,
lib/rbot/ircbot.rb,
lib/rbot/maskdb.rb,
lib/rbot/botuser.rb,
lib/rbot/botuser.rb,
lib/rbot/message.rb,
lib/rbot/plugins.rb,
lib/rbot/rfc2812.rb,
lib/rbot/language.rb,
lib/rbot/ircsocket.rb,
lib/rbot/pkgconfig.rb,
lib/rbot/rbotconfig.rb,
lib/rbot/core/remote.rb,
lib/rbot/registry/tc.rb,
lib/rbot/registry/tc.rb,
lib/rbot/registry/bdb.rb,
lib/rbot/registry/bdb.rb,
lib/rbot/config-compat.rb,
lib/rbot/core/userdata.rb,
lib/rbot/messagemapper.rb,
lib/rbot/core/utils/utils.rb,
lib/rbot/core/utils/extends.rb,
lib/rbot/core/utils/filters.rb,
lib/rbot/core/utils/httputil.rb,
lib/rbot/core/utils/wordlist.rb,
lib/rbot/core/utils/parse_time.rb,
lib/rbot/config.rb

Overview

-- vim:sw=2:et ++

:title: rbot time parsing utilities

Author

Giuseppe "Oblomov" Bilotta [email protected]

These routines read a string and return the number of seconds they represent.

Defined Under Namespace

Modules: BotConfig, PKGConfig, ServerOrCasemap, Utils Classes: AsciiCasemap, BanlistMessage, BasicUserMessage, Bot, Casemap, Channel, ChannelList, Client, DBHash, DBTree, InviteMessage, JoinMessage, KickMessage, MessageQueue, ModeChangeMessage, MotdMessage, NamesMessage, Netmask, NetmaskDb, NetmaskList, NickMessage, NoSuchTargetMessage, NoticeMessage, PartMessage, PrivMessage, QueueRing, QuitMessage, RfcCasemap, Server, Socket, StrictRfcCasemap, TopicMessage, UnknownMessage, User, UserList, UserMessage, WelcomeMessage, WhoisMessage

Constant Summary collapse

Bold =

Define standard IRC attriubtes (not so standard actually, but the closest thing we have ...)

"\002"
Underline =
"\037"
Reverse =
"\026"
Italic =
"\011"
NormalText =
"\017"
AttributeRx =
/#{Bold}|#{Underline}|#{Reverse}|#{Italic}|#{NormalText}/
Color =

Color is prefixed by \003 and followed by optional foreground and background specifications, two-digits-max numbers separated by a comma. One of the two parts must be present.

"\003"
ColorRx =
/#{Color}\d?\d?(?:,\d\d?)?/
FormattingRx =
/#{AttributeRx}|#{ColorRx}/
ColorCode =

Standard color codes

{
  :black      => 1,
  :blue       => 2,
  :navyblue   => 2,
  :navy_blue  => 2,
  :green      => 3,
  :red        => 4,
  :brown      => 5,
  :purple     => 6,
  :olive      => 7,
  :yellow     => 8,
  :limegreen  => 9,
  :lime_green => 9,
  :teal       => 10,
  :aqualight  => 11,
  :aqua_light => 11,
  :royal_blue => 12,
  :hotpink    => 13,
  :hot_pink   => 13,
  :darkgray   => 14,
  :dark_gray  => 14,
  :lightgray  => 15,
  :light_gray => 15,
  :white      => 16
}
RPL_WELCOME =

"Welcome to the Internet Relay Network !@"

001
RPL_YOURHOST =

"Your host is , running version "

002
RPL_CREATED =

"This server was created "

003
RPL_MYINFO =

" "

004
RPL_ISUPPORT =

"005 nick PREFIX=(ov)@+ CHANTYPES=#& :are supported by this server"

defines the capabilities supported by the server.

Previous RFCs defined message 005 as follows:

  • Sent by the server to a user to suggest an alternative server. This is often used when the connection is refused because the server is already full.

"Try server , port "

RPL_BOUNCE=005

005
RPL_USERHOST =

":*1 *( " " )"

  • Reply format used by USERHOST to list replies to the query list. The reply string is composed as follows:

reply = nickname [ "*" ] "=" ( "+" / "-" ) hostname

The '*' indicates whether the client has registered as an Operator. The '-' or '+' characters represent whether the client has set an AWAY message or not respectively.

302
RPL_ISON =

":*1 *( " " )"

  • Reply format used by ISON to list replies to the query list.
303
RPL_AWAY =

" :"

301
RPL_UNAWAY =

":You are no longer marked as being away"

305
RPL_NOWAWAY =

":You have been marked as being away"

306
RPL_WHOISUSER =

" * :"

311
RPL_WHOISSERVER =

" :"

312
RPL_WHOISOPERATOR =

" :is an IRC operator"

313
RPL_WHOISIDLE =

" :seconds idle"

317
RPL_ENDOFWHOIS =

" :End of WHOIS list"

318
RPL_WHOISCHANNELS =

" :*( ( "@" / "+" ) " " )"

319
RPL_WHOWASUSER =

" * :"

314
RPL_ENDOFWHOWAS =

" :End of WHOWAS"

369
RPL_LISTSTART =

Obsolete. Not used.

321
RPL_LIST =

" <# visible> :"

322
RPL_LISTEND =

":End of LIST"

323
RPL_UNIQOPIS =

" "

325
RPL_CHANNELMODEIS =

" "

324
RPL_CREATIONTIME =

" "

329
RPL_CHANNEL_URL =

" "

328
RPL_NOTOPIC =

" :No topic is set"

331
RPL_TOPIC =

" :"

332
RPL_TOPIC_INFO =

333
RPL_INVITING =

" "

  • Returned by the server to indicate that the attempted INVITE message was successful and is being passed onto the end client.
341
RPL_SUMMONING =

" :Summoning user to IRC"

  • Returned by a server answering a SUMMON message to indicate that it is summoning that user.
342
RPL_INVITELIST =

" "

346
RPL_ENDOFINVITELIST =

" :End of channel invite list"

  • When listing the 'invitations masks' for a given channel, a server is required to send the list back using the RPL_INVITELIST and RPL_ENDOFINVITELIST messages. A separate RPL_INVITELIST is sent for each active mask. After the masks have been listed (or if none present) a RPL_ENDOFINVITELIST MUST be sent.
347
RPL_EXCEPTLIST =

" "

348
RPL_ENDOFEXCEPTLIST =

" :End of channel exception list"

  • When listing the 'exception masks' for a given channel, a server is required to send the list back using the RPL_EXCEPTLIST and RPL_ENDOFEXCEPTLIST messages. A separate RPL_EXCEPTLIST is sent for each active mask. After the masks have been listed (or if none present) a RPL_ENDOFEXCEPTLIST MUST be sent.
349
RPL_VERSION =

". :"

  • Reply by the server showing its version details.

The is the version of the software being used (including any patchlevel revisions) and the is used to indicate if the server is running in "debug mode".

The "comments" field may contain any comments about the version or further version details.

351
RPL_WHOREPLY =

" ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] : "

352
RPL_ENDOFWHO =

" :End of WHO list"

315
RPL_NAMREPLY =

"( "=" / "*" / "@" ) :[ "@" / "+" ] *( " " [ "@" / "+" ] )

  • "@" is used for secret channels, "*" for private channels, and "=" for others (public channels).
353
RPL_ENDOFNAMES =

" :End of NAMES list"

366
364
365
RPL_BANLIST =

" "

367
RPL_ENDOFBANLIST =

" :End of channel ban list"

368
RPL_INFO =

":"

371
RPL_ENDOFINFO =

":End of INFO list"

374
RPL_MOTDSTART =

":- Message of the day - "

375
RPL_MOTD =

":- "

372
RPL_ENDOFMOTD =

":End of MOTD command"

376
RPL_YOUREOPER =

":You are now an IRC operator"

  • RPL_YOUREOPER is sent back to a client which has just successfully issued an OPER message and gained operator status.
381
RPL_REHASHING =

" :Rehashing"

  • If the REHASH option is used and an operator sends a REHASH message, an RPL_REHASHING is sent back to the operator.
382
RPL_YOURESERVICE =

"You are service "

  • Sent by the server to a service upon successful registration.
383
RPL_TIME =

" :<string showing server's local time>"

  • When replying to the TIME message, a server MUST send the reply using the RPL_TIME format above. The string showing the time need only contain the correct day and time there. There is no further requirement for the time string.
391
RPL_USERSSTART =

":UserID Terminal Host"

392
RPL_USERS =

": "

393
RPL_ENDOFUSERS =

":End of users"

394
RPL_NOUSERS =

":Nobody logged in"

395
200
RPL_TRACECONNECTING =

"Try. "

201
RPL_TRACEHANDSHAKE =

"H.S. "

202
RPL_TRACEUNKNOWN =

"???? []"

203
RPL_TRACEOPERATOR =

"Oper "

204
RPL_TRACEUSER =

"User "

205
RPL_TRACESERVER =

"Serv S C <nick!user|!>@<host|server> V"

206
RPL_TRACESERVICE =

"Service "

207
RPL_TRACENEWTYPE =

" 0 "

208
RPL_TRACECLASS =

"Class "

209
RPL_TRACERECONNECT =

Unused.

210
RPL_TRACELOG =

"File "

261
RPL_TRACEEND =

" <version & debug level> :End of TRACE"

262
RPL_LOCALUSERS =

":Current local users: 3 Max: 4"

265
RPL_GLOBALUSERS =

":Current global users: 3 Max: 4"

266
RPL_STATSCONN =

"::Highest connection count: 4 (4 clients) (251 since server was (re)started)"

250
RPL_STATSLINKINFO =

"

  • reports statistics on a connection. identifies the particular connection, is the amount of data that is queued and waiting to be sent the number of messages sent, and the amount of data sent, in Kbytes. and are the equivalent of and for received data, respectively.
211
RPL_STATSCOMMANDS =

" "

  • reports statistics on commands usage.
212
RPL_ENDOFSTATS =

" :End of STATS report"

219
RPL_STATSUPTIME =

":Server Up %d days %d:%02d:%02d"

  • reports the server uptime.
242
RPL_STATSOLINE =

"O * "

  • reports the allowed hosts from where user may become IRC operators.
243
RPL_UMODEIS =

""

  • To answer a query about a client's own mode, RPL_UMODEIS is sent back.
221
RPL_SERVLIST =

" "

234
RPL_SERVLISTEND =

" :End of service listing"

235
RPL_LUSERCLIENT =

":There are users and services on servers"

251
RPL_LUSEROP =

" :operator(s) online"

252
RPL_LUSERUNKNOWN =

" :unknown connection(s)"

253
RPL_LUSERCHANNELS =

" :channels formed"

254
RPL_LUSERME =

":I have clients and servers"

255
RPL_ADMINME =

" :Administrative info"

256
RPL_ADMINLOC1 =

":"

257
RPL_ADMINLOC2 =

":"

258
RPL_ADMINEMAIL =

":"

259
RPL_TRYAGAIN =

" :Please wait a while and try again."

  • When a server drops a command without processing it, it MUST use the reply RPL_TRYAGAIN to inform the originating client.
263
ERR_NOSUCHNICK =

" :No such nick/channel"

  • Used to indicate the nickname parameter supplied to a command is currently unused.
401
ERR_NOSUCHSERVER =

" :No such server"

  • Used to indicate the server name given currently does not exist.
402
ERR_NOSUCHCHANNEL =

" :No such channel"

  • Used to indicate the given channel name is invalid.
403
ERR_CANNOTSENDTOCHAN =

" :Cannot send to channel"

  • Sent to a user who is either (a) not on a channel which is mode +n or (b) not a chanop (or mode +v) on a channel which has mode +m set or where the user is banned and is trying to send a PRIVMSG message to that channel.
404
ERR_TOOMANYCHANNELS =

" :You have joined too many channels"

  • Sent to a user when they have joined the maximum number of allowed channels and they try to join another channel.
405
ERR_WASNOSUCHNICK =

" :There was no such nickname"

  • Returned by WHOWAS to indicate there is no history information for that nickname.
406
ERR_TOOMANYTARGETS =

" : recipients. "

  • Returned to a client which is attempting to send a PRIVMSG/NOTICE using the user@host destination format and for a user@host which has several occurrences.

  • Returned to a client which trying to send a PRIVMSG/NOTICE to too many recipients.

  • Returned to a client which is attempting to JOIN a safe channel using the shortname when there are more than one such channel.

407
ERR_NOSUCHSERVICE =

" :No such service"

  • Returned to a client which is attempting to send a SQUERY to a service which does not exist.
408
ERR_NOORIGIN =

":No origin specified"

  • PING or PONG message missing the originator parameter.
409
ERR_NORECIPIENT =

":No recipient given ()"

411
ERR_NOTEXTTOSEND =

":No text to send"

412
ERR_NOTOPLEVEL =

" :No toplevel domain specified"

413
ERR_WILDTOPLEVEL =

" :Wildcard in toplevel domain"

414
ERR_BADMASK =

" :Bad Server/host mask"

415
ERR_UNKNOWNCOMMAND =

" :Unknown command"

  • Returned to a registered client to indicate that the command sent is unknown by the server.
421
ERR_NOMOTD =

":MOTD File is missing"

  • Server's MOTD file could not be opened by the server.
422
ERR_NOADMININFO =

" :No administrative info available"

  • Returned by a server in response to an ADMIN message when there is an error in finding the appropriate information.
423
ERR_FILEERROR =

":File error doing on "

  • Generic error message used to report a failed file operation during the processing of a message.
424
ERR_NONICKNAMEGIVEN =

":No nickname given"

  • Returned when a nickname parameter expected for a command and isn't found.
431
ERR_ERRONEUSNICKNAME =

" :Erroneous nickname"

  • Returned after receiving a NICK message which contains characters which do not fall in the defined set. See section 2.3.1 for details on valid nicknames.
432
ERR_NICKNAMEINUSE =

" :Nickname is already in use"

  • Returned when a NICK message is processed that results in an attempt to change to a currently existing nickname.
433
ERR_NICKCOLLISION =

" :Nickname collision KILL from @"

  • Returned by a server to a client when it detects a nickname collision (registered of a NICK that already exists by another server).
436
ERR_UNAVAILRESOURCE =

"<nick/channel> :Nick/channel is temporarily unavailable"

  • Returned by a server to a user trying to join a channel currently blocked by the channel delay mechanism.

  • Returned by a server to a user trying to change nickname when the desired nickname is blocked by the nick delay mechanism.

437
ERR_USERNOTINCHANNEL =

" :They aren't on that channel"

  • Returned by the server to indicate that the target user of the command is not on the given channel.
441
ERR_NOTONCHANNEL =

" :You're not on that channel"

  • Returned by the server whenever a client tries to perform a channel affecting command for which the client isn't a member.
442
ERR_USERONCHANNEL =

" :is already on channel"

  • Returned when a client tries to invite a user to a channel they are already on.
443
ERR_NOLOGIN =

" :User not logged in"

  • Returned by the summon after a SUMMON command for a user was unable to be performed since they were not logged in.
444
ERR_SUMMONDISABLED =

":SUMMON has been disabled"

  • Returned as a response to the SUMMON command. MUST be returned by any server which doesn't implement it.
445
ERR_USERSDISABLED =

":USERS has been disabled"

  • Returned as a response to the USERS command. MUST be returned by any server which does not implement it.
446
ERR_NOTREGISTERED =

":You have not registered"

  • Returned by the server to indicate that the client MUST be registered before the server will allow it to be parsed in detail.
451
ERR_NEEDMOREPARAMS =

" :Not enough parameters"

  • Returned by the server by numerous commands to indicate to the client that it didn't supply enough parameters.
461
ERR_ALREADYREGISTRED =

":Unauthorized command (already registered)"

  • Returned by the server to any link which tries to change part of the registered details (such as password or user details from second USER message).
462
ERR_NOPERMFORHOST =

":Your host isn't among the privileged"

  • Returned to a client which attempts to register with a server which does not been setup to allow connections from the host the attempted connection is tried.
463
ERR_PASSWDMISMATCH =

":Password incorrect"

  • Returned to indicate a failed attempt at registering a connection for which a password was required and was either not given or incorrect.
464
ERR_YOUREBANNEDCREEP =

":You are banned from this server"

  • Returned after an attempt to connect and register yourself with a server which has been setup to explicitly deny connections to you.
465
ERR_YOUWILLBEBANNED =
  • Sent by a server to a user to inform that access to the server will soon be denied.
466
ERR_KEYSET =

" :Channel key already set"

467
ERR_CHANNELISFULL =

" :Cannot join channel (+l)"

471
ERR_UNKNOWNMODE =

" :is unknown mode char to me for "

472
ERR_INVITEONLYCHAN =

" :Cannot join channel (+i)"

473
ERR_BANNEDFROMCHAN =

" :Cannot join channel (+b)"

474
ERR_BADCHANNELKEY =

" :Cannot join channel (+k)"

475
ERR_BADCHANMASK =

" :Bad Channel Mask"

476
ERR_NOCHANMODES =

" :Channel doesn't support modes"

477
ERR_BANLISTFULL =

" :Channel list is full"

478
ERR_NOPRIVILEGES =

":Permission Denied- You're not an IRC operator"

  • Any command requiring operator privileges to operate MUST return this error to indicate the attempt was unsuccessful.
481
ERR_CHANOPRIVSNEEDED =

" :You're not channel operator"

  • Any command requiring 'chanop' privileges (such as MODE messages) MUST return this error if the client making the attempt is not a chanop on the specified channel.
482
ERR_CANTKILLSERVER =

":You can't kill a server!"

  • Any attempts to use the KILL command on a server are to be refused and this error returned directly to the client.
483
ERR_RESTRICTED =

":Your connection is restricted!"

  • Sent by the server to a user upon connection to indicate the restricted nature of the connection (user mode "+r").
484
ERR_UNIQOPPRIVSNEEDED =

":You're not the original channel operator"

  • Any MODE requiring "channel creator" privileges MUST return this error if the client making the attempt is not a chanop on the specified channel.
485
ERR_NOOPERHOST =

":No O-lines for your host"

  • If a client sends an OPER message and the server has not been configured to allow connections from the client's host as an operator, this error MUST be returned.
491
ERR_UMODEUNKNOWNFLAG =

":Unknown MODE flag"

  • Returned by the server to indicate that a MODE message was sent with a nickname parameter and that the a mode flag sent was not recognized.
501
ERR_USERSDONTMATCH =

":Cannot change mode for other users"

  • Error sent to any user trying to view or change the user mode for a user other than themselves.
502
RPL_SERVICEINFO =

5.3 Reserved numerics

These numerics are not described above since they fall into one of the following categories:

  1. no longer in use;

  2. reserved for future planned use;

  3. in current use but are part of a non-generic 'feature' of the current IRC server.

231
RPL_ENDOFSERVICES =
232
RPL_SERVICE =
233
RPL_NONE =
300
RPL_WHOISCHANOP =
316
RPL_KILLDONE =
361
RPL_CLOSING =
362
RPL_CLOSEEND =
363
RPL_INFOSTART =
373
RPL_MYPORTIS =
384
RPL_STATSCLINE =
213
RPL_STATSNLINE =
214
RPL_STATSILINE =
215
RPL_STATSKLINE =
216
RPL_STATSQLINE =
217
RPL_STATSYLINE =
218
RPL_STATSVLINE =
240
RPL_STATSLLINE =
241
RPL_STATSHLINE =
244
RPL_STATSSLINE =
244
RPL_STATSPING =
246
RPL_STATSBLINE =
247
ERR_NOSERVICEHOST =
492
RPL_DATASTR =
290
Config =
Bot::Config

Class Method Summary collapse

Class Method Details

.color(fg = nil, bg = nil) ⇒ Object

Insert the full color code for a given foreground/background combination.



98
99
100
101
102
103
104
105
106
107
# File 'lib/rbot/message.rb', line 98

def Irc.color(fg=nil,bg=nil)
  str = Color.dup
  if fg
   str << Irc.find_color(fg)
  end
  if bg
    str << "," << Irc.find_color(bg)
  end
  return str
end

.find_color(data) ⇒ Object

Convert a String or Symbol into a color number



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rbot/message.rb', line 79

def Irc.find_color(data)
  "%02d" % if Integer === data
    data
  else
    f = if String === data
          data.intern
        else
          data
        end
    if ColorCode.key?(f)
      ColorCode[f]
    else
      0
    end
  end
end