Class: MadChatter::MessageListeners::Code
- Inherits:
-
Object
- Object
- MadChatter::MessageListeners::Code
show all
- Includes:
- Actions
- Defined in:
- lib/mad_chatter/message_listeners/code.rb
Instance Method Summary
collapse
Methods included from Actions
#send_action, #send_message, #send_status_message, #stop_message_handling
Instance Method Details
#handle(msg) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/mad_chatter/message_listeners/code.rb', line 7
def handle(msg)
if msg.original_text =~ %r{^/code (.+)}
code = parse(msg.original_text)
message = MadChatter::Message.new('message', nil, msg.token, msg.channel)
message.html = "<pre>" + message.filter(code) + "</pre>"
message.growl = msg.username + ' has shared a code sample' if msg.username
MadChatter.send_message(message)
stop_message_handling
end
end
|
#parse(text) ⇒ Object
18
19
20
|
# File 'lib/mad_chatter/message_listeners/code.rb', line 18
def parse(text)
text.sub!('/code', '')
end
|