rj1
about | log | files | refs | license
commit 9fa57015e75a4b3c4b237d5e69563609d909835d
parent 7bc5404c17135c16ffc49202126da1a6a8519e5a
author: rj1 <[email protected]>
date:   Sat, 24 Dec 2022 11:46:31 -0600

chat.openai.com now requires cookie for cloudflare waf

Diffstat:
MREADME.md | 3++-
Mchatgpt-irc.py | 3+++
Mexample-config.json | 3++-
3 files changed, 7 insertions(+), 2 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 from the *headers* tab +- collect your auth token 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,5 +26,6 @@ chat with chatgpt on irc! "realname": "chatgpt", "channels": ["#rj1"], "auth_token": "", + "cookie" "" } ``` diff --git a/chatgpt-irc.py b/chatgpt-irc.py @@ -9,6 +9,7 @@ import uuid class ChatGPT: def __init__(self): self.auth_token = options["auth_token"] + self.cookie = options['cookie'] self.conversation_id = "" self.parent_message_id = str(uuid.uuid4()) self.message_id = self.parent_message_id @@ -48,6 +49,7 @@ class ChatGPT: "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", + "Cookie": self.cookie, "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive", @@ -185,6 +187,7 @@ async def main_loop(**options): if message.command == "PING": sendcmd("PONG", *message.params) elif message.command == "001": + sendcmd("MODE", options["nickname"], "+B") for channel in options["channels"]: sendcmd("JOIN", channel) diff --git a/example-config.json b/example-config.json @@ -6,5 +6,6 @@ "ident": "chatgpt", "realname": "chatgpt", "channels": ["#rj1"], - "auth_token": "" + "auth_token": "", + "cookie": "" }