Class: IRC::Messages::PrivateMessage
- Defined in:
- lib/irc/messages/private_message.rb
Overview
4.4.1 Private messages
Command: PRIVMSG Parameters: <receiver>,<receiver> <text to be sent>
PRIVMSG is used to send private messages between users. <receiver> is the nickname of the receiver of the message. <receiver> can also be a list of names or channels separated with commas.
The <receiver> parameter may also me a host mask (#mask) or server mask ($mask). In both cases the server will only send the PRIVMSG to those who have a server or host matching the mask. The mask must have at least 1 (one) “.” in it and no wildcards following the last “.”. This requirement exists to prevent people sending messages to “#*” or “$*”, which would broadcast to all users; from experience, this is abused more than used responsibly and properly. Wildcards are the ‘*’ and ‘?’ characters. This extension to the PRIVMSG command is only available to Operators.
Numeric Replies:
-
ERR_NORECIPIENT
-
ERR_NOTEXTTOSEND
-
ERR_CANNOTSENDTOCHAN
-
ERR_NOTOPLEVEL
-
ERR_WILDTOPLEVEL
-
ERR_TOOMANYTARGETS
-
ERR_NOSUCHNICK
-
RPL_AWAY
Examples:
:Angel PRIVMSG Wiz :Hello are you receiving this message ?
; Message from Angel to Wiz.
PRIVMSG Angel :yes I’m receiving it !receiving it !‘u>(768u+1n) .br
; Message to Angel.
PRIVMSG [email protected] :Hello !
; Message to a client on server
tolsun.oulu.fi with username of "jto".
PRIVMSG $*.fi :Server tolsun.oulu.fi rebooting.
; Message to everyone on a server which
has a name matching *.fi.
PRIVMSG #*.edu :NSFNet is undergoing work, expect interruptions
; Message to all users who come from a
host which has a name matching *.edu.
Constant Summary collapse
- CODE =
"PRIVMSG"
Constants inherited from Message
Constants included from Codes
Codes::ERR_ALREADYREGISTRED, Codes::ERR_BADCHANMASK, Codes::ERR_BADCHANNAME, Codes::ERR_BADCHANNELKEY, Codes::ERR_BANNEDFROMCHAN, Codes::ERR_CANNOTSENDTOCHAN, Codes::ERR_CANTKILLSERVER, Codes::ERR_CHANNELISFULL, Codes::ERR_CHANOPRIVSNEEDED, Codes::ERR_ERRONEUSNICKNAME, Codes::ERR_FILEERROR, Codes::ERR_INVALIDUSERNAME, Codes::ERR_INVITEONLYCHAN, Codes::ERR_KEYSET, Codes::ERR_LINKCHANNEL, Codes::ERR_NEEDMOREPARAMS, Codes::ERR_NICKCOLLISION, Codes::ERR_NICKNAMEINUSE, Codes::ERR_NOADMININFO, Codes::ERR_NOLOGIN, Codes::ERR_NOMOTD, Codes::ERR_NONICKNAMEGIVEN, Codes::ERR_NOOPERHOST, Codes::ERR_NOORIGIN, Codes::ERR_NOPERMFORHOST, Codes::ERR_NOPRIVILEGES, Codes::ERR_NORECIPIENT, Codes::ERR_NOSERVICEHOST, Codes::ERR_NOSUCHCHANNEL, Codes::ERR_NOSUCHNICK, Codes::ERR_NOSUCHSERVER, Codes::ERR_NOTEXTTOSEND, Codes::ERR_NOTONCHANNEL, Codes::ERR_NOTOPLEVEL, Codes::ERR_NOTREGISTERED, Codes::ERR_PASSWDMISMATCH, Codes::ERR_SECUREONLYCHAN, Codes::ERR_SUMMONDISABLED, Codes::ERR_TARGETTOOFAST, Codes::ERR_TOOMANYCHANNELS, Codes::ERR_TOOMANYTARGETS, Codes::ERR_UMODEUNKNOWNFLAG, Codes::ERR_UNKNOWNCOMMAND, Codes::ERR_UNKNOWNMODE, Codes::ERR_USERNOTINCHANNEL, Codes::ERR_USERONCHANNEL, Codes::ERR_USERSDISABLED, Codes::ERR_USERSDONTMATCH, Codes::ERR_WASNOSUCHNICK, Codes::ERR_WILDTOPLEVEL, Codes::ERR_YOUREBANNEDCREEP, Codes::ERR_YOUWILLBEBANNED, Codes::RPL_ADMINEMAIL, Codes::RPL_ADMINLOC1, Codes::RPL_ADMINLOC2, Codes::RPL_ADMINME, Codes::RPL_AWAY, Codes::RPL_BANLIST, Codes::RPL_BOUNCE, Codes::RPL_CHANNELMODEIS, Codes::RPL_CLOSEEND, Codes::RPL_CLOSING, Codes::RPL_CREATED, Codes::RPL_ENDOFBANLIST, Codes::RPL_ENDOFINFO, Codes::RPL_ENDOFLINKS, Codes::RPL_ENDOFMOTD, Codes::RPL_ENDOFNAMES, Codes::RPL_ENDOFSERVICES, Codes::RPL_ENDOFSTATS, Codes::RPL_ENDOFUSERS, Codes::RPL_ENDOFWHO, Codes::RPL_ENDOFWHOIS, Codes::RPL_ENDOFWHOWAS, Codes::RPL_INFO, Codes::RPL_INFOSTART, Codes::RPL_INVITING, Codes::RPL_ISON, Codes::RPL_ISUPPORT, Codes::RPL_KILLDONE, Codes::RPL_LINKS, Codes::RPL_LIST, Codes::RPL_LISTEND, Codes::RPL_LISTSTART, Codes::RPL_LUSERCHANNELS, Codes::RPL_LUSERCLIENT, Codes::RPL_LUSERME, Codes::RPL_LUSEROP, Codes::RPL_LUSERUNKNOWN, Codes::RPL_MOTD, Codes::RPL_MOTDSTART, Codes::RPL_MYINFO, Codes::RPL_MYPORTIS, Codes::RPL_NAMREPLY, Codes::RPL_NONE, Codes::RPL_NOTOPIC, Codes::RPL_NOUSERS, Codes::RPL_NOWAWAY, Codes::RPL_REHASHING, Codes::RPL_SERVICE, Codes::RPL_SERVICEINFO, Codes::RPL_SERVLIST, Codes::RPL_SERVLISTEND, Codes::RPL_STATSCLINE, Codes::RPL_STATSCOMMANDS, Codes::RPL_STATSHLINE, Codes::RPL_STATSILINE, Codes::RPL_STATSKLINE, Codes::RPL_STATSLINKINFO, Codes::RPL_STATSLLINE, Codes::RPL_STATSNLINE, Codes::RPL_STATSOLINE, Codes::RPL_STATSQLINE, Codes::RPL_STATSUPTIME, Codes::RPL_STATSYLINE, Codes::RPL_SUMMONING, Codes::RPL_TIME, Codes::RPL_TOPIC, Codes::RPL_TOPICINFO, Codes::RPL_TRACECLASS, Codes::RPL_TRACECONNECTING, Codes::RPL_TRACEHANDSHAKE, Codes::RPL_TRACELINK, Codes::RPL_TRACELOG, Codes::RPL_TRACENEWTYPE, Codes::RPL_TRACEOPERATOR, Codes::RPL_TRACESERVER, Codes::RPL_TRACEUNKNOWN, Codes::RPL_TRACEUSER, Codes::RPL_UMODEIS, Codes::RPL_UNAWAY, Codes::RPL_USERHOST, Codes::RPL_USERS, Codes::RPL_USERSSTART, Codes::RPL_VERSION, Codes::RPL_WELCOME, Codes::RPL_WHOISCHANNELS, Codes::RPL_WHOISCHANOP, Codes::RPL_WHOISIDLE, Codes::RPL_WHOISOPERATOR, Codes::RPL_WHOISSERVER, Codes::RPL_WHOISUSER, Codes::RPL_WHOREPLY, Codes::RPL_WHOWASUSER, Codes::RPL_YOUREOPER, Codes::RPL_YOURHOST
Instance Attribute Summary collapse
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Message
#code, #host, #login, #message, #nick, #raw_message, #server
Instance Method Summary collapse
-
#handle(context) ⇒ Object
Notify all connection listeners, that a private message was received.
Methods inherited from Message
#==, #eql?, #initialize, is_valid?, #to_s
Constructor Details
This class inherits a constructor from IRC::Messages::Message
Instance Attribute Details
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
85 86 87 |
# File 'lib/irc/messages/private_message.rb', line 85 def sender @sender end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
84 85 86 |
# File 'lib/irc/messages/private_message.rb', line 84 def target @target end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
86 87 88 |
# File 'lib/irc/messages/private_message.rb', line 86 def text @text end |
Instance Method Details
#handle(context) ⇒ Object
Notify all connection listeners, that a private message was received.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/irc/messages/private_message.rb', line 89 def handle(context) # Notify all connection listeners by calling their on_server_response method. super(context) # Notify all connection listeners by calling their on_private_message method. notify(context) do |connection_listener| connection_listener.(context, IRC::Models::Channel.is_valid?(target) ? context.lookup_channel(target) : context.lookup_user(target), text) end end |