Sha256: e25c096a33eabd1933403aefde54dfccbf067bfe4b7bfa29233f7678c8bb40d3

Contents?: true

Size: 1.03 KB

Versions: 43

Compression:

Stored size: 1.03 KB

Contents

module Plugins
  class BotHelp
    include Cinch::Plugin
    include Cinch::Helpers
    enable_acl

    set(
        plugin_name: "BotHelp",
        help: "Need help?.\nUsage: `?help`\nUsage: `?help [plugin]` `?help plugins`",
    )
    match /help (.+)$/i, method: :execute_help

    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.") unless list.has_key?(name.downcase)
      m.user.notice("Help for #{Format(:bold, list[name.downcase][:name])}:\n#{list[name.downcase][:help]}")
    end

    match 'help', method: :execute_list
    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 `!help <plugin name>`.")
    end
  end
end


# AutoLoad
Bot.config.plugins.plugins.push Plugins::BotHelp

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
zetabot-2.1.2 lib/Zeta/plugins/help.rb
zetabot-2.1.1 lib/Zeta/plugins/help.rb
zetabot-2.1.0 lib/Zeta/plugins/help.rb
zetabot-2.0.9 lib/Zeta/plugins/help.rb
zetabot-2.0.8 lib/Zeta/plugins/help.rb
zetabot-2.0.7 lib/Zeta/plugins/help.rb
zetabot-2.0.6 lib/Zeta/plugins/help.rb
zetabot-2.0.5 lib/Zeta/plugins/help.rb
zetabot-2.0.4 lib/Zeta/plugins/help.rb
zetabot-2.0.3 lib/Zeta/plugins/help.rb
zetabot-2.0.2 lib/Zeta/plugins/help.rb
zetabot-2.0.1 lib/Zeta/plugins/help.rb
zetabot-2.0.0 lib/Zeta/plugins/help.rb
zetabot-1.1.0 lib/Zeta/plugins/help.rb
zetabot-1.0.7 lib/Zeta/plugins/help.rb
zetabot-1.0.6 lib/Zeta/plugins/help.rb
zetabot-1.0.5 lib/Zeta/plugins/help.rb
zetabot-1.0.4 lib/Zeta/plugins/help.rb
zetabot-1.0.3 lib/Zeta/plugins/help.rb
zetabot-1.0.2 lib/Zeta/plugins/help.rb