diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..051d09d --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +eval "$(lorri direnv)" diff --git a/bot.py b/bot.py index b724252..c11918c 100644 --- a/bot.py +++ b/bot.py @@ -9,7 +9,7 @@ import asyncio from dotenv import load_dotenv import discord -from discord import Intents +# from discord import Intents from scraper import Girls @@ -21,7 +21,7 @@ GUILD = os.getenv("DISCORD_GUILD") # Zocken mit Heidi class HeidiClient(discord.Client): def __init__(self): super().__init__( - intents=Intents.default(), + # intents=Intents.default(), status="Nur eine kann Germany's next Topmodel werden!", ) @@ -50,6 +50,7 @@ class HeidiClient(discord.Client): ### Voicelines self.matchers["sag kein Foto$"] = self.say_kein_foto + self.matchers["sag Opfer"] = self.say_opfer ### Helpers ------------------------------------------------------------------------------------ @@ -208,7 +209,25 @@ class HeidiClient(discord.Client): voice_client.play(audio_source) while voice_client.is_playing(): - asyncio.sleep(1) + await asyncio.sleep(1) + + await voice_client.disconnect() + + async def say_opfer(self, message): + """ + sag Opfer ("Opfer") + """ + voice_channel = message.author.voice.channel + + if voice_channel == None: + return + + voice_client = await voice_channel.connect() + audio_source = discord.FFmpegPCMAudio("sounds/opfer.mp3") + voice_client.play(audio_source) + + while voice_client.is_playing(): + await asyncio.sleep(1) await voice_client.disconnect() diff --git a/scraper.py b/scraper.py index 5f28a56..f3ad2f3 100644 --- a/scraper.py +++ b/scraper.py @@ -26,7 +26,7 @@ class Girls(): self.girls_in = {girl.find("h4", class_="candidate-title").text.lower(): girl for girl in girls_in} self.girls_out = {girl.find("h4", class_="candidate-title").text.lower(): girl for girl in girls_out} - self.girls = self.girls_in | self.girls_out + self.girls = {**self.girls_in, **self.girls_out} def get_in_names(self): diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..da2cc0b --- /dev/null +++ b/shell.nix @@ -0,0 +1,22 @@ +{ pkgs ? import {} }: + +with pkgs; + +let myPython = python38.buildEnv.override { + extraLibs = with python38Packages; [ + python-dotenv + rich + discordpy + beautifulsoup4 + selenium + ]; + }; +in + +mkShell { + buildInputs = [ + myPython + nodePackages.pyright + geckodriver + ]; +}