Sha256: 2303a058f9b0df2e8dbe228f01abfa27a854d30ee0e45492d60791feb76b67f2

Contents?: true

Size: 955 Bytes

Versions: 43

Compression:

Stored size: 955 Bytes

Contents

module Admin
  class Bot
    include Cinch::Plugin
    include Cinch::Helpers

    enable_acl(:oper)

    set(
        plugin_name: "BotAdmin",
        help: "Bot administrator-only private commands.\nUsage: `~nick [channel]`;",
    )

    # Regex
    match /set nick (.+)/, method: :nick
    match /set mode (.+)/, method: :mode
    match /die(?: (.+))?/, method: :quit, group: :quit

    # Methods
    def nick(m, nick)
      bot.nick = nick
      synchronize(:nickchange) do
        @bot.handlers.dispatch :admin, m, "My nick got changed from #{@bot.last_nick} to #{@bot.nick} by #{m.user.nick}", m.target
      end
    end

    def mode(m, nick)
      bot.modes = m
    end

    def quit(m, msg=nil)
      msg ||= m.user.nick
      @bot.handlers.dispatch :admin, m, "I am being shut down NOW!#{" - Reason: " + msg unless msg.nil?}", m.target
      sleep 2
      bot.quit(msg)
    end


  end
end


# AutoLoad
Bot.config.plugins.plugins.push Admin::Bot

Version data entries

43 entries across 43 versions & 1 rubygems

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