Class: EM::IrcBot::Message
- Inherits:
-
Object
- Object
- EM::IrcBot::Message
- Defined in:
- lib/em/irc_bot/message.rb
Overview
A message that has come in to the bot from the server.
You will see one of these objects in every one of your #on
callbacks --
it is what gets yielded to your callbacks. You should never need to
create an instance of this class yourself.
Instance Attribute Summary collapse
-
#bot ⇒ EM::IrcBot
readonly
The instance of EM::IrcBot from which this message originated.
-
#channel ⇒ String
readonly
The public channel, or nick, which originated the message.
-
#line ⇒ String
readonly
The text of the message.
-
#sender ⇒ String
readonly
The nick which sent the message.
Instance Method Summary collapse
-
#initialize(bot, channel, sender, line) ⇒ Message
constructor
:nodoc:.
-
#private? ⇒ Boolean
Whether or not this message was sent directly to the bot, or came to us via a channel.
-
#reply(s) ⇒ Object
Send a line of text back to the channel which originated the message.
Constructor Details
#initialize(bot, channel, sender, line) ⇒ Message
:nodoc:
43 44 45 46 47 48 |
# File 'lib/em/irc_bot/message.rb', line 43 def initialize(bot, channel, sender, line) @bot = bot @channel = channel @sender = sender @line = line end |
Instance Attribute Details
#bot ⇒ EM::IrcBot (readonly)
The instance of EM::IrcBot from which this message originated. Useful if you want to send a customised message back.
18 19 20 |
# File 'lib/em/irc_bot/message.rb', line 18 def bot @bot end |
#channel ⇒ String (readonly)
The public channel, or nick, which originated the message. This is the place which replies will be sent to by #reply.
25 26 27 |
# File 'lib/em/irc_bot/message.rb', line 25 def channel @channel end |
#line ⇒ String (readonly)
The text of the message.
39 40 41 |
# File 'lib/em/irc_bot/message.rb', line 39 def line @line end |
#sender ⇒ String (readonly)
33 34 35 |
# File 'lib/em/irc_bot/message.rb', line 33 def sender @sender end |
Instance Method Details
#private? ⇒ Boolean
Whether or not this message was sent directly to the bot, or came to us via a channel.
69 70 71 |
# File 'lib/em/irc_bot/message.rb', line 69 def private? channel == sender end |
#reply(s) ⇒ Object
Send a line of text back to the channel which originated the message.
This is only a reply to the source channel; it doesn't modify your message at all to, say, prepend the nick of the sender. That bit's up to you.
60 61 62 |
# File 'lib/em/irc_bot/message.rb', line 60 def reply(s) bot.say(channel, s) end |