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 <nick>!<user>@<host>”

001
RPL_YOURHOST =

“Your host is <servername>, running version <ver>”

002
RPL_CREATED =

“This server was created <date>”

003
RPL_MYINFO =

“<servername> <version> <available user modes> <available channel modes>”

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 <server name>, port <port number>”

RPL_BOUNCE=005

005
RPL_USERHOST =

“:*1<reply> *( ” “ <reply> )”

  • 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<nick> *( ” “ <nick> )”

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

303
RPL_AWAY =

“<nick> :<away message>”

301
RPL_UNAWAY =

“:You are no longer marked as being away”

305
RPL_NOWAWAY =

“:You have been marked as being away”

306
RPL_WHOISUSER =

“<nick> <user> <host> * :<real name>”

311
RPL_WHOISSERVER =

“<nick> <server> :<server info>”

312
RPL_WHOISOPERATOR =

“<nick> :is an IRC operator”

313
RPL_WHOISIDLE =

“<nick> <integer> :seconds idle”

317
RPL_ENDOFWHOIS =

“<nick> :End of WHOIS list”

318
RPL_WHOISCHANNELS =

“<nick> :*( ( ”@“ / ”+“ ) <channel> ” “ )”

319
RPL_WHOWASUSER =

“<nick> <user> <host> * :<real name>”

314
RPL_ENDOFWHOWAS =

“<nick> :End of WHOWAS”

369
RPL_LISTSTART =

Obsolete. Not used.

321
RPL_LIST =

“<channel> <# visible> :<topic>”

322
RPL_LISTEND =

“:End of LIST”

323
RPL_UNIQOPIS =

“<channel> <nickname>”

325
RPL_CHANNELMODEIS =

“<channel> <mode> <mode params>”

324
RPL_CREATIONTIME =

“<channel> <unixtime>”

329
RPL_CHANNEL_URL =

“<channel> <url>”

328
RPL_NOTOPIC =

“<channel> :No topic is set”

331
RPL_TOPIC =

“<channel> :<topic>”

332
RPL_TOPIC_INFO =

<channel> <set by> <unixtime>

333
RPL_INVITING =

“<channel> <nick>”

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

341
RPL_SUMMONING =

“<user> :Summoning user to IRC”

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

342
RPL_INVITELIST =

“<channel> <invitemask>”

346
RPL_ENDOFINVITELIST =

“<channel> :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 =

“<channel> <exceptionmask>”

348
RPL_ENDOFEXCEPTLIST =

“<channel> :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 =

“<version>.<debuglevel> <server> :<comments>”

  • Reply by the server showing its version details.

The <version> is the version of the software being used (including any patchlevel revisions) and the <debuglevel> 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 =

