From 81c43aadccafc5c9ee0e90bdf2caf9c750aabc34 Mon Sep 17 00:00:00 2001 From: mtuszowski Date: Fri, 15 Nov 2024 14:01:25 +0100 Subject: [PATCH] xxx --- administration_commands.py | 9 +++++++++ ai_commands.py | 41 ++++++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/administration_commands.py b/administration_commands.py index e93a323..4eac164 100644 --- a/administration_commands.py +++ b/administration_commands.py @@ -32,6 +32,7 @@ class AdministrationModule(commands.Cog): description="Jeśli nie wiesz jak użyć tej komendy to nawet nie próbuj", guild=discord.Object(id=664789470779932693), ) + @commands.has_any_role('Nocna Zmiana', 'Jarl', 'Thane') async def galeria_slaw(self, ctx): if isinstance(ctx.channel, discord.DMChannel): for guild in self.bot.guilds: @@ -51,6 +52,8 @@ class AdministrationModule(commands.Cog): description="Jeśli nie wiesz jak użyć tej komendy to nawet nie próbuj", guild=discord.Object(id=664789470779932693), ) + @commands.has_any_role('Jarl', 'Thane') + async def update_banlist(self, ctx): """ Update a banlist in a Discord guild from preprovided list in channel. @@ -135,6 +138,12 @@ class AdministrationModule(commands.Cog): f"Nie mam na serwerze {guild} uprawnień do banowania. :()" ) await ctx.send("Zrobione tak czy inaczej") + @commands.hybrid_command( + name="archive_channel", + description="Jeśli nie wiesz jak użyć tej komendy to nawet nie próbuj", + guild=discord.Object(id=664789470779932693), + ) + @commands.has_any_role('Jarl', 'Thane') async def archive_channel(self, channel_no): """ diff --git a/ai_commands.py b/ai_commands.py index 7023a27..b39984c 100644 --- a/ai_commands.py +++ b/ai_commands.py @@ -4,7 +4,7 @@ import re import sys from enum import Enum from datetime import datetime -from typing import Optional +from typing import Optional, TypedDict import discord import openai @@ -24,14 +24,18 @@ from constants import ( WORD_REACTIONS, ) class Dm_Mode(Enum): - ARMIA_HAMMER = 1, + ARMIA_HAMMERA = 1, SPECJALNY_ZIEMNIACZEK = 2, - SEKRETNY_SEKSRET = 3 + SEKRETNY_SEKSRET = 3, + ECHO_ECHO = 4 class Events(commands.Cog): def __init__(self, bot): self.bot = bot self.logger = logging.getLogger("discord") + self.armia = {} + for superfryta in SPECJALNE_ZIEMNIACZKI.values(): + self.armia[superfryta[2]] = Dm_Mode.SPECJALNY_ZIEMNIACZEK async def cog_load(self): self.logger.info("Starting personal assistants") @@ -66,26 +70,21 @@ class Events(commands.Cog): description="Jeśli nie wiesz jak użyć tej komendy to nawet nie próbuj", guild=discord.Object(id=664789470779932693), ) - async def switch_dm_mode(self, ctx, arg: Dm_Mode): - - # add in on message - # broadcast avaiable only for me - with ctx.typing: + async def switch_dm_mode(self, ctx, dm_mode_arg: Dm_Mode): + async with ctx.typing: if isinstance(ctx.channel, discord.DMChannel): for superfryta in SPECJALNE_ZIEMNIACZKI.values(): if ctx.message.author.id == superfryta[0]: + self.armia[superfryta[2]] = dm_mode_arg await ctx.reply("Weszlo") return await ctx.reply("Tylko członkowie Armii Hammera mogą używać. Nie jesteś jednym z nich") else: await ctx.reply("Nope. Nie wiesz jak użyć") - #secrets, assistant, echo, dm - #required parameter from list of values - assistant, dm_broadcast, echo @commands.hybrid_command( name="armia_hammera", - description="Jeśli nie wiesz jak użyć tej komendy to nawet nie próbuj", - guild=discord.Object(id=664789470779932693), + description="Jeśli nie wiesz jak użyć tej komendy to nawet nie próbuj" ) async def armia_hammera(self, ctx, message_txt: str, recipient: Optional[discord.User]): pass @@ -139,9 +138,21 @@ class Events(commands.Cog): for superfryta in SPECJALNE_ZIEMNIACZKI.values(): self.logger.info(superfryta[0]) if message.author.id == superfryta[0]: - await self.bot.process_commands(message) - await ai_functions.chat_with_assistant(message, superfryta[1]) - return + if self.armia[message.author.id]== Dm_Mode.SPECJALNY_ZIEMNIACZEK: + await self.bot.process_commands(message) + await ai_functions.chat_with_assistant(message, superfryta[1]) + return + elif self.armia[message.author.id]== Dm_Mode.ECHO_ECHO: + await ai_functions.echo(message) + return + elif self.armia[message.author.id]== Dm_Mode.ARMIA_HAMMERA: + #self.armia_hammera_back() + return + elif self.armia[message.author.id]== Dm_Mode.SEKRETNY_SEKSRET: + pass + else: + await message.channel.send("Coś się wyebao. Wołaj Hammera") + return channel = self.bot.get_channel(1064888712565100614) await channel.send("Słyszałem ja żem że: " + message.content) return