Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from muharamdani/refactor/call-formkey-and-cook…
Browse files Browse the repository at this point in the history
…ie-form-env-file

Refactor | Update readme, call formkey and cookie form env file
  • Loading branch information
muharamdani authored Mar 4, 2023
2 parents faf5a45 + 663cefe commit e73d4c9
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
QUORA_FORMKEY=your_formkey
MB_COOKIE=your_cookie
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.idea
config.json
.env
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Quora Poe

- Since it
This is a CLI tool to call the Quora Poe API through GraphQL. It is a work in progress, and currently only supports the following:
- Chat with 3 types of bots (Claude, Capybara, and Nutria)
- Clear the chat history

## Installation

To install this app, run:
- Copy the .env.example file to .env and fill in the required fields
- Run the following command to install the dependencies:

```
npm install
Expand All @@ -20,9 +21,11 @@ npm start

## Requirements

To use this API, you will need to have the following cookies:
- Quora-Formkey: This is obtained by logging in to Quora.com, viewing the page source, and finding the "formkey" dictionary key. Use its value in the Quora-Formkey field.
To use this API, you will need to have the following:
- Quora-Formkey: This is obtained by logging in to Quora.com, viewing the page source, and finding the "formkey" dictionary key.
- Cookie: 'm-b=xxxx' - This is the value of the cookie with the key m-b, which is present in the list of cookies used on Quora.com, you can simply inspect cookies in Chrome to get it.
- Put the above two in a .env file in the root directory of the project

Note: Next plan is to semi automate this things

## Dependencies
Expand All @@ -39,5 +42,7 @@ Note: Next plan is to semi automate this things
- prompts

## Contributing
Since I do not own apple devices, I am unable to reverse engineer the app to find the endpoints/requests made by the app.
If you are able to do so, please contribute to this repo by adding new features or fixing bugs.

To contribute to this repo, fork first and create a pull request.
10 changes: 8 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import makeSession from "fetch-cookie";
import fetch from "cross-fetch";
import prompts from "prompts";
import ora from "ora";
import * as dotenv from "dotenv";
import { readFileSync } from "fs";
dotenv.config();
const spinner = ora({
color: "cyan",
});
Expand Down Expand Up @@ -32,8 +34,8 @@ class ChatBot {
"apollographql-client-name": "com.quora.app.Experts-apollo-ios",
"Connection": "keep-alive",
"Content-Type": "application/json",
"Quora-Formkey": "fil this",
"Cookie": "fill this"
"Quora-Formkey": process.env.QUORA_FORMKEY || "",
"Cookie": process.env.MB_COOKIE || "",
},
}),
cache: new InMemoryCache(),
Expand All @@ -60,8 +62,12 @@ class ChatBot {
{ title: "Claude - a2", value: "a2" },
{ title: "Capybara (logical)", value: "capybara" },
{ title: "Nutria (simpler)", value: "nutria" },
{ title: "exit", value: "exit" }
],
});
if (bot === "exit") {
return;
}
await this.getChatId(bot);
let helpMsg = "Available commands: !help !exit, !clear, !submit" +
"\n!help - show this message" +
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"cheerio": "^1.0.0-rc.12",
"cli-spinners": "^2.7.0",
"cross-fetch": "^3.1.5",
"dotenv": "^16.0.3",
"fetch-cookie": "^2.1.0",
"graphql": "^16.6.0",
"graphql-tag": "^2.12.6",
Expand Down
16 changes: 12 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import makeSession from "fetch-cookie";
import fetch from "cross-fetch";
import prompts from "prompts";
import ora from "ora";
import https from 'https';
import {readFileSync, writeFile} from "fs";
import * as dotenv from "dotenv";
import {readFileSync} from "fs";

dotenv.config();

const spinner = ora({
color: "cyan",
Expand Down Expand Up @@ -36,8 +38,8 @@ class ChatBot {
"apollographql-client-name": "com.quora.app.Experts-apollo-ios",
"Connection": "keep-alive",
"Content-Type": "application/json",
"Quora-Formkey": "fil this",
"Cookie": "fill this"
"Quora-Formkey": process.env.QUORA_FORMKEY || "",
"Cookie": process.env.MB_COOKIE || "",
},
}),
cache: new InMemoryCache(),
Expand Down Expand Up @@ -65,8 +67,14 @@ class ChatBot {
{title: "Claude - a2", value: "a2"},
{title: "Capybara (logical)", value: "capybara"},
{title: "Nutria (simpler)", value: "nutria"},
{title: "exit", value: "exit"}
],
});

if (bot === "exit") {
return;
}

await this.getChatId(bot);

let helpMsg = "Available commands: !help !exit, !clear, !submit" +
Expand Down

0 comments on commit e73d4c9

Please sign in to comment.