update for nixos

This commit is contained in:
churl
2021-03-29 19:06:38 +02:00
parent dff2783a5c
commit 80ecce5196
4 changed files with 46 additions and 4 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
eval "$(lorri direnv)"

25
bot.py
View File

@ -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()

View File

@ -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):

22
shell.nix Normal file
View File

@ -0,0 +1,22 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let myPython = python38.buildEnv.override {
extraLibs = with python38Packages; [
python-dotenv
rich
discordpy
beautifulsoup4
selenium
];
};
in
mkShell {
buildInputs = [
myPython
nodePackages.pyright
geckodriver
];
}