Class: ModSpox::Messages::Incoming::Privmsg
- Defined in:
- lib/mod_spox/messages/incoming/Privmsg.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
the message sent.
-
#source ⇒ Object
readonly
source of the message.
-
#target ⇒ Object
readonly
target of the message.
Attributes inherited from Message
Instance Method Summary collapse
-
#addressed? ⇒ Boolean
Is message addressing the bot.
-
#initialize(raw, source, target, message) ⇒ Privmsg
constructor
A new instance of Privmsg.
-
#is_action? ⇒ Boolean
Is this message an action message.
-
#is_colored? ⇒ Boolean
Does the message contain colors.
-
#is_private? ⇒ Boolean
Is this is private message.
-
#is_public? ⇒ Boolean
Is this a public message.
-
#message_nocolor ⇒ Object
Message with coloring stripped.
-
#replyto ⇒ Object
Convinence method for replying to the correct place.
Constructor Details
#initialize(raw, source, target, message) ⇒ Privmsg
Returns a new instance of Privmsg.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 13 def initialize(raw, source, target, ) super(raw) @source = source @target = target if( =~ /^\001ACTION\s(.+)\001/) @message = $1 @action = true else @message = @action = false end botnick = Models::Nick.filter(:botnick => true).first if(botnick) @addressed = @message =~ /^#{botnick.nick}/i else @addressed = false end end |
Instance Attribute Details
#message ⇒ Object (readonly)
the message sent
12 13 14 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 12 def @message end |
#source ⇒ Object (readonly)
source of the message
8 9 10 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 8 def source @source end |
#target ⇒ Object (readonly)
target of the message
10 11 12 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 10 def target @target end |
Instance Method Details
#addressed? ⇒ Boolean
Is message addressing the bot
33 34 35 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 33 def addressed? return @addressed || is_private? end |
#is_action? ⇒ Boolean
Is this message an action message
58 59 60 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 58 def is_action? @action end |
#is_colored? ⇒ Boolean
Does the message contain colors
48 49 50 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 48 def is_colored? return @message =~ /\cC\d\d?(?:,\d\d?)?/ end |
#is_private? ⇒ Boolean
Is this is private message
38 39 40 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 38 def is_private? return @target.is_a?(Models::Nick) end |
#is_public? ⇒ Boolean
Is this a public message
43 44 45 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 43 def is_public? return @target.is_a?(Models::Channel) end |
#message_nocolor ⇒ Object
Message with coloring stripped
53 54 55 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 53 def return @message.gsub(/\cC\d\d?(?:,\d\d?)?/, '') end |
#replyto ⇒ Object
Convinence method for replying to the correct place
63 64 65 66 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 63 def replyto return @source if is_private? return @target if is_public? end |