Class: MadChatter::MessageListeners::Image
- Inherits:
-
Object
- Object
- MadChatter::MessageListeners::Image
show all
- Includes:
- Actions
- Defined in:
- lib/mad_chatter/message_listeners/image.rb
Constant Summary
collapse
- @@regex =
%r{^/img (.+)}
Instance Method Summary
collapse
Methods included from Actions
#send_action, #send_message, #send_status_message, #stop_message_handling
Instance Method Details
#handle(message) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/mad_chatter/message_listeners/image.rb', line 9
def handle(message)
if message.text =~ @@regex
img_url = parse_url(message.text)
img_msg = MadChatter::Message.new('message', img_url, message.token, message.channel)
img_msg.html = "<img src='#{img_url}'>"
img_msg.growl = message.username + ' has shared an image'
MadChatter.send_message(message)
stop_message_handling
end
end
|
#parse_url(message_text) ⇒ Object
20
21
22
|
# File 'lib/mad_chatter/message_listeners/image.rb', line 20
def parse_url(message_text)
@@regex.match(message_text).captures[0]
end
|