# File lib/rbot/core/auth.rb, line 232
  def auth_allow_deny(m, p)
    begin
      botuser = @bot.auth.get_botuser(p[:user].sub(/^all$/,"everyone"))
    rescue
      return m.reply(_("couldn't find botuser %{name}") % {:name => p[:user]})
    end

    if p[:where].to_s.empty?
      where = :*
    else
      where = m.parse_channel_list(p[:where].to_s).first # should only be one anyway
    end

    # pseudo-message to find the template. The source is ignored, and the
    # target is set according to where the template should be checked
    # (public or private)
    # This might still fail in the case of 'everywhere' for commands there are
    # really only private
    case where
    when "?""?"
      pseudo_target = @bot.myself
    when :*
      pseudo_target = m.channel
    else
      pseudo_target = m.server.channel(where)
    end

    pseudo = PrivMessage.new(bot, m.server, m.source, pseudo_target, p[:stuff].to_s)

    auth_path = find_auth(pseudo)
    debug auth_path

    if auth_path
      allow = p[:allow]
      if @bot.auth.permit?(botuser, auth_path, where)
        return m.reply(_("%{user} can already do that") % {:user => botuser}) if allow
      else
        return m.reply(_("%{user} can't do that already") % {:user => botuser}) if !allow
      end
      cmd = PrivMessage.new(bot, m.server, m.source, m.target, "permissions set %{sign}%{path} %{where} for %{user}" % {
        :path => auth_path,
        :user => p[:user],
        :sign => (allow ? '+' : '-'),
        :where => p[:where].to_s
      })
      handle(cmd)
    else
      m.reply(_("sorry, %{cmd} doesn't look like a valid command. maybe you misspelled it, or you need to specify it should be in private?") % {
        :cmd => p[:stuff].to_s
      })
    end
  end