froge_bot/froge.py

92 lines
2.3 KiB
Python
Raw Normal View History

2024-10-26 22:54:24 +00:00
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()