Sha256: 95a2f9562ebd5ae0e1e04df10f1079f4c4ae3cffad8c9b0c38ba86658e45d68a

Contents?: true

Size: 1.95 KB

Versions: 10

Compression:

Stored size: 1.95 KB

Contents

class SlackSmartBot
  # helpadmin: ----------------------------------------------
  # helpadmin: `bot status`
  # helpadmin:    Displays the status of the bot
  # helpadmin:    If on master channel and admin user also it will display info about bots created
  # helpadmin:
  def bot_status(dest, from)
    get_bots_created()
    gems_remote = `gem list slack-smart-bot --remote`
    version_remote = gems_remote.to_s().scan(/slack-smart-bot \((\d+\.\d+\.\d+)/).join
    version_message = ""
    if version_remote != VERSION
      version_message = " There is a new available version: #{version_remote}."
    end
    require "socket"
    ip_address = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address
    respond "*#{Socket.gethostname} (#{ip_address})*\n\tStatus: #{@status}.\n\tVersion: #{VERSION}.#{version_message}\n\tRules file: #{File.basename config.rules_file}\n\tExtended: #{@bots_created[@channel_id][:extended] unless config.on_master_bot}\n\tAdmins: #{config.admins}\n\tBot time: #{Time.now}", dest
    if @status == :on
      respond "I'm listening to [#{@listening.join(", ")}]", dest
      if config.on_master_bot and config.admins.include?(from)
        sleep 5
        @bots_created.each do |k, v|
          msg = []
          msg << "`#{v[:channel_name]}` (#{k}):"
          msg << "\tcreator: #{v[:creator_name]}"
          msg << "\tadmins: #{v[:admins]}"
          msg << "\tstatus: #{v[:status]} #{" *(not responded)*" unless @pings.include?(v[:channel_name])}"
          msg << "\tcreated: #{v[:created]}"
          msg << "\trules: #{v[:rules_file]}"
          msg << "\textended: #{v[:extended]}"
          msg << "\tcloud: #{v[:cloud]}"
          if config.on_master_bot and v.key?(:cloud) and v[:cloud]
            msg << "\trunner: `ruby #{config.file} \"#{v[:channel_name]}\" \"#{v[:admins]}\" \"#{v[:rules_file]}\" on&`"
          end
          respond msg.join("\n"), dest
        end
        @pings = []
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
slack-smart-bot-1.4.3 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.4.2 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.4.1 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.4.0 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.3.1 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.3.0 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.2.0 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.1.2 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.1.1 lib/slack/smart-bot/commands/general/bot_status.rb
slack-smart-bot-1.1.0 lib/slack/smart-bot/commands/general/bot_status.rb