Class: CeilingCat::Plugin::CampfireAccountMonitor
- Defined in:
- lib/ceiling_cat/plugins/campfire_account_monitor.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.commands ⇒ Object
If you want the plugin to run when certain text is sent use commands instead of handle.
- .description ⇒ Object
- .name ⇒ Object
- .public? ⇒ Boolean
Instance Method Summary collapse
-
#handle ⇒ Object
handle manages a plugin’s entire interaction with an event.
- #total_users ⇒ Object
Methods inherited from Base
#body, #body_without_command, #body_without_nick, #body_without_nick_or_command, #commands, #initialize, #pluralize, #reply, #room, #store, store, #user, #words
Constructor Details
This class inherits a constructor from CeilingCat::Plugin::Base
Class Method Details
.commands ⇒ Object
If you want the plugin to run when certain text is sent use commands instead of handle. Ceiling Cat will watch for “![command]” or “[name]: [command” and execute the method for that command.
24 25 26 |
# File 'lib/ceiling_cat/plugins/campfire_account_monitor.rb', line 24 def self.commands [{:command => "total users", :description => "Gets the total number of current users in chat", :method => "total_users", :public => false}] end |
.description ⇒ Object
28 29 30 |
# File 'lib/ceiling_cat/plugins/campfire_account_monitor.rb', line 28 def self.description "For monitoring Campfire connection limits" end |
.name ⇒ Object
32 33 34 |
# File 'lib/ceiling_cat/plugins/campfire_account_monitor.rb', line 32 def self.name "Campfire account monitor" end |
.public? ⇒ Boolean
36 37 38 |
# File 'lib/ceiling_cat/plugins/campfire_account_monitor.rb', line 36 def self.public? false end |
Instance Method Details
#handle ⇒ Object
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 |
# File 'lib/ceiling_cat/plugins/campfire_account_monitor.rb', line 11 def handle if room.connection.config.service.downcase == "campfire" && event.type == :entrance user_count = room.connection.total_user_count max_users = room.connection.config.max_users || 100 if room.plugin_installed?("notifo") && user_count > max_users-2 room.plugin("notifo").new(@event).deliver("#{user_count} of #{max_users} max connections to Campfire.") end end super end |
#total_users ⇒ Object
40 41 42 43 44 |
# File 'lib/ceiling_cat/plugins/campfire_account_monitor.rb', line 40 def total_users if room.connection.config.service.downcase == "campfire" reply "#{room.connection.total_user_count} connections currently used" end end |