Skip to content

Commit ad71b08

Browse files
authored
Merge pull request #3 from Aqueuse/main
add a config.json file for token and channel name
2 parents 7b9ef16 + c930f80 commit ad71b08

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

chat.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
from twitchio.ext import commands
2-
import pprint
2+
import json
33

4-
class Bot(commands.Bot):
54

5+
class Bot(commands.Bot):
66
def __init__(self):
7+
json_file = open('default_config.json', 'r')
8+
data = json.load(json_file)
79
# 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'])
10+
super().__init__(token=data["token"], prefix='?', initial_channels=[data["channel"]])
911

1012
async def event_ready(self):
1113
# We are logged in and ready to chat and use commands...
1214
print(f'Hello {self.nick}')
1315

16+
async def event_message(self, ctx: commands.Context):
17+
print(f"{ctx.author.name} : {ctx.content}")
18+
1419
@commands.command()
1520
async def event_message(self, ctx: commands.Context):
1621
print(f"{ctx.author.name} : {ctx.content}")

default_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "channel" : "my-channel", "token" : "my-token" }

0 commit comments

Comments
 (0)