diff --git a/lib/adapter/question.py b/lib/adapter/question.py index f872f00..56bf9ab 100644 --- a/lib/adapter/question.py +++ b/lib/adapter/question.py @@ -39,6 +39,8 @@ If the problem persists, file a GitHub issue at github.com/chubin/cheat.sh or ping @igor_chubin """ +NOT_AUTHORIZED_MESSAGE = """403 UNAUTHORIZED" + class Question(UpstreamAdapter): """ @@ -111,6 +113,12 @@ class Question(UpstreamAdapter): else: topic = [topic] + if request_option.get("action") == "suggest": + if request_option.get("authorized"): + topic = ["--action", "suggest"] + topic + else: + return NOT_AUTHORIZED_MESSAGE + cmd = [CONFIG["path.internal.bin.upstream"]] + topic proc = Popen(cmd, stdin=open(os.devnull, "r"), stdout=PIPE, stderr=PIPE) answer = proc.communicate()[0].decode('utf-8')