Sha256: 1b206ae9ad1cac9f22cec149b0979b9e9232598736d068fef7a029be932f9591

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

class SlackSmartBot

  # helpadmin: ----------------------------------------------
  # helpadmin: `exit bot`
  # helpadmin: `quit bot`
  # helpadmin: `close bot`
  # helpadmin:    The bot stops running and also stops all the bots created from this master channel
  # helpadmin:    You can use this command only if you are an admin user and you are on the master channel
  # helpadmin:
  def exit_bot(command, from, dest, display_name)
    if ON_MASTER_BOT
      if ADMIN_USERS.include?(from) #admin user
        unless @questions.keys.include?(from)
          ask("are you sure?", command, from, dest)
        else
          case @questions[from]
          when /yes/i, /yep/i, /sure/i
            respond "Game over!", dest
            respond "Ciao #{display_name}!", dest
            @bots_created.each { |key, value|
              value[:thread] = ""
              send_msg_channel(key, "Bot has been closed by #{from}")
              sleep 0.5
            }
            update_bots_file()
            sleep 0.5
            exit!
          when /no/i, /nope/i, /cancel/i
            @questions.delete(from)
            respond "Thanks, I'm happy to be alive", dest
          else
            ask("I don't understand, are you sure do you want me to close? (yes or no)", command, from, dest)
          end
        end
      else
        respond "Only admin users can kill me", dest
      end
    else
      respond "To do this you need to be an admin user in the master channel: <##{@master_bot_id}>", dest
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.0.2 lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb
slack-smart-bot-1.0.1 lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb
slack-smart-bot-1.0.0 lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb