Skip to content

Commit 494ac71

Browse files
committed
add a config.json file for token and channel name
1 parent 963239b commit 494ac71

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

chat.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
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...
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}!')
14+
print(f'Hello {self.nick}')
1815

1916
async def event_message(self, ctx: commands.Context):
20-
print(f"From {ctx.author.name}: {ctx.content}")
17+
print(f"{ctx.author.name} : {ctx.content}")
18+
19+
2120

2221
bot = Bot()
2322
bot.run()

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)