Sha256: b33269c03202b9b507682f0a6324f2356758fb44b1bb85a7a381fb75152d816a

Contents?: true

Size: 1.76 KB

Versions: 17

Compression:

Stored size: 1.76 KB

Contents

class SlackSmartBot
  # helpmaster: ----------------------------------------------
  # helpmaster: `kill bot on CHANNEL_NAME`
  # helpmaster:    kills the bot on the specified channel
  # helpmaster:    Only works if you are on Master channel and you created that bot or you are an admin user
  # helpmaster:
  def kill_bot_on_channel(dest, from, channel)
    save_stats(__method__)
    if config.on_master_bot
      get_channels_name_and_id() unless @channels_name.keys.include?(channel) or @channels_id.keys.include?(channel)
      channel_id = nil
      if @channels_name.key?(channel) #it is an id
        channel_id = channel
        channel = @channels_name[channel_id]
      elsif @channels_id.key?(channel) #it is a channel name
        channel_id = @channels_id[channel]
      end
      if channel_id.nil?
        respond "There is no channel with that name: #{channel}, please be sure is written exactly the same", dest
      elsif @bots_created.keys.include?(channel_id)
        if @bots_created[channel_id][:admins].split(",").include?(from)
          if @bots_created[channel_id][:thread].kind_of?(Thread) and @bots_created[channel_id][:thread].alive?
            @bots_created[channel_id][:thread].kill
          end
          @bots_created.delete(channel_id)
          update_bots_file()
          respond "Bot on channel: #{channel}, has been killed and deleted.", dest
          send_msg_channel(channel, "Bot has been killed by #{from}")
        else
          respond "You need to be the creator or an admin of that bot channel", dest
        end
      else
        respond "There is no bot in this channel: #{channel}", dest
      end
    else
      respond "Sorry I cannot kill bots from this channel, please visit the master channel: <##{@master_bot_id}>", dest
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
slack-smart-bot-1.9.2 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.9.1 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.8.2 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.8.1 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.8.0 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.7.0 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.8 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.7 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.6 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.5 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.4 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.3 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.2 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.1 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.6.0 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.5.1 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
slack-smart-bot-1.5.0 lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb