chatgpt-irc - chatgpt via irc
git clone https://github.com/rj1/chatgpt-irc
commit 144cd63944abf2433f3aa6a388d7f809bbb693c9 parent 9fa57015e75a4b3c4b237d5e69563609d909835d author: rj1 <[email protected]> date: Mon, 30 Jan 2023 02:57:57 -0600 added useragent as a config option Diffstat:
M | README.md | | | 5 | +++-- |
M | chatgpt-irc.py | | | 3 | ++- |
M | example-config.json | | | 3 | ++- |
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md @@ -7,7 +7,7 @@ chat with chatgpt on irc! - head to the [chatgpt website](https://chat.openai.com/chat) and sign in - open the network tab in devtools (press F12) - say "hi" to chatgpt -- collect your auth token and cookie from the *headers* tab +- collect your auth token, user agent, and cookie from the *headers* tab - create `config.json` using [the example configuration](#example-config) below or by copying `example-config.json` - run the bot: `python chatgpt-irc.py` @@ -26,6 +26,7 @@ chat with chatgpt on irc! "realname": "chatgpt", "channels": ["#rj1"], "auth_token": "", - "cookie" "" + "cookie" "", + "useragent": "" } ``` diff --git a/chatgpt-irc.py b/chatgpt-irc.py @@ -10,6 +10,7 @@ class ChatGPT: def __init__(self): self.auth_token = options["auth_token"] self.cookie = options['cookie'] + self.useragent = options['useragent'] self.conversation_id = "" self.parent_message_id = str(uuid.uuid4()) self.message_id = self.parent_message_id @@ -48,7 +49,7 @@ class ChatGPT: "Authorization": f"Bearer {self.auth_token}", "Content-Type": "application/json", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", + "User-Agent": self.useragent, "Cookie": self.cookie, "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8", "Accept-Encoding": "gzip, deflate, br", diff --git a/example-config.json b/example-config.json @@ -7,5 +7,6 @@ "realname": "chatgpt", "channels": ["#rj1"], "auth_token": "", - "cookie": "" + "cookie": "", + "useragent": "" }