Class: Flexo::Events::PrivmsgEvent
- Inherits:
-
Flexo::Event
- Object
- Flexo::Event
- Flexo::Events::PrivmsgEvent
- Defined in:
- lib/flexo/events/privmsg.rb
Overview
Private messages, which, in fact, isn’t neccessarily private. When the target of a privmsg is a channel, it’s displayed to the entire channel. Which isn’t very private at all.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#sender ⇒ Object
(also: #from)
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 Flexo::Event
Instance Method Summary collapse
-
#ctcp? ⇒ Boolean
Returns true if this was a CTCP-message, and false if not.
-
#initialize(*args) ⇒ PrivmsgEvent
constructor
A new instance of PrivmsgEvent.
-
#reply(text, to_channel = true) ⇒ Object
Sends a quick reply to the message.
-
#to_channel? ⇒ Boolean
Sent to a channel, or was it actually a private message?.
-
#to_me? ⇒ Boolean
Were you the target of the message?.
Methods inherited from Flexo::Event
Constructor Details
#initialize(*args) ⇒ PrivmsgEvent
Returns a new instance of PrivmsgEvent.
12 13 14 15 16 17 18 |
# File 'lib/flexo/events/privmsg.rb', line 12 def initialize(*args) super @sender = @data.hostmask.nick if @data.hostmask @target = @data.params[0] @ctcp = (m = @data.string.match(/^\x01(.+?)\x01$/)) ? true : false @text = @ctcp ? m[1] : @data.string end |
Instance Attribute Details
#sender ⇒ Object (readonly) Also known as: from
Returns the value of attribute sender.
7 8 9 |
# File 'lib/flexo/events/privmsg.rb', line 7 def sender @sender end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
8 9 10 |
# File 'lib/flexo/events/privmsg.rb', line 8 def target @target end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'lib/flexo/events/privmsg.rb', line 9 def text @text end |
Instance Method Details
#ctcp? ⇒ Boolean
Returns true if this was a CTCP-message, and false if not.
21 22 23 |
# File 'lib/flexo/events/privmsg.rb', line 21 def ctcp? return @ctcp end |
#reply(text, to_channel = true) ⇒ Object
Sends a quick reply to the message. If to_channel is false, it’s sent to the person who sent the message, whether he sent it to a channel, or private. If it was sent to you, this will send a direct reply no matter what to_channel is set to.
40 41 42 43 |
# File 'lib/flexo/events/privmsg.rb', line 40 def reply(text, to_channel=true) target = (to_channel && to_channel?) ? @target : @sender @manager.sender.privmsg(target, text) end |
#to_channel? ⇒ Boolean
Sent to a channel, or was it actually a private message?
31 32 33 |
# File 'lib/flexo/events/privmsg.rb', line 31 def to_channel? return Flexo::Constants::CHANPREFIX.include?(@target[0..0]) end |
#to_me? ⇒ Boolean
Were you the target of the message?
26 27 28 |
# File 'lib/flexo/events/privmsg.rb', line 26 def to_me? return @target == @manager.nickname # FIXME: Should this be stored here? end |