Class: YAIB::Message
- Inherits:
-
Object
- Object
- YAIB::Message
- Defined in:
- lib/yaib/message.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(rawmsg, bot) ⇒ Message
constructor
A new instance of Message.
- #parse(rawmsg) ⇒ Object
- #privmsg(s) ⇒ Object
Constructor Details
#initialize(rawmsg, bot) ⇒ Message
Returns a new instance of Message.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/yaib/message.rb', line 5 def initialize(rawmsg, bot) @message, rawchan, rawuser = parse(rawmsg) if rawchan == bot.config.nick then @channel = bot.return_user rawuser, rawuser @user = @channel else @channel = bot.channels[rawchan] @user = bot.return_user rawuser, rawchan end end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
3 4 5 |
# File 'lib/yaib/message.rb', line 3 def channel @channel end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/yaib/message.rb', line 3 def @message end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'lib/yaib/message.rb', line 3 def user @user end |
Instance Method Details
#parse(rawmsg) ⇒ Object
16 17 18 |
# File 'lib/yaib/message.rb', line 16 def parse(rawmsg) [rawmsg.scan(/.* PRIVMSG .*? \:(.*)/).join, rawmsg.scan(/.* PRIVMSG (.*?) \:.*/).join, rawmsg.split(/\!/)[0].sub(/^\:/,'')] end |
#privmsg(s) ⇒ Object
20 21 22 |
# File 'lib/yaib/message.rb', line 20 def privmsg(s) @channel.privmsg(s) end |