Skip to content

Commit 472cb25

Browse files
committed
add readme and sample env
1 parent 2f8ba93 commit 472cb25

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

.env.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
OPENAI_EMAIL=
2+
OPENAI_PASSWORD=
3+
TWITCH_NAME=
4+
TWITCH_TOKEN=
5+
TWITCH_CHANNEL=

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ChatGPT Twitch Bot
2+
3+
## Prerequisites
4+
5+
- NodeJS >= 18
6+
7+
## Usage
8+
9+
Firstly you need to install the required npm packages with
10+
11+
`npm i`
12+
13+
This bot is based on the chatgpt package from @transitive-bullshit
14+
We also use tmijs to communicate with the Twitch Channels
15+
16+
After installing the required packages you need to populate the environment file with following variables
17+
18+
- OPENAI_EMAIL=
19+
- OPENAI_PASSWORD=
20+
- TWITCH_NAME=
21+
- TWITCH_TOKEN=
22+
- TWITCH_CHANNEL=
23+
24+
For the OPENAI Variables just put your credentials in, remember to log out from your browser before. For Twitch you can create an extra bot or connect from your main Account.
25+
You can get the TWITCH_TOKEN [here](https://twitchapps.com/tmi/)
26+
You can join any desired Twitch Channel by specifying it with TWITCH_CHANNEL variable.
27+
28+
After all of that you can start the script with following line
29+
30+
`npx tsx chatgpt-twitch-bot.ts`
31+
32+
This will compile and run the typescript file on the fly
33+
34+
## Known Problems
35+
36+
I have tried to work on having conversations but unfortunately I always run into a 429, there is an extra branch if you would like to contribute
37+
38+
Unfortunately you have to login with the captcha on every request...

chatgpt_bot-twitch-demo.ts renamed to chatgpt-twitch-bot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const client = new tmi.Client({
1313
username: process.env.TWITCH_NAME,
1414
password: process.env.TWITCH_TOKEN,
1515
},
16-
channels: ["chatgpt_bot_0001"],
16+
channels: [process.env.TWITCH_CHANNEL as string],
1717
});
1818

1919
client.connect();
@@ -42,7 +42,7 @@ client.on("message", (channel, tags, message, self) => {
4242

4343
const response = await api.sendMessage(prompt);
4444

45-
client.say(channel, `@${tags.username}, ${response}}`);
45+
client.say(channel, `@${tags.username}, ${response}`);
4646
})();
4747
}
4848
});

0 commit comments

Comments
 (0)