Created new command for moderators. This command allows to reconfigure some functionalitys of the bot

This commit is contained in:
JKuijperM 2025-06-20 13:57:07 +02:00
parent 9e3bca1482
commit 47d8195465

26
bot.py
View File

@ -20,7 +20,7 @@ def load_config_file():
def save_config_file(new_content): def save_config_file(new_content):
with open('config.json', 'w', encoding='utf-8') as f: with open('config.json', 'w', encoding='utf-8') as f:
json.dump(new_content, f, ident=4) json.dump(new_content, f)
class Bot(commands.Bot): class Bot(commands.Bot):
count_to_hydrate = 0 count_to_hydrate = 0
@ -60,6 +60,9 @@ class Bot(commands.Bot):
if 'hola caracola' in ctx.content.lower(): if 'hola caracola' in ctx.content.lower():
await ctx.channel.send('Hola caracola @{}'.format(ctx.author.display_name)) await ctx.channel.send('Hola caracola @{}'.format(ctx.author.display_name))
if 'sobrehidratada' in ctx.content.lower() or 'sobrehidratado' in ctx.content.lower() or 'sobrehidratación' in ctx.content.lower():
await ctx.channel.send('Muahahah eso es que mi plan malvado está funcionando 😈 @{}'.format(ctx.author.display_name))
# For each 100 messages, send one # For each 100 messages, send one
self.count_to_hydrate += 1 self.count_to_hydrate += 1
self.count_to_prime_spam += 1 self.count_to_prime_spam += 1
@ -134,6 +137,27 @@ class Bot(commands.Bot):
print('\nSending my command list...') print('\nSending my command list...')
await ctx.channel.send('Los comandos disponibles ahora mismo son: !redes, !placaje, !reco. ' await ctx.channel.send('Los comandos disponibles ahora mismo son: !redes, !placaje, !reco. '
'También puedes saludar con un "Hola caracola".') 'También puedes saludar con un "Hola caracola".')
@commands.command(name='config')
async def modify_config(self, ctx):
# TODO: Check if user is the streamer or mod
# Get the values from the message
if ctx.author.name.lower() == ctx.channel.name.lower() or ctx.author.badges == 'moderator':
print('[OK] Correct credentials to modify the config.')
print('{}'.format(ctx.message.content))
config_message = ctx.message.content.replace('\U000e0000', '').split()
print(config_message)
if len(config_message) == 3:
if config_message[1] == 'water':
self.default_values['water_limit'] = int(config_message[2])
save_config_file(self.default_values)
elif config_message[1] == 'prime':
self.default_values['prime_spam_limit'] = int(config_message[2])
save_config_file(self.default_values)
else:
await ctx.channel.send('@{} Jefe, faltan parámetros para la configuración.'.format(ctx.author.display_name))
if __name__ == "__main__": if __name__ == "__main__":