File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from 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 } " )
Original file line number Diff line number Diff line change 1+ { "channel" : " my-channel" , "token" : " my-token" }
You can’t perform that action at this time.
0 commit comments