From 47d8195465947810a2711bfa633a8ac672963f63 Mon Sep 17 00:00:00 2001 From: JKuijperM Date: Fri, 20 Jun 2025 13:57:07 +0200 Subject: [PATCH] Created new command for moderators. This command allows to reconfigure some functionalitys of the bot --- bot.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 63c23d6..0a27e7d 100644 --- a/bot.py +++ b/bot.py @@ -20,7 +20,7 @@ def load_config_file(): def save_config_file(new_content): 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): count_to_hydrate = 0 @@ -60,6 +60,9 @@ class Bot(commands.Bot): if 'hola caracola' in ctx.content.lower(): 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 self.count_to_hydrate += 1 self.count_to_prime_spam += 1 @@ -134,6 +137,27 @@ class Bot(commands.Bot): print('\nSending my command list...') await ctx.channel.send('Los comandos disponibles ahora mismo son: !redes, !placaje, !reco. ' '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__":