-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_twitch.py
53 lines (46 loc) · 1.91 KB
/
main_twitch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from streamer_things.StreamBotUtils import *
class TwitchBot(tcommands.Bot):
def __init__(self, bridge: 'MainBot' = None, discord_link : int = None):
# Initialise our Bot with our access token, prefix and a list of channels to join on boot...
self.bridge = bridge
self.streamer = StreamerInfo()
self.streamers = [self.streamer]
self.channels = [x.channel for x in self.streamers]
self.discord_link = discord_link
async def go(self):
print("Starting Twitch bot...")
super().__init__(token=SecretData.twitch_token(),
prefix='=',
initial_channels=self.channels)
await self.start()
def main_channel(self) -> tChannel:
'''
Returns the main Twitch channel configured in the bot
'''
return self.get_channel(self.channels[0].replace("#",""))
async def event_ready(self):
self.uptime = datetime.datetime.utcnow()
tcog = "cogs_twitch"
for filename in listdir(f'./{tcog}'):
if filename.endswith('.py'):
self.load_module(f'{tcog}.{filename[:-3]}')
print(f'Loaded cog: {filename[:-3]}')
print(f'''
---------------------
| Twitch Ready!
| Name > {self.nick}
| ID > {self.user_id}
| Channels > {self.channels}
---------------------
''')
# async def event_message(self, message : tmessage.Message):
# if message.echo: return
# print(f'''[T] {message.author.name}: {message.content}''')
# if self.bridge:
# await self.bridge.discord_message(channel=(self.bridge.d_test_channel
# if self.bridge.d_test_channel else self.discord_link), message=message.content)
# await self.handle_commands(message)
if __name__ == "__main__":
import asyncio
bot = TwitchBot()
asyncio.run(bot.go())