Method: CeilingCat::Plugin::Messages#handle

Defined in:
lib/ceiling_cat/plugins/messages.rb

#handleObject

handle manages a plugin’s entire interaction with an event. If you only want to execute commands - “![command]” - leave handle alone (or remove it and define commands below)



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ceiling_cat/plugins/messages.rb', line 11

def handle
  if event.type == :entrance
    messages = []
    messages_for_user = self.class.messages_for(user.name)
    if messages_for_user.size > 0
      messages << "Hey #{user.name}! I have a message to deliver to you:"
      messages += messages_for_user.collect{|message| "From #{message[:from]}: #{message[:body]}"}
      reply messages
    end
    self.class.remove(messages_for_user)
    false
  else
    super
  end
end