Class: Plugins::BotInfo
- Inherits:
-
Object
- Object
- Plugins::BotInfo
- Includes:
- Cinch::Helpers, Cinch::Plugin
- Defined in:
- lib/Zeta/plugins/botinfo.rb
Instance Method Summary collapse
-
#execute(m) ⇒ Object
Methods.
- #execute_help(m, name) ⇒ Object
- #execute_list(m) ⇒ Object
-
#initialize(*args) ⇒ BotInfo
constructor
A new instance of BotInfo.
Methods included from Cinch::Plugin
Constructor Details
#initialize(*args) ⇒ BotInfo
Returns a new instance of BotInfo.
20 21 22 23 |
# File 'lib/Zeta/plugins/botinfo.rb', line 20 def initialize *args super @started_at = Time.now end |
Instance Method Details
#execute(m) ⇒ Object
Methods
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/Zeta/plugins/botinfo.rb', line 36 def execute(m) = { bot_name: @bot.nick, cinch_version: Cinch::VERSION, #is_admin: config[:admins].is_admin?(m.user.mask) ? "an admin" : "not an admin", owner_name: 'Liothen', plugins_count_remaining: @bot.plugins.length - 10, plugins_head: @bot.plugins[0..9].map {|p| p.class.plugin_name }.join(", "), ruby_platform: RUBY_PLATFORM, ruby_release_date: RUBY_RELEASE_DATE, ruby_version: RUBY_VERSION, session_start_date: @started_at.strftime("%A, %B %e, %Y, at %l:%M:%S %P"), total_channels: @bot.channels.length, total_users: proc { users = [] @bot.channels.each {|c| c.users.each {|u| users << u[0].nick } } users.uniq.size }.call, uptime: ChronicDuration.output(Time.now.to_i - @started_at.to_i) } tf = TagFormatter.new open(File.join(__dir__, '../botinfo.txt'),&:read), tags: m.user.notice tf.parse end |
#execute_help(m, name) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/Zeta/plugins/botinfo.rb', line 72 def execute_help(m, name) list = {} @bot.plugins.each {|p| list[p.class.plugin_name.downcase] = {name: p.class.plugin_name, help: p.class.help} }; return m.user.notice("Help for \"#{name}\" could not be found.") if !list.has_key?(name.downcase) m.user.notice("Help for #{Format(:bold,list[name.downcase][:name])}:\n#{list[name.downcase][:help]}") end |
#execute_list(m) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/Zeta/plugins/botinfo.rb', line 65 def execute_list(m) list = [] @bot.plugins.each {|p| list << p.class.plugin_name }; m.user.notice("All #{list.size} currently loaded plugins for #{@bot.nick}:\n#{list.to_sentence}.\nTo view help for a plugin, use `/msg #{@bot.nick} help <plugin name>`.") end |