Class: MadChatter::MessageListeners::Video
- Inherits:
-
Object
- Object
- MadChatter::MessageListeners::Video
show all
- Includes:
- Actions
- Defined in:
- lib/mad_chatter/message_listeners/video.rb
Constant Summary
collapse
- @@youtube =
%r{^/youtube http://youtu.be/(.*)$}
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/video.rb', line 9
def handle(message)
if message.original_text =~ @@youtube
youtube_id = parse_youtube_id(message.original_text)
img_msg = MadChatter::Message.new('message', nil, message.token, message.channel)
img_msg.html = "<iframe width='560' height='315' src='http://www.youtube.com/embed/#{youtube_id}' frameborder='0' allowfullscreen></iframe>"
img_msg.growl = message.username + ' has shared a YouTube video'
MadChatter.send_message(message)
stop_message_handling
end
end
|
#parse_youtube_id(text) ⇒ Object
20
21
22
|
# File 'lib/mad_chatter/message_listeners/video.rb', line 20
def parse_youtube_id(text)
@@youtube.match(text).captures[0]
end
|