Class: CeilingCat::Plugin::Greeter

Inherits:
Base
  • Object
show all
Defined in:
lib/ceiling_cat/plugins/greeter.rb

Instance Attribute Summary

Attributes inherited from Base

#event

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#body, #body_without_command, #body_without_nick, #body_without_nick_or_command, #commands, commands, #initialize, #pluralize, public?, #reply, #room, store, #store, #user, #words

Constructor Details

This class inherits a constructor from CeilingCat::Plugin::Base

Class Method Details

.descriptionObject



25
26
27
# File 'lib/ceiling_cat/plugins/greeter.rb', line 25

def self.description
  "Welcomes visitors and memebrs to chat."
end

.nameObject



21
22
23
# File 'lib/ceiling_cat/plugins/greeter.rb', line 21

def self.name
  "Greeter"
end

Instance Method Details

#handleObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ceiling_cat/plugins/greeter.rb', line 4

def handle
  messages = []

  if event.type == :entrance
    members = room.users_in_room(:type => "member")
    guests = room.users_in_room(:type => "guest")
    if user.is_guest?
      messages << "Hey #{user.name}!"
    elsif user.is_registered?
      messages << "Nice to see you again #{user.name}"
    end
    reply messages unless messages.empty?
  elsif event.type == :chat
    super
  end
end