Class: ModSpox::Messages::Incoming::Privmsg
- Defined in:
- lib/mod_spox/messages/incoming/Privmsg.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ctcp ⇒ Object
readonly
message is CTCP.
-
#ctcp_type ⇒ Object
readonly
message CTCP type.
-
#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_ctcp? ⇒ Boolean
-
#is_dcc? ⇒ Boolean
Is this a DCC message.
-
#is_private? ⇒ Boolean
Is this is private message.
-
#is_public? ⇒ Boolean
Is this a public message.
-
#message(color = false) ⇒ Object
the message sent.
-
#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.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 15 def initialize(raw, source, target, ) super(raw) @source = source @target = target @ctcp = false @ctcp_type = nil @action = false if(@raw_content =~ /\x01(\S+)\s(.+)\x01/) @ctcp = true @ctcp_type = $1 @message = $2 @action = @ctcp_type.downcase == 'action' else @message = end botnick = Models::Nick.filter(:botnick => true).first if(botnick) @addressed = @message =~ /^#{botnick.nick}/i else @addressed = false end end |
Instance Attribute Details
#ctcp ⇒ Object (readonly)
message is CTCP
12 13 14 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 12 def ctcp @ctcp end |
#ctcp_type ⇒ Object (readonly)
message CTCP type
14 15 16 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 14 def ctcp_type @ctcp_type 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
39 40 41 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 39 def addressed? return @addressed || is_private? end |
#is_action? ⇒ Boolean
Is this message an action message
74 75 76 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 74 def is_action? @action end |
#is_colored? ⇒ Boolean
Does the message contain colors
59 60 61 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 59 def is_colored? return @message =~ /\cC\d\d?(?:,\d\d?)?/ end |
#is_ctcp? ⇒ Boolean
78 79 80 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 78 def is_ctcp? @ctcp end |
#is_dcc? ⇒ Boolean
Is this a DCC message
49 50 51 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 49 def is_dcc? return @target.is_a?(String) end |
#is_private? ⇒ Boolean
Is this is private message
44 45 46 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 44 def is_private? return !is_public? end |
#is_public? ⇒ Boolean
Is this a public message
54 55 56 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 54 def is_public? return @target.is_a?(Models::Channel) end |
#message(color = false) ⇒ Object
the message sent
69 70 71 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 69 def (color=false) return color ? @message : end |
#message_nocolor ⇒ Object
Message with coloring stripped
64 65 66 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 64 def return @message.gsub(/\cC\d\d?(?:,\d\d?)?/, '').tr("\x00-\x1f", '') end |
#replyto ⇒ Object
Convinence method for replying to the correct place
83 84 85 |
# File 'lib/mod_spox/messages/incoming/Privmsg.rb', line 83 def replyto return is_public? || is_dcc? ? @target : @source end |