Sha256: 898d12df940b97f39b34ef6df06b18a0d77acc779a56566009eee647f36768b0

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

class SlackSmartBot
  # help: ----------------------------------------------
  # help: `see repls`
  # help: `see irbs`
  # help:    It will display the repls
  # help:
  def see_repls(dest, user, typem)
    #todo: add tests
    save_stats(__method__)
    from = user.name
    if config[:allow_access].key?(__method__) and !config[:allow_access][__method__].include?(user.name) and !config[:allow_access][__method__].include?(user.id) and 
      (!user.key?(:enterprise_user) or ( user.key?(:enterprise_user) and !config[:allow_access][__method__].include?(user[:enterprise_user].id)))
      respond "You don't have access to use this command, please contact an Admin to be able to use it: <@#{config.admins.join(">, <@")}>"
    else
      message = ""
      @repls.sort.to_h.each do |session_name, repl|
        if (repl.creator_name == user.name or repl.type == :public) or (config.admins.include?(user.name) and typem == :on_dm)
          message += "(#{repl.type}) *#{session_name}*: #{repl.description} / created: #{repl.created} / accessed: #{repl.accessed} / creator: #{repl.creator} / runs: #{repl.runs_by_creator+repl.runs_by_others} / gets: #{repl.gets} \n"
        end
      end
      message = "No repls created" if message == ''
      respond message
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
slack-smart-bot-1.6.6 lib/slack/smart-bot/commands/on_bot/see_repls.rb
slack-smart-bot-1.6.5 lib/slack/smart-bot/commands/on_bot/see_repls.rb
slack-smart-bot-1.6.4 lib/slack/smart-bot/commands/on_bot/see_repls.rb
slack-smart-bot-1.6.3 lib/slack/smart-bot/commands/on_bot/see_repls.rb
slack-smart-bot-1.6.2 lib/slack/smart-bot/commands/on_bot/see_repls.rb
slack-smart-bot-1.6.1 lib/slack/smart-bot/commands/on_bot/see_repls.rb