“<channel> <user> <host> <server> <nick> ( ”H“ / ”G“ > [”*“] [ ( ”@“ / ”+“ ) ] :<hopcount> <real name>”

352
RPL_ENDOFWHO =

“<name> :End of WHO list”

315
RPL_NAMREPLY =

“( ”=“ / ”*“ / ”@“ ) <channel> :[ ”@“ / ”+“ ] <nick> *( ” “ [ ”@“ / ”+“ ] <nick> )

  • “@” is used for secret channels, “*” for private

channels, and “=” for others (public channels).

353
RPL_ENDOFNAMES =

“<channel> :End of NAMES list”

366
364
365
RPL_BANLIST =

“<channel> <banmask>”

367
RPL_ENDOFBANLIST =

“<channel> :End of channel ban list”

368
RPL_INFO =

“:<string>”

371
RPL_ENDOFINFO =

“:End of INFO list”

374
RPL_MOTDSTART =

“:- <server> Message of the day - ”

375
RPL_MOTD =

“:- <text>”

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 =

“<config file> :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 <servicename>”

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

383
RPL_TIME =

“<server> :<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 =

“:<username> <ttyline> <hostname>”

393
RPL_ENDOFUSERS =

“:End of users”

394
RPL_NOUSERS =

“:Nobody logged in”

395
200
RPL_TRACECONNECTING =

“Try. <class> <server>”

201
RPL_TRACEHANDSHAKE =

“H.S. <class> <server>”

202
RPL_TRACEUNKNOWN =

“???? <class> [<client IP address in dot form>]”

203
RPL_TRACEOPERATOR =

“Oper <class> <nick>”

204
RPL_TRACEUSER =

“User <class> <nick>”

205
RPL_TRACESERVER =

“Serv <class> <int>S <int>C <server> <nick!user|*!*>@<host|server> V<protocol version>”

206
RPL_TRACESERVICE =

“Service <class> <name> <type> <active type>”

207
RPL_TRACENEWTYPE =

“<newtype> 0 <client name>”

208
RPL_TRACECLASS =

“Class <class> <count>”

209
RPL_TRACERECONNECT =

Unused.

210
RPL_TRACELOG =

“File <logfile> <debug level>”

261
RPL_TRACEEND =

“<server name> <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 =

“<linkname> <sendq> <sent messages> <sent Kbytes> <received messages> <received Kbytes> <time open>”

  • reports statistics on a connection. <linkname> identifies the particular connection, <sendq> is the amount of data that is queued and waiting to be sent <sent messages> the number of messages sent, and <sent Kbytes> the amount of data sent, in Kbytes. <received messages> and <received Kbytes> are the equivalent of <sent messages> and <sent Kbytes> for received data, respectively. <time open> indicates how long ago the connection was opened, in seconds.

211
RPL_STATSCOMMANDS =

“<command> <count> <byte count> <remote count>”

  • reports statistics on commands usage.

212
RPL_ENDOFSTATS =

“<stats letter> :End of STATS report”

219
RPL_STATSUPTIME =

“:Server Up %d days %d:%02d:%02d”

  • reports the server uptime.

242
RPL_STATSOLINE =

“O <hostmask> * <name>”

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

243
RPL_UMODEIS =

“<user mode string>”

  • To answer a query about a client’s own mode, RPL_UMODEIS is sent back.

221
RPL_SERVLIST =

“<name> <server> <mask> <type> <hopcount> <info>”

234
RPL_SERVLISTEND =

“<mask> <type> :End of service listing”

235
RPL_LUSERCLIENT =

“:There are <integer> users and <integer> services on <integer> servers”

251
RPL_LUSEROP =

“<integer> :operator(s) online”

252
RPL_LUSERUNKNOWN =

“<integer> :unknown connection(s)”

253
RPL_LUSERCHANNELS =

“<integer> :channels formed”

254
RPL_LUSERME =

“:I have <integer> clients and <integer> servers”

255
RPL_ADMINME =

“<server> :Administrative info”

256
RPL_ADMINLOC1 =

“:<admin info>”

257
RPL_ADMINLOC2 =

“:<admin info>”

258
RPL_ADMINEMAIL =

“:<admin info>”

259
RPL_TRYAGAIN =

“<command> :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 =

“<nickname> :No such nick/channel”

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

401
ERR_NOSUCHSERVER =

“<server name> :No such server”

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

402
ERR_NOSUCHCHANNEL =

“<channel name> :No such channel”

  • Used to indicate the given channel name is invalid.

403
ERR_CANNOTSENDTOCHAN =

“<channel name> :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 =

“<channel name> :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 =

“<nickname> :There was no such nickname”

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

406
ERR_TOOMANYTARGETS =

“<target> :<error code> recipients. <abort message>”

  • 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 =

“<service name> :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 (<command>)”

411
ERR_NOTEXTTOSEND =

“:No text to send”

412
ERR_NOTOPLEVEL =

“<mask> :No toplevel domain specified”

413
ERR_WILDTOPLEVEL =

“<mask> :Wildcard in toplevel domain”

414
ERR_BADMASK =

“<mask> :Bad Server/host mask”

415
ERR_UNKNOWNCOMMAND =

“<command> :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 =

“<server> :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 <file op> on <file>”

  • 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 =

“<nick> :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 =

“<nick> :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 =

“<nick> :Nickname collision KILL from <user>@<host>”

  • 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 =

“<nick> <channel> :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 =

“<channel> :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 =

“<user> <channel> :is already on channel”

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

443
ERR_NOLOGIN =

“<user> :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 =

“<command> :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> :Channel key already set”

467
ERR_CHANNELISFULL =

“<channel> :Cannot join channel (+l)”

471
ERR_UNKNOWNMODE =

“<char> :is unknown mode char to me for <channel>”

472
ERR_INVITEONLYCHAN =

“<channel> :Cannot join channel (+i)”

473
ERR_BANNEDFROMCHAN =

“<channel> :Cannot join channel (+b)”

474
ERR_BADCHANNELKEY =

“<channel> :Cannot join channel (+k)”

475
ERR_BADCHANMASK =

“<channel> :Bad Channel Mask”

476
ERR_NOCHANMODES =

“<channel> :Channel doesn’t support modes”

477
ERR_BANLISTFULL =

“<channel> <char> :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 =

“<channel> :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