From b676579e7dbcb1563d2eecfe1bb6a27472a27e9b Mon Sep 17 00:00:00 2001 From: Jkibbels Date: Sat, 26 Oct 2024 18:54:24 -0400 Subject: [PATCH] bot --- froge.py | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 froge.py diff --git a/froge.py b/froge.py new file mode 100644 index 0000000..35d35e6 --- /dev/null +++ b/froge.py @@ -0,0 +1,92 @@ +import os +import json +from twitchio.ext import commands + +authConfig = None + +authConfigFileName = 'froge.json' +generalConfigFileName = 'general.json' + +########## HELPER FUNCTIONS ########## +def ReadAuthConfig(): + with open (authConfigFileName, 'r') as file: + global authConfig + authConfig = json.load(file) + +def ReadGeneralConfig(): + with open (generalConfigFileName, 'r') as file: + global generalConfig + generalConfig = json.load(file) + +def GetTmiToken(): + ReadAuthConfig() + global authConfig + if authConfig != None: + return authConfig['TMI_TOKEN'] + +def GetClientId(): + ReadAuthConfig() + global authConfig + if authConfig != None: + return authConfig['CLIENT_ID'] + +def GetBotNick(): + ReadAuthConfig() + global authConfig + if authConfig != None: + return authConfig['BOT_NICK'] + +def GetBotCommandPrefix(): + ReadAuthConfig() + global authConfig + if authConfig != None: + return authConfig['BOT_PREFIX'] + +def GetBotChannel(): + ReadAuthConfig() + global authConfig + if authConfig != None: + return authConfig['CHANNEL'] + +def GetClientSecret(): + ReadAuthConfig() + global authConfig + if authConfig != None: + return authConfig['CLIENT_SECRET'] + +########## HELPER FUNCTIONS END ########## + +class Bot(commands.Bot): + def __init__(self): + super().__init__(token=GetTmiToken(), + prefix=GetBotCommandPrefix(), + initial_channels=[GetBotChannel()]) + + async def event_ready(self): # Console confirmation the bot is actually alive >:) + print(f'Logged in as {self.nick}') + print(f'User id is {self.user_id}') + + ### COMMANDS ### + @commands.command() # !hello + async def hello(self, ctx: commands.Context): + await ctx.send(f'Hello {ctx.author.name}') + + @commands.command() # !socials + async def socials(self, ctx: commands.Context): + await ctx.send(f"") + + @commands.command() # !clip [optional: time] (default: 30 seconds) + async def clip(self, ctx: commands.Context, time='30s'): + await self.create + await ctx.send(' ') + + @commands.command() # !discord + async def discord(self, ctx: commands.Context): + await ctx.send(' ') + + @commands.command() # !timer {time} + async def timer(self, ctx: commands.Context): + await ctx.send(' ') + +bot = Bot() +bot.run() \ No newline at end of file