Sha256: 256dce21c6749b04585940fee9d1811759d37eada426c443226317ebf74e6cb6

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

class SlackSmartBot

  # helpadmin: ----------------------------------------------
  # helpadmin: `kill routine NAME`
  # helpadmin: `delete routine NAME`
  # helpadmin: `remove routine NAME`
  # helpadmin:    It will kill and remove the specified routine
  # helpadmin:    You can use this command only if you are an admin user
  # helpadmin:    NAME: one word to identify the routine
  # helpadmin:    Examples:
  # helpadmin:      _kill routine example_
  # helpadmin:    <https://github.com/MarioRuiz/slack-smart-bot#routines|more info>
  # helpadmin:
  def remove_routine(dest, from, name)
    save_stats(__method__)
    if config.admins.include?(from) #admin user
      if @routines.key?(@channel_id) and @routines[@channel_id].key?(name)
        @routines[@channel_id][name][:thread].exit
        @routines[@channel_id].delete(name)
        update_routines()
        respond "The routine *`#{name}`* has been removed.", dest
      else
        respond "There isn't a routine with that name: *`#{name}`*.\nCall `see routines` to see added routines", dest
      end
    else
      respond "Only admin users can delete routines", dest
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack-smart-bot-1.10.0 lib/slack/smart-bot/commands/on_bot/admin/remove_routine.rb