Class: CeilingCat::Plugin::About

Inherits:
Base
  • Object
show all
Defined in:
lib/ceiling_cat/plugins/about.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, #handle, #initialize, #pluralize, #reply, #room, store, #store, #user, #words

Constructor Details

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

Class Method Details

.commandsObject



4
5
6
7
8
9
# File 'lib/ceiling_cat/plugins/about.rb', line 4

def self.commands
  [{:command => "plugins", :description => "List of installed plugins.", :method => "list_plugins"},
   {:command => "commands", :description => "List of available commands.", :method => "list_commands", :public => true},
   {:command => "users", :description => "List of registered in the room.", :method => "list_users", :public => true},
   {:command => "guests", :description => "List of guests in the room.", :method => "list_guests", :public => true}]
end

.descriptionObject



11
12
13
# File 'lib/ceiling_cat/plugins/about.rb', line 11

def self.description
  "About the currently running Ceiling Cat"
end

.nameObject



15
16
17
# File 'lib/ceiling_cat/plugins/about.rb', line 15

def self.name
  "About"
end

.public?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ceiling_cat/plugins/about.rb', line 19

def self.public?
  true
end

Instance Method Details

#list_commandsObject



27
28
29
30
31
# File 'lib/ceiling_cat/plugins/about.rb', line 27

def list_commands
  messages = room.available_commands(user.is_registered?) # Show all commands if the user is registered, otherwise only show private commands
  messages << "Run commands with '![command]' or '#{room.me.name}: [command]'"
  reply messages
end

#list_guestsObject



42
43
44
45
46
47
48
49
# File 'lib/ceiling_cat/plugins/about.rb', line 42

def list_guests
  guests = room.users_in_room(:type => "guest")
  if guests.size > 0
    reply "#{room.list_of_users_in_room(:type => "guest")} #{pluralize(guests.size, "is a", "are")} #{pluralize(guests.size, "guest")}."
  else
    reply "There are no guests in the room at this time."
  end
end

#list_pluginsObject



23
24
25
# File 'lib/ceiling_cat/plugins/about.rb', line 23

def list_plugins
  reply room.plugin_descriptions(user.is_registered?)
end

#list_usersObject



33
34
35
36
37
38
39
40
# File 'lib/ceiling_cat/plugins/about.rb', line 33

def list_users
  members = room.users_in_room(:type => "member")
  if members.size > 0
    reply "#{room.list_of_users_in_room(:type => "member")} #{pluralize(members.size, "is a", "are")} #{pluralize(members.size, "registered user")}."
  else
    reply "There are no registered users in the room at this time."
  end
end