Skip to content

Commit 963239b

Browse files
committed
fix
0 parents  commit 963239b

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
### Twitch-Chat
2+
3+
📜 I made an script in Python for receive message from twitch chat.
4+
5+
## Tutorial 💻
6+
7+
For use the bot, make sure to do this:
8+
9+
```py
10+
class Bot(commands.Bot):
11+
12+
def __init__(self):
13+
# Make sure to put your personal token, use https://twitchapps.com/tmi/ for generate a random token.
14+
super().__init__(token='tokenbot', prefix='?', initial_channels=['channelname'])
15+
16+
bot = Bot()
17+
bot.run()
18+
```
19+
20+
And if you wanna make the chat, add this event:
21+
22+
```py
23+
class Bot(commands.Bot):
24+
def __init__(self):
25+
# Initialise our Bot with our access token, prefix and a list of channels to join on boot...
26+
super().__init__(token='tokenbot', prefix='?', initial_channels=['channelname'])
27+
async def event_message(self, ctx: commands.Context):
28+
# Print author and content of message
29+
print(f"From {ctx.author.name}: {ctx.content}")
30+
31+
bot = Bot()
32+
bot.run()
33+
```
34+
35+
And now, you can run the script and you'll have message content and message's author !
36+
37+
38+
## Wanna contact us ? 🤔
39+
40+
If you wanna contact us, send mail at miyucode@gmail.com

chat.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from twitchio.ext import commands
2+
import pprint
3+
4+
class Bot(commands.Bot):
5+
6+
def __init__(self):
7+
# Initialise our Bot with our access token, prefix and a list of channels to join on boot...
8+
super().__init__(token='token', prefix='?', initial_channels=['channelname'])
9+
10+
async def event_ready(self):
11+
# We are logged in and ready to chat and use commands...
12+
print(f'Connected on {self.nick} with success ! - Twitch Bot')
13+
14+
@commands.command()
15+
async def hello(self, ctx: commands.Context):
16+
# Send a hello back!
17+
await ctx.send(f'Hello {ctx.author.name}!')
18+
19+
async def event_message(self, ctx: commands.Context):
20+
print(f"From {ctx.author.name}: {ctx.content}")
21+
22+
bot = Bot()
23+
bot.run()

0 commit comments

Comments
 (0)