class BotPolicy
  attr_reader :user, :model

  def initialize(user, model)
    @user = user || User.new
    @bot = model
  end

  class Scope
    def initialize(user, scope)
      @user  = user
      @scope = scope
    end

    def resolve
      if user.admin?
        scope.all
      else
        scope.all
      end
    end

    private

    attr_reader :user, :scope
  end

  def index?
    @user.admin?
  end

  def show?
    @user.admin? || @user == @bot.user
  end

  # TODO: Restrict bot start but for now open to all
  def telegram_listen?
    @user.admin? || @user == @bot.user || true
  end


  def new?
    @user.admin?
  end

  def create?
    @user.admin?
  end

  def edit?
    @user.admin? || @user == @bot.user
  end

  def update?
    @user.admin? || @user == @bot.user
  end

  def destroy?
    @user.admin? || @user == @bot.user
  end
end
