Compare commits
40 Commits
ca91617371
...
v3.1
| Author | SHA1 | Date | |
|---|---|---|---|
| c2847de7dd | |||
| 08230eb3de | |||
| f2ddb4ab66 | |||
| 876232f674 | |||
| d7c3a7c740 | |||
| bdcd5208a7 | |||
| 79fcf0142a | |||
| 0f6cc12182 | |||
| 9b66061ee7 | |||
| c6608e4695 | |||
| 3335009692 | |||
| d7604b6604 | |||
| 2e493e404b | |||
| 16822e0212 | |||
| 9d78352ea5 | |||
| 13b3e9910a | |||
| 1b89d2ef3b | |||
| 6debffbd77 | |||
| e08c1c0204 | |||
| 82f0387675 | |||
| b6fbed1c49 | |||
| e430b99e35 | |||
| 626611f5a8 | |||
| 56b625b5b8 | |||
| e3e42dc235 | |||
| 1c8a6c3945 | |||
| e94fbdd716 | |||
| 361de0f5eb | |||
| d8c1ca48a9 | |||
| 0fa5807442 | |||
| 222b5b99f3 | |||
| a34e4fc01b | |||
| 7250d7bb7d | |||
| 48e47f081a | |||
| a0e184f2fc | |||
| 273b3ff406 | |||
| 29d4dff673 | |||
| 51f560f686 | |||
| 9836ae72c4 | |||
| b66c10bacb |
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.mkv filter=lfs diff=lfs merge=lfs -text
|
||||
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
||||
@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- ".gitea/workflows/*"
|
||||
- "Dockerfile"
|
||||
- "*.py"
|
||||
- "requirements.txt"
|
||||
@ -17,10 +18,10 @@ jobs:
|
||||
- name: Login to container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.local.chriphost.de
|
||||
registry: gitea.vps.chriphost.de
|
||||
username: ${{ secrets.CONTAINER_REGISTRY_USER }}
|
||||
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
|
||||
- name: Build Docker image
|
||||
run: docker build . --file Dockerfile --tag gitea.local.chriphost.de/christoph/discord-heidi:latest
|
||||
run: docker build . --file Dockerfile --tag gitea.vps.chriphost.de/christoph/discord-heidi:latest
|
||||
- name: Push Docker image
|
||||
run: docker push gitea.local.chriphost.de/christoph/discord-heidi:latest
|
||||
run: docker push gitea.vps.chriphost.de/christoph/discord-heidi:latest
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,3 +11,5 @@ Pipfile.lock
|
||||
/discord.log
|
||||
/disabled_voicelines/
|
||||
*.svg
|
||||
.vscode
|
||||
Heidi_User.conf
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
workflow: # for entire pipeline
|
||||
rules:
|
||||
- if: '$CI_COMMIT_REF_NAME == "master"' # only run on master...
|
||||
changes: # ...and when these files have changed
|
||||
- "*.py"
|
||||
- "Dockerfile"
|
||||
|
||||
docker-build:
|
||||
stage: build
|
||||
image: docker:20 # provides the docker toolset (but without an active daemon)
|
||||
services: # configure images that run during jobs linked to the image (above)
|
||||
- docker:dind # dind build on docker and starts up the dockerdaemon (docker itself doesn't do that), which is needed to call docker build etc.
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
- docker pull $CI_REGISTRY_IMAGE:latest || true # latest image for cache (not failing if image is not found)
|
||||
- >
|
||||
docker build
|
||||
--pull
|
||||
--cache-from $CI_REGISTRY_IMAGE:latest
|
||||
--label "org.opencontainers.image.title=$CI_PROJECT_TITLE"
|
||||
--label "org.opencontainers.image.url=$CI_PROJECT_URL"
|
||||
--label "org.opencontainers.image.created=$CI_JOB_STARTED_AT"
|
||||
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA"
|
||||
--label "org.opencontainers.image.version=$CI_COMMIT_REF_NAME"
|
||||
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||
.
|
||||
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
|
||||
- docker push $CI_REGISTRY_IMAGE:latest
|
||||
|
||||
docker-deploy:
|
||||
stage: deploy
|
||||
image: alpine:3.15
|
||||
needs: ["docker-build"]
|
||||
script:
|
||||
- chmod og= $ID_RSA
|
||||
- apk update && apk add openssh-client
|
||||
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "/home/christoph/$CI_PROJECT_TITLE/launch.sh"
|
||||
@ -7,4 +7,4 @@ WORKDIR /app
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN pip3 install -r requirements.txt
|
||||
COPY . .
|
||||
CMD ["python3", "bot.py"]
|
||||
CMD ["python3", "-u", "bot.py"]
|
||||
|
||||
502
bot.py
502
bot.py
@ -1,180 +1,187 @@
|
||||
# Example: https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py
|
||||
|
||||
import os, re, random, logging, asyncio, discord
|
||||
from discord import app_commands
|
||||
import random, logging
|
||||
from discord.app_commands import Choice
|
||||
from functools import reduce
|
||||
from dotenv import load_dotenv
|
||||
from typing import Optional, Union
|
||||
|
||||
# TODO: Reenable + extend textgen
|
||||
# from textgen import textgen
|
||||
# from textgen_markov import MarkovTextGenerator
|
||||
# from textgen_lstm import LSTMTextGenerator
|
||||
|
||||
# TODO: Reenable + extend scraper
|
||||
# from models import Models
|
||||
|
||||
# We're fancy today
|
||||
from typing import Dict, List, Optional, Union, Callable, Any
|
||||
from rich.traceback import install
|
||||
|
||||
from heidi_client import *
|
||||
|
||||
# Install rich traceback
|
||||
install(show_locals=True)
|
||||
|
||||
# ================================================================================================ #
|
||||
# ================================================================================================ #
|
||||
# NOTE: Always set this correctly: #
|
||||
DOCKER = True #
|
||||
# ================================================================================================ #
|
||||
# ================================================================================================ #
|
||||
|
||||
# DONE: Migrate back to discord.py
|
||||
# DONE: Rewrite bot with slash commands (and making actual use of discord.py)
|
||||
# TODO: Insult statistics (you have insulted 20 times)
|
||||
# TODO: Only post in heidi-spam channel
|
||||
# TODO: yt-dlp music support
|
||||
# TODO: Somehow upload voicelines more easily (from discord voice message?), also need to be distributed to folders so no more than 25 lines per folder
|
||||
# TODO: Reenable text/quote generation, allow uploading of training text files, allow switching "personalities" (/elon generates elon quote?)
|
||||
# TODO: Zalgo generator
|
||||
# @todo Only post in heidi-spam channel
|
||||
# @todo yt-dlp music support
|
||||
# @todo Somehow upload voicelines more easily (from discord voice message?)
|
||||
|
||||
# IDs of the servers Heidi is used on
|
||||
LINUS_GUILD = discord.Object(id=431154792308408340)
|
||||
TEST_GUILD = discord.Object(id=821511861178204161)
|
||||
|
||||
class HeidiClient(discord.Client):
|
||||
def __init__(self, *, intents: discord.Intents):
|
||||
super().__init__(status="Nur eine kann GNTM werden!", intents=intents)
|
||||
|
||||
# Separate object that keeps all application command state
|
||||
self.tree = app_commands.CommandTree(self)
|
||||
|
||||
# self.models = Models() # scraped model list
|
||||
|
||||
# automatic actions on all messages
|
||||
# auto_triggers is a map with tuples of two functions: (predicate, action)
|
||||
# if the predicate is true the action is performed
|
||||
self.auto_triggers = {
|
||||
# lambda m: m.author.nick.lower() in self.models.get_in_names(): self.autoreact_to_girls,
|
||||
lambda m: "jeremy" in m.author.nick.lower(): self._autoreact_to_jeremy
|
||||
}
|
||||
|
||||
# Textgen
|
||||
self.textgen_models: dict[str, textgen] = {
|
||||
# The name must correspond to the name of the training text file
|
||||
# "kommunistisches_manifest": LSTMTextGenerator(10),
|
||||
# "musk": LSTMTextGenerator(10),
|
||||
# "bibel": LSTMTextGenerator(10)
|
||||
|
||||
# "bibel": MarkovTextGenerator(3), # Prefix length of 3
|
||||
# "kommunistisches_manifest": MarkovTextGenerator(3),
|
||||
# "musk": MarkovTextGenerator(3)
|
||||
}
|
||||
|
||||
for name, model in self.textgen_models.items():
|
||||
model.init(name) # Loads the textfile
|
||||
|
||||
if os.path.exists(f"weights/{name}_lstm_model.pt"):
|
||||
model.load()
|
||||
elif not DOCKER:
|
||||
model.train()
|
||||
else:
|
||||
print("Error: Can't load model", name)
|
||||
|
||||
print("Generating test sentence for", name)
|
||||
self.textgen_models[name].generate_sentence()
|
||||
|
||||
# Synchronize commands to guilds
|
||||
async def setup_hook(self):
|
||||
self.tree.copy_global_to(guild=LINUS_GUILD)
|
||||
await self.tree.sync(guild=LINUS_GUILD)
|
||||
|
||||
self.tree.copy_global_to(guild=TEST_GUILD)
|
||||
await self.tree.sync(guild=TEST_GUILD)
|
||||
|
||||
# Commands -----------------------------------------------------------------------------------
|
||||
|
||||
# async def list_models_in(self, message):
|
||||
# """
|
||||
# wer ist dabei?
|
||||
# """
|
||||
# await message.channel.send("\n".join(self.models.get_in_names()))
|
||||
|
||||
# async def list_models_out(self, message):
|
||||
# """
|
||||
# wer ist raus? (Liste der Keks welche ge*ickt wurden)
|
||||
# """
|
||||
# await message.channel.send("\n".join(self.models.get_out_names()))
|
||||
|
||||
# async def show_model_picture(self, message):
|
||||
# """
|
||||
# gib Bild von <Name>
|
||||
# """
|
||||
# name = message.content.split()[-1]
|
||||
# picture = discord.Embed()
|
||||
# picture.set_image(url=self.models.get_image(name))
|
||||
# picture.set_footer(text=name)
|
||||
# await message.channel.send(embed=picture)
|
||||
|
||||
|
||||
# Automatic Actions --------------------------------------------------------------------------
|
||||
|
||||
# @staticmethod
|
||||
# async def autoreact_to_girls(message):
|
||||
# """
|
||||
# ❤ aktives Model
|
||||
# """
|
||||
# await message.add_reaction("❤")
|
||||
|
||||
@staticmethod
|
||||
async def _autoreact_to_jeremy(message):
|
||||
"""
|
||||
🧀 Jeremy
|
||||
"""
|
||||
await message.add_reaction("🧀")
|
||||
|
||||
# ------------------------------------------------------------------------------------------------
|
||||
|
||||
# Log to file
|
||||
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
|
||||
handler = logging.FileHandler(filename="discord.log", encoding="utf-8", mode="w")
|
||||
|
||||
# Intents specification is no longer optional
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True # Allow to react to member join/leave etc
|
||||
intents.message_content = True # Allow to read message content from arbitrary messages
|
||||
intents.members = True # Allow to react to member join/leave etc
|
||||
intents.message_content = True # Allow to read message content from arbitrary messages
|
||||
intents.voice_states = True # Allow to process on_voice_state_update
|
||||
|
||||
# Setup our client
|
||||
# Set up our client
|
||||
client = HeidiClient(intents=intents)
|
||||
|
||||
|
||||
# Events -----------------------------------------------------------------------------------------
|
||||
# NOTE: I defined the events outside of the Client class, don't know if I like it or not...
|
||||
# NOTE: I defined the events outside the Client class, don't know if I like it or not...
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print(f"{client.user} (id: {client.user.id}) has connected to Discord!")
|
||||
async def on_ready() -> None:
|
||||
"""
|
||||
This event triggers when the Heidi client has finished connecting.
|
||||
"""
|
||||
if client.user is not None:
|
||||
print(f"{client.user} (id: {client.user.id}) has connected to Discord!")
|
||||
else:
|
||||
print("client.user is None!")
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
async def on_message(message: Message) -> None:
|
||||
"""
|
||||
This event triggers when a message is sent in any text channel.
|
||||
"""
|
||||
# Skip Heidis own messages
|
||||
if message.author == client.user:
|
||||
return
|
||||
|
||||
# Automatic actions for all messages
|
||||
# python iterates over the keys of a map
|
||||
for predicate in client.auto_triggers:
|
||||
for predicate in client.on_message_triggers:
|
||||
if predicate(message):
|
||||
action = client.auto_triggers[predicate]
|
||||
action = client.on_message_triggers[predicate]
|
||||
print(f"on_message: calling {action.__name__}")
|
||||
await action(message)
|
||||
break
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_voice_state_update(
|
||||
member: Member, before: VoiceState, after: VoiceState
|
||||
) -> None:
|
||||
"""
|
||||
This event triggers when a member joins/changes/leaves a voice channel or mutes/unmutes.
|
||||
"""
|
||||
# Skip Heidis own voice state updates (e.g. on /say)
|
||||
if member._user == client.user:
|
||||
return
|
||||
|
||||
# Automatic acions for all voice state changes
|
||||
# python iterates over the keys of a map
|
||||
for predicate in client.on_voice_state_triggers:
|
||||
if predicate(member, before, after):
|
||||
action: Callable = client.on_voice_state_triggers[predicate]
|
||||
print(f"on_voice_state_update: calling {action.__name__}")
|
||||
await action(member, before, after)
|
||||
|
||||
|
||||
# Config Commands --------------------------------------------------------------------------------
|
||||
|
||||
|
||||
async def user_config_key_autocomplete(
|
||||
interaction: Interaction, current: str
|
||||
) -> List[Choice[str]]:
|
||||
"""
|
||||
Suggest a value from the user config keys (each .conf section is a key).
|
||||
"""
|
||||
return [
|
||||
Choice(name=key, value=key)
|
||||
for key in client.user_config.sections()
|
||||
if key.lower().startswith(current.lower())
|
||||
]
|
||||
|
||||
|
||||
async def user_config_value_autocomplete(
|
||||
interaction: Interaction, current: str
|
||||
) -> List[Choice[str]]:
|
||||
"""
|
||||
Calls an autocomplete function depending on the entered config_key.
|
||||
"""
|
||||
autocompleters = {"ENTRANCE.SOUND": user_entrance_sound_autocomplete}
|
||||
autocompleter = autocompleters[interaction.namespace.option]
|
||||
|
||||
print(f"config_value_autocomplete: calling {autocompleter.__name__}")
|
||||
|
||||
return autocompleter(interaction, current)
|
||||
|
||||
|
||||
def user_entrance_sound_autocomplete(
|
||||
interaction: Interaction, current: str
|
||||
) -> List[Choice[str]]:
|
||||
"""
|
||||
Generates autocomplete options for the ENTRANCE.SOUND config key.
|
||||
"""
|
||||
boards: List[str] = os.listdir(SOUNDDIR)
|
||||
all_sounds: Dict[str, List[str]] = {
|
||||
board: os.listdir(f"{SOUNDDIR}/{board}/") for board in boards
|
||||
} # These are all sounds, organized per board
|
||||
|
||||
# @todo Initially only suggest boards, because there are too many sounds to show them all
|
||||
completions: List[Choice[str]] = []
|
||||
for (
|
||||
board,
|
||||
board_sounds,
|
||||
) in all_sounds.items(): # Iterate over all sounds, organized per board
|
||||
for sound in board_sounds: # Iterate over board specific sounds
|
||||
soundpath = f"{board}/{sound}"
|
||||
if soundpath.lower().startswith(current.lower()):
|
||||
completions += [Choice(name=soundpath.split(".")[0], value=soundpath)]
|
||||
|
||||
return completions
|
||||
|
||||
|
||||
@client.tree.command(
|
||||
name="userconfig",
|
||||
description="User-spezifische Heidi-Einstellungen (Heidi merkt sie sich in ihrem riesigen Gehirn).",
|
||||
)
|
||||
@app_commands.rename(config_key="option")
|
||||
@app_commands.describe(config_key="Die Option, welche du ändern willst.")
|
||||
@app_commands.autocomplete(config_key=user_config_key_autocomplete)
|
||||
@app_commands.rename(config_value="wert")
|
||||
@app_commands.describe(
|
||||
config_value="Der Wert, auf welche die Option gesetzt werden soll."
|
||||
)
|
||||
@app_commands.autocomplete(config_value=user_config_value_autocomplete)
|
||||
@enforce_channel(HEIDI_SPAM_ID)
|
||||
async def user_config(
|
||||
interaction: Interaction, config_key: str, config_value: str
|
||||
) -> None:
|
||||
"""
|
||||
Set a user config value for the calling user.
|
||||
"""
|
||||
# Only Members can set settings
|
||||
if not isinstance(interaction.user, Member):
|
||||
print("User not a member")
|
||||
await interaction.response.send_message("Heidi sagt: Komm in die Gruppe!", ephemeral=True)
|
||||
return
|
||||
|
||||
member: Member = interaction.user
|
||||
|
||||
client.user_config[config_key][member.name] = config_value
|
||||
client.write_user_config()
|
||||
|
||||
await interaction.response.send_message(
|
||||
f"Ok, ich schreibe {member.name}={config_value} in mein fettes Gehirn!",
|
||||
ephemeral=True
|
||||
)
|
||||
|
||||
|
||||
# Commands ---------------------------------------------------------------------------------------
|
||||
|
||||
@client.tree.command(name = "giblinkbruder", description = "Heidi hilft mit dem Link zu deiner Lieblingsshow im Qualitätsfernsehen.")
|
||||
async def show_link(interaction: discord.Interaction):
|
||||
link_pro7 = "https://www.prosieben.de/tv/germanys-next-topmodel/livestream"
|
||||
link_joyn = "https://www.joyn.de/serien/germanys-next-topmodel"
|
||||
|
||||
await interaction.response.send_message(f"ProSieben: {link_pro7}\nJoyn: {link_joyn}")
|
||||
|
||||
@client.tree.command(name="heidi", description="Heidi!")
|
||||
async def heidi_exclaim(interaction: discord.Interaction):
|
||||
@enforce_channel(HEIDI_SPAM_ID)
|
||||
async def heidi_exclaim(interaction: Interaction) -> None:
|
||||
"""
|
||||
Print a random Heidi quote.
|
||||
"""
|
||||
messages = [
|
||||
"Die sind doch fast 18!",
|
||||
"Heidi!",
|
||||
@ -182,126 +189,174 @@ async def heidi_exclaim(interaction: discord.Interaction):
|
||||
"Dann zieh dich mal aus!",
|
||||
"Warum denn so schüchtern?",
|
||||
"Im TV ist das legal!",
|
||||
"Das Stroh ist nur fürs Shooting!"
|
||||
"Das Stroh ist nur fürs Shooting!",
|
||||
"Jetzt sei doch mal sexy!",
|
||||
"Stell dich nicht so an!",
|
||||
"Models müssen da halt durch!",
|
||||
"Heul doch nicht!",
|
||||
]
|
||||
await interaction.response.send_message(random.choice(messages))
|
||||
|
||||
|
||||
@client.tree.command(name="miesmuschel", description="Was denkt Heidi?")
|
||||
@app_commands.rename(question = "frage")
|
||||
@app_commands.describe(question = "Heidi wird es beantworten!")
|
||||
async def magic_shell(interaction: discord.Interaction, question: str):
|
||||
@app_commands.rename(question="frage")
|
||||
@app_commands.describe(question="Heidi wird es beantworten!")
|
||||
@enforce_channel(HEIDI_SPAM_ID)
|
||||
async def magic_shell(interaction: Interaction, question: str) -> None:
|
||||
"""
|
||||
Answer a yes/no question.
|
||||
"""
|
||||
# Should be equal amounts of yes/no answers, to have a 50/50 chance.
|
||||
choices = [
|
||||
"Ja!",
|
||||
"Jo.",
|
||||
"Jo",
|
||||
"Total!",
|
||||
"Natürlich.",
|
||||
"Natürlich",
|
||||
"Klaro Karo",
|
||||
"Offensichtlich Sherlock",
|
||||
"Tom sagt Ja",
|
||||
"Nein!",
|
||||
"Nö.",
|
||||
"Nä.",
|
||||
"Niemals!",
|
||||
"Nur über meine Leiche du Hurensohn!",
|
||||
"In deinen Träumen.",
|
||||
"Tom sagt Nein",
|
||||
]
|
||||
question = question.strip()
|
||||
question_mark = "" if question[-1] == "?" else "?"
|
||||
await interaction.response.send_message(f"{question}{question_mark}\nHeidi sagt: {random.choice(choices)}")
|
||||
await interaction.response.send_message(
|
||||
f"{question}{question_mark}\nHeidi sagt: {random.choice(choices)}"
|
||||
)
|
||||
|
||||
# TODO: Allow , separated varargs, need to parse manually as slash commands don't support varargs
|
||||
|
||||
# @todo Allow , separated varargs, need to parse manually as slash commands don't support varargs
|
||||
@client.tree.command(name="wähle", description="Heidi trifft die Wahl!")
|
||||
@app_commands.rename(option_a = "entweder")
|
||||
@app_commands.describe(option_a = "Ist es vielleicht dies?")
|
||||
@app_commands.rename(option_b = "oder")
|
||||
@app_commands.describe(option_b = "Oder doch eher das?")
|
||||
async def choose(interaction: discord.Interaction, option_a: str, option_b: str):
|
||||
@app_commands.rename(option_a="entweder")
|
||||
@app_commands.describe(option_a="Ist es vielleicht dies?")
|
||||
@app_commands.rename(option_b="oder")
|
||||
@app_commands.describe(option_b="Oder doch eher das?")
|
||||
@enforce_channel(HEIDI_SPAM_ID)
|
||||
async def choose(interaction: Interaction, option_a: str, option_b: str) -> None:
|
||||
"""
|
||||
Select an answer from two options.
|
||||
"""
|
||||
options = [option_a.strip(), option_b.strip()]
|
||||
await interaction.response.send_message(f"{options[0]} oder {options[1]}?\nHeidi sagt: {random.choice(options)}")
|
||||
await interaction.response.send_message(
|
||||
f"{options[0]} oder {options[1]}?\nHeidi sagt: {random.choice(options)}"
|
||||
)
|
||||
|
||||
# async def quote_model_autocomplete(interaction: discord.Interaction, current: str) -> list[Choice[str]]:
|
||||
# models = client.textgen_models.keys()
|
||||
# return [Choice(name=model, value=model) for model in models]
|
||||
|
||||
# @client.tree.command(name="zitat", description="Heidi zitiert!")
|
||||
# @app_commands.rename(quote_model = "style")
|
||||
# @app_commands.describe(quote_model = "Woraus soll Heidi zitieren?")
|
||||
# @app_commands.autocomplete(quote_model = quote_model_autocomplete)
|
||||
# async def quote(interaction: discord.Interaction, quote_model: str):
|
||||
# generated_quote = client.textgen_models[quote_model].generate_sentence()
|
||||
# joined_quote = " ".join(generated_quote)
|
||||
# await interaction.response.send_message(f"Heidi zitiert: \"{joined_quote}\"")
|
||||
# Sounds -----------------------------------------------------------------------------------------
|
||||
|
||||
# @client.tree.command(name="vervollständige", description="Heidi beendet den Satz!")
|
||||
# @app_commands.rename(prompt = "satzanfang")
|
||||
# @app_commands.describe(prompt = "Der Satzanfang wird vervollständigt.")
|
||||
# @app_commands.rename(quote_model = "style")
|
||||
# @app_commands.describe(quote_model = "Woraus soll Heidi vervollständigen?")
|
||||
# @app_commands.autocomplete(quote_model = quote_model_autocomplete)
|
||||
# async def complete(interaction: discord.Interaction, prompt: str, quote_model: str):
|
||||
# prompt = re.sub(r"[^a-zäöüß'.,]+", " ", prompt.lower()) # only keep valid chars
|
||||
# generated_quote = client.textgen_models[quote_model].complete_sentence(prompt.split())
|
||||
# joined_quote = " ".join(generated_quote)
|
||||
# await interaction.response.send_message(f"Heidi sagt: \"{joined_quote}\"")
|
||||
|
||||
SOUNDDIR: str = "/sounds/" if DOCKER else "./voicelines/"
|
||||
async def board_autocomplete(
|
||||
interaction: Interaction, current: str
|
||||
) -> List[Choice[str]]:
|
||||
"""
|
||||
Suggest a sound board.
|
||||
"""
|
||||
boards: List[str] = os.listdir(SOUNDDIR)
|
||||
|
||||
# Example: https://discordpy.readthedocs.io/en/latest/interactions/api.html?highlight=autocomplete#discord.app_commands.autocomplete
|
||||
async def board_autocomplete(interaction: discord.Interaction, current: str) -> list[Choice[str]]:
|
||||
boards = os.listdir(SOUNDDIR)
|
||||
return [Choice(name=board, value=board) for board in boards]
|
||||
return [
|
||||
Choice(name=board, value=board)
|
||||
for board in boards
|
||||
if board.lower().startswith(current.lower())
|
||||
]
|
||||
|
||||
async def sound_autocomplete(interaction: discord.Interaction, current: str) -> list[Choice[str]]:
|
||||
board = interaction.namespace.board # TODO: Can't work?
|
||||
sounds = map(lambda x: x.split(".")[0], os.listdir(SOUNDDIR + board + "/"))
|
||||
return [Choice(name=sound, value=sound) for sound in sounds]
|
||||
|
||||
@client.tree.command(name = "sag", description = "Heidi drückt den Knopf auf dem Soundboard.")
|
||||
@app_commands.describe(sound = "Was soll Heidi sagen?")
|
||||
@app_commands.autocomplete(board = board_autocomplete)
|
||||
@app_commands.autocomplete(sound = sound_autocomplete)
|
||||
async def say_voiceline(interaction: discord.Interaction, board: str, sound: str):
|
||||
async def sound_autocomplete(
|
||||
interaction: Interaction, current: str
|
||||
) -> List[Choice[str]]:
|
||||
"""
|
||||
Suggest a sound from an already selected board.
|
||||
"""
|
||||
board: str = interaction.namespace.board
|
||||
sounds: List[str] = os.listdir(f"{SOUNDDIR}/{board}/")
|
||||
|
||||
return [
|
||||
Choice(name=sound.split(".")[0], value=sound)
|
||||
for sound in sounds
|
||||
if sound.lower().startswith(current.lower())
|
||||
]
|
||||
|
||||
|
||||
@client.tree.command(
|
||||
name="sag", description="Heidi drückt den Knopf auf dem Soundboard."
|
||||
)
|
||||
@app_commands.describe(sound="Was soll Heidi sagen?")
|
||||
@app_commands.autocomplete(board=board_autocomplete)
|
||||
@app_commands.autocomplete(sound=sound_autocomplete)
|
||||
@enforce_channel(HEIDI_SPAM_ID)
|
||||
async def say_voiceline(interaction: Interaction, board: str, sound: str) -> None:
|
||||
"""
|
||||
Play a voiceline in the calling member's current voice channel.
|
||||
"""
|
||||
# Only Members can access voice channels
|
||||
if not isinstance(interaction.user, discord.Member):
|
||||
if not isinstance(interaction.user, Member):
|
||||
print("User not a member")
|
||||
await interaction.response.send_message("Heidi sagt: Komm in die Gruppe!")
|
||||
await interaction.response.send_message("Heidi sagt: Komm in die Gruppe!", ephemeral=True)
|
||||
return
|
||||
|
||||
member: discord.Member = interaction.user
|
||||
member: Member = interaction.user
|
||||
|
||||
# Member needs to be in voice channel to hear audio (Heidi needs to know the channel to join)
|
||||
if (not member.voice) or (not member.voice.channel) or (not isinstance(member.voice.channel, discord.VoiceChannel)):
|
||||
print("User not in (valid) voice channel!")
|
||||
await interaction.response.send_message("Heidi sagt: Komm in den Channel!")
|
||||
return
|
||||
await play_voice_line_for_member(interaction, member, board, sound)
|
||||
|
||||
voice_channel: discord.VoiceChannel = member.voice.channel
|
||||
|
||||
try:
|
||||
open(SOUNDDIR + board + "/" + sound + ".mkv")
|
||||
except IOError:
|
||||
print("Error: Invalid soundfile!")
|
||||
await interaction.response.send_message(f"Heidi sagt: \"{board}/{sound}\" kanninich finden bruder")
|
||||
return
|
||||
class InstantButton(discord.ui.Button):
|
||||
def __init__(self, label: str, board: str, sound: str):
|
||||
super().__init__(style=discord.ButtonStyle.red, label=label)
|
||||
|
||||
await interaction.response.send_message(f"Heidi sagt: \"{board}/{sound}\"")
|
||||
self.board = board
|
||||
self.sound = sound
|
||||
|
||||
audio_source = discord.FFmpegPCMAudio(SOUNDDIR + board + "/" + sound + ".mkv") # only works from docker
|
||||
voice_client = await voice_channel.connect()
|
||||
voice_client.play(audio_source)
|
||||
async def callback(self, interaction: Interaction):
|
||||
"""
|
||||
Handle a press of the button.
|
||||
"""
|
||||
if not isinstance(interaction.user, Member):
|
||||
await interaction.response.send_message("Heidi mag keine discord.User, nur discord.Member!", ephemeral=True)
|
||||
return
|
||||
|
||||
while voice_client.is_playing():
|
||||
await asyncio.sleep(1)
|
||||
await play_voice_line_for_member(interaction, interaction.user, self.board, self.sound)
|
||||
|
||||
|
||||
class InstantButtons(discord.ui.View):
|
||||
def __init__(self, board: str, timeout=None):
|
||||
super().__init__(timeout=timeout)
|
||||
|
||||
sounds = os.listdir(f"{SOUNDDIR}/{board}")
|
||||
for sound in sounds:
|
||||
self.add_item(InstantButton(sound.split(".")[0], board, sound))
|
||||
|
||||
|
||||
@client.tree.command(
|
||||
name="instantbuttons", description="Heidi malt Knöpfe für Sounds in den Chat."
|
||||
)
|
||||
@app_commands.describe(board="Welches Soundboard soll knöpfe bekommen?")
|
||||
@app_commands.autocomplete(board=board_autocomplete)
|
||||
@enforce_channel(HEIDI_SPAM_ID)
|
||||
async def soundboard_buttons(interaction: Interaction, board: str) -> None:
|
||||
await interaction.response.send_message(f"Soundboard: {board.capitalize()}", view=InstantButtons(board))
|
||||
|
||||
await voice_client.disconnect()
|
||||
|
||||
# Contextmenu ------------------------------------------------------------------------------------
|
||||
|
||||
# TODO: More insults
|
||||
|
||||
# Callable on members
|
||||
@client.tree.context_menu(name="beleidigen")
|
||||
async def insult(interaction: discord.Interaction, member: discord.Member): # with message: discord.Message this can be called on a message
|
||||
async def insult(
|
||||
interaction: Interaction, member: Member
|
||||
) -> None: # with message: discord.Message this can be called on a message
|
||||
"""
|
||||
Send an insult to a member via direct message.
|
||||
"""
|
||||
if not member.dm_channel:
|
||||
await member.create_dm()
|
||||
|
||||
if not member.dm_channel:
|
||||
print("Error creating DMChannel!")
|
||||
await interaction.response.send_message("Heidi sagt: Gib mal DM Nummer süße*r!")
|
||||
await interaction.response.send_message("Heidi sagt: Gib mal DM Nummer süße*r!", ephemeral=True)
|
||||
return
|
||||
|
||||
insults = [
|
||||
@ -317,20 +372,25 @@ async def insult(interaction: discord.Interaction, member: discord.Member): # wi
|
||||
"Opfer!",
|
||||
"Du miese Raupe!",
|
||||
"Geh Steckdosen befruchten!",
|
||||
"Richtiger Gesichtsgünther ey!"
|
||||
"Richtiger Gesichtsgünther ey!",
|
||||
]
|
||||
|
||||
await member.dm_channel.send(random.choice(insults))
|
||||
await interaction.response.send_message("Anzeige ist raus!") # with ephemeral = True only the caller can see the answer
|
||||
await interaction.response.send_message(
|
||||
"Anzeige ist raus!",
|
||||
ephemeral=True
|
||||
) # with ephemeral = True only the caller can see the answer
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Used to start the bot locally, for docker the variables have to be set when the container is run
|
||||
load_dotenv()
|
||||
TOKEN: str = os.getenv("DISCORD_TOKEN") or ""
|
||||
|
||||
# Start client if TOKEN valid
|
||||
if TOKEN != "":
|
||||
print(f"Running client with DOCKER={DOCKER}")
|
||||
client.run(TOKEN, log_handler=handler)
|
||||
else:
|
||||
print("DISCORD_TOKEN not found, exiting...")
|
||||
|
||||
76
flake.lock
generated
76
flake.lock
generated
@ -2,15 +2,15 @@
|
||||
"nodes": {
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1666548262,
|
||||
"narHash": "sha256-4DyN4KXqQQsCw0vCXkMThw4b5Q4/q87ZZgRb4st8COc=",
|
||||
"lastModified": 1701787589,
|
||||
"narHash": "sha256-ce+oQR4Zq9VOsLoh9bZT8Ip9PaMLcjjBUHVPzW5d7Cw=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "c8ce8ed81726079c398f5f29c4b68a7d6a3c2fa2",
|
||||
"rev": "44ddedcbcfc2d52a76b64fb6122f209881bd3e1e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -20,27 +20,15 @@
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1642700792,
|
||||
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
|
||||
"type": "github"
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -51,11 +39,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1643381941,
|
||||
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
|
||||
"lastModified": 1677383253,
|
||||
"narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
|
||||
"rev": "9952d6bc395f5841262b006fbace8dd7e143b634",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -67,11 +55,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1666926733,
|
||||
"narHash": "sha256-+gYfOEnQVISPDRNoWm2VJD5OEuTUySt48RchLpvm61o=",
|
||||
"lastModified": 1701693815,
|
||||
"narHash": "sha256-7BkrXykVWfkn6+c1EhFA3ko4MLi3gVG0p9G96PNnKTM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f44ba1be526c8da9e79a5759feca2365204003f6",
|
||||
"rev": "09ec6a0881e1a36c29d67497693a67a16f4da573",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -84,9 +72,39 @@
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
||||
41
flake.nix
41
flake.nix
@ -11,31 +11,10 @@
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
overlays = [ devshell.overlay ];
|
||||
overlays = [ devshell.overlays.default ];
|
||||
};
|
||||
|
||||
# TODO: Originally it was nixpkgs.fetchurl but that didn't work, pkgs.fetchurl did...
|
||||
# Determine the difference between nixpkgs and pkgs
|
||||
|
||||
# Taken from: https://github.com/gbtb/nix-stable-diffusion/blob/master/flake.nix
|
||||
# Overlay: https://nixos.wiki/wiki/Overlays
|
||||
# FetchURL: https://ryantm.github.io/nixpkgs/builders/fetchers/
|
||||
torch-rocm = pkgs.hiPrio (pkgs.python310Packages.torch-bin.overrideAttrs (old: {
|
||||
src = pkgs.fetchurl {
|
||||
name = "torch-1.12.1+rocm5.1.1-cp310-cp310-linux_x86_64.whl";
|
||||
url = "https://download.pytorch.org/whl/rocm5.1.1/torch-1.12.1%2Brocm5.1.1-cp310-cp310-linux_x86_64.whl";
|
||||
hash = "sha256-kNShDx88BZjRQhWgnsaJAT8hXnStVMU1ugPNMEJcgnA=";
|
||||
};
|
||||
}));
|
||||
torchvision-rocm = pkgs.hiPrio (pkgs.python310Packages.torchvision-bin.overrideAttrs (old: {
|
||||
src = pkgs.fetchurl {
|
||||
name = "torchvision-0.13.1+rocm5.1.1-cp310-cp310-linux_x86_64.whl";
|
||||
url = "https://download.pytorch.org/whl/rocm5.1.1/torchvision-0.13.1%2Brocm5.1.1-cp310-cp310-linux_x86_64.whl";
|
||||
hash = "sha256-mYk4+XNXU6rjpgWfKUDq+5fH/HNPQ5wkEtAgJUDN/Jg=";
|
||||
};
|
||||
}));
|
||||
|
||||
myPython = pkgs.python310.withPackages (p: with p; [
|
||||
myPython = pkgs.python311.withPackages (p: with p; [
|
||||
# Basic
|
||||
rich
|
||||
|
||||
@ -45,15 +24,15 @@
|
||||
pynacl
|
||||
|
||||
# Scraping
|
||||
beautifulsoup4
|
||||
requests
|
||||
# beautifulsoup4
|
||||
# requests
|
||||
|
||||
# MachineLearning
|
||||
torch-rocm
|
||||
torchvision-rocm
|
||||
numpy
|
||||
matplotlib
|
||||
nltk
|
||||
# torch-rocm
|
||||
# torchvision-rocm
|
||||
# numpy
|
||||
# matplotlib
|
||||
# nltk
|
||||
]);
|
||||
in {
|
||||
devShell = pkgs.devshell.mkShell {
|
||||
@ -61,7 +40,7 @@
|
||||
|
||||
packages = with pkgs; [
|
||||
myPython
|
||||
nodePackages.pyright # LSP
|
||||
# nodePackages.pyright # LSP
|
||||
];
|
||||
|
||||
# Use $1 for positional args
|
||||
|
||||
BIN
heidi-sounds/basic/Alarm.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Alarm.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Bing Chilling.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Bing Chilling.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Bingbong.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Bingbong.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Durchfallmann.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Durchfallmann.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Frosch.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Frosch.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Grab them.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Grab them.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Habicht.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Habicht.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Haha nein.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Haha nein.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Jajaja.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Jajaja.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Kein Foto.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Kein Foto.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Kurze Trinkpause.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Kurze Trinkpause.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Mach die Baschics.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Mach die Baschics.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Ok lets go.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Ok lets go.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Opfer.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Opfer.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/PH.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/PH.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Shock Dart.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Shock Dart.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Suiii.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Suiii.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Warum.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Warum.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/basic/Yarak gruessen.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/basic/Yarak gruessen.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/1900er.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/1900er.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Alter was.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Alter was.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Amok laufn.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Amok laufn.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Erschiessd euch.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Erschiessd euch.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Forza.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Forza.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Gaudi.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Gaudi.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Geh von meinem Grundstueck.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Geh von meinem Grundstueck.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Geiles Stueck.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Geiles Stueck.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Hagebuddne.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Hagebuddne.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Hurensohn hau ab.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Hurensohn hau ab.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Ich arbeite.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Ich arbeite.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Ich bin ein Dummer.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Ich bin ein Dummer.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Ich seh Punkte.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Ich seh Punkte.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Lusa.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Lusa.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Mann.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Mann.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Meddl.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Meddl.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Menschen ausloeschen.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Menschen ausloeschen.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Nice Sache.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Nice Sache.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Oehh.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Oehh.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Pruegel in der Hosne.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Pruegel in der Hosne.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Schwaenze im Mund.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Schwaenze im Mund.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Seid ihr bescheuerd.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Seid ihr bescheuerd.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Wie Bidde.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Wie Bidde.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/drache/Wuerde man merken.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/drache/Wuerde man merken.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/henri/Hausmeister.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/henri/Hausmeister.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/henri/He turned into me.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/henri/He turned into me.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/henri/Ich bin der Pablo.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/henri/Ich bin der Pablo.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/henri/Kann ich behilflich sein.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/henri/Kann ich behilflich sein.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/henri/Koetzlicher Kill.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/henri/Koetzlicher Kill.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/henri/Tapier.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/henri/Tapier.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/henri/Yakari.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/henri/Yakari.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/jungs/Du Nuttensohn.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/jungs/Du Nuttensohn.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/jungs/Florian du Hurensohn.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/jungs/Florian du Hurensohn.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/jungs/Halts Maul Linus.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/jungs/Halts Maul Linus.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/jungs/Jajaja.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/jungs/Jajaja.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/jungs/Knorke.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/jungs/Knorke.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/jungs/Neinneinnein.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/jungs/Neinneinnein.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/jungs/Sven du Hurensohn.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/jungs/Sven du Hurensohn.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/kaptn/Discord Call.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/kaptn/Discord Call.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/kaptn/FBI open up.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/kaptn/FBI open up.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/kaptn/Kleine Spende Bitte.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/kaptn/Kleine Spende Bitte.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/kaptn/Meine Chicken Nuggets Verbrennen.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/kaptn/Meine Chicken Nuggets Verbrennen.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/kaptn/Nebenrisiken.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/kaptn/Nebenrisiken.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Ahhh.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Ahhh.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Cannier.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Cannier.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Canny.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Canny.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Dir mache ich Beine.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Dir mache ich Beine.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Du willst das Buch.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Du willst das Buch.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Estoy Loco.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Estoy Loco.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Et wird Suppe jejessen.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Et wird Suppe jejessen.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Halt die Fresse.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Halt die Fresse.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Hee Hee.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Hee Hee.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Helikopter.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Helikopter.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Ich hab gar niks gemacht.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Ich hab gar niks gemacht.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Jaegermeister.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Jaegermeister.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Kuckuck du kleine Schlampe.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Kuckuck du kleine Schlampe.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Pornhub.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Pornhub.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Red Sun Earrape.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Red Sun Earrape.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Sexy Anne.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Sexy Anne.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Tagesschau.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Tagesschau.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Uncanny.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Uncanny.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Wallah Kriese.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Wallah Kriese.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Was ist denn hier los.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Was ist denn hier los.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Wiide.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Wiide.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Willige Opfer.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Willige Opfer.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/marius/Zeig Titten.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/marius/Zeig Titten.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/tit/Ab in Knast.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/tit/Ab in Knast.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/tit/Bitconnect.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/tit/Bitconnect.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
heidi-sounds/vinz/VINZENT.mkv
(Stored with Git LFS)
Normal file
BIN
heidi-sounds/vinz/VINZENT.mkv
(Stored with Git LFS)
Normal file
Binary file not shown.
145
heidi_client.py
Normal file
145
heidi_client.py
Normal file
@ -0,0 +1,145 @@
|
||||
import configparser
|
||||
from discord import app_commands, Message, VoiceState
|
||||
|
||||
from heidi_constants import *
|
||||
from heidi_helpers import *
|
||||
|
||||
|
||||
class HeidiClient(discord.Client):
|
||||
def __init__(self, *, intents: discord.Intents):
|
||||
super().__init__(status="Nur eine kann GNTM werden!", intents=intents)
|
||||
|
||||
# Separate object that keeps all application command state
|
||||
self.tree = app_commands.CommandTree(self)
|
||||
|
||||
# Handle persistent user configuration
|
||||
self.user_config = configparser.ConfigParser()
|
||||
if not os.path.exists(f"{CONFIGPATH}/{USERCONFIGNAME}"):
|
||||
open(f"{CONFIGPATH}/{USERCONFIGNAME}", "x")
|
||||
self.user_config.read(f"{CONFIGPATH}/{USERCONFIGNAME}")
|
||||
self.update_to_default_user_config()
|
||||
self.print_user_config()
|
||||
|
||||
# automatic actions on all messages
|
||||
# on_message_triggers is a map with tuples of two functions: (predicate, action)
|
||||
# the predicate receives the message as argument
|
||||
# if the predicate is true the action is performed
|
||||
self.on_message_triggers = {
|
||||
# lambda m: m.author.nick.lower() in self.models.get_in_names(): self.autoreact_to_girls,
|
||||
lambda m: "jeremy" in m.author.nick.lower(): self._autoreact_to_jeremy,
|
||||
lambda m: "kardashian" in m.author.nick.lower()
|
||||
or "jenner" in m.author.nick.lower(): self._autoreact_to_kardashian,
|
||||
}
|
||||
|
||||
# automatic actions on voice state changes
|
||||
# on_voice_state_triggers is a map with tuples of two functions: (predicate, action)
|
||||
# the predicate receives the member, before- and after-state as arguments
|
||||
# if the predicate is true, the action is performed
|
||||
self.on_voice_state_triggers = {
|
||||
lambda m, b, a: b.channel != a.channel
|
||||
and a.channel is not None
|
||||
and isinstance(a.channel, VoiceChannel): self._play_entrance_sound,
|
||||
}
|
||||
|
||||
# Synchronize commands to guilds
|
||||
async def setup_hook(self):
|
||||
self.tree.copy_global_to(guild=LINUS_GUILD)
|
||||
await self.tree.sync(guild=LINUS_GUILD)
|
||||
|
||||
self.tree.copy_global_to(guild=TEST_GUILD)
|
||||
await self.tree.sync(guild=TEST_GUILD)
|
||||
|
||||
def update_to_default_user_config(self) -> None:
|
||||
"""
|
||||
Adds config keys to the config, if they don't exist yet.
|
||||
This writes the user config file.
|
||||
"""
|
||||
user_config_sections = ["ENTRANCE.SOUND"]
|
||||
|
||||
for section in user_config_sections:
|
||||
if section not in self.user_config:
|
||||
print(f"Adding section {section} to {CONFIGPATH}/{USERCONFIGNAME}")
|
||||
self.user_config[section] = dict()
|
||||
|
||||
self.write_user_config()
|
||||
|
||||
def print_user_config(self) -> None:
|
||||
"""
|
||||
Print the current user config from memory.
|
||||
This does not read the user config file.
|
||||
"""
|
||||
print("Heidi User Config:\n")
|
||||
|
||||
for section in self.user_config.sections():
|
||||
print(f"[{section}]")
|
||||
for key in self.user_config[section]:
|
||||
print(f"{key}={self.user_config[section][key]}")
|
||||
|
||||
print("")
|
||||
|
||||
def write_user_config(self) -> None:
|
||||
"""
|
||||
Write the current configuration to disk.
|
||||
"""
|
||||
if not os.path.exists(f"{CONFIGPATH}/{USERCONFIGNAME}"):
|
||||
print(f"Error: {CONFIGPATH}/{USERCONFIGNAME} doesn't exist!")
|
||||
return
|
||||
|
||||
print(f"Writing {CONFIGPATH}/{USERCONFIGNAME}")
|
||||
|
||||
with open(f"{CONFIGPATH}/{USERCONFIGNAME}", "w") as file:
|
||||
self.user_config.write(file)
|
||||
|
||||
# Automatic Actions ------------------------------------------------------------------------------
|
||||
|
||||
@staticmethod
|
||||
async def _autoreact_to_jeremy(message: Message) -> None:
|
||||
"""
|
||||
🧀 Jeremy.
|
||||
This function is set in on_message_triggers and triggered by the on_message event.
|
||||
"""
|
||||
await message.add_reaction("🧀")
|
||||
|
||||
@staticmethod
|
||||
async def _autoreact_to_kardashian(message: Message) -> None:
|
||||
"""
|
||||
💄 Kardashian.
|
||||
This function is set in on_message_triggers and triggered by the on_message event.
|
||||
"""
|
||||
await message.add_reaction("💄")
|
||||
|
||||
async def _play_entrance_sound(
|
||||
self,
|
||||
member: Member,
|
||||
before: VoiceState,
|
||||
after: VoiceState,
|
||||
) -> None:
|
||||
"""
|
||||
Play a sound when a member joins a voice channel (and another member is present).
|
||||
This function is set in on_voice_state_triggers and triggered by the on_voice_state_update event.
|
||||
"""
|
||||
|
||||
# Don't play anything when no other users are present
|
||||
if (
|
||||
member is not None
|
||||
and member.voice is not None
|
||||
and member.voice.channel is not None
|
||||
and len(member.voice.channel.members) <= 1
|
||||
):
|
||||
print("Not playing entrance sound, as no other members are present")
|
||||
return
|
||||
|
||||
soundpath: Union[str, None] = self.user_config["ENTRANCE.SOUND"].get(
|
||||
member.name, None
|
||||
)
|
||||
|
||||
if soundpath is None:
|
||||
print(f"User {member.name} has not set an entrance sound")
|
||||
return
|
||||
|
||||
board, sound = soundpath.split("/")
|
||||
|
||||
# Wait a bit to not have simultaneous joins
|
||||
await asyncio.sleep(1)
|
||||
|
||||
await play_voice_line_for_member(None, member, board, sound)
|
||||
29
heidi_constants.py
Normal file
29
heidi_constants.py
Normal file
@ -0,0 +1,29 @@
|
||||
import os
|
||||
import discord
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# This is run when this file is imported
|
||||
load_dotenv()
|
||||
|
||||
print("Debug: Importing heidi_constants.py")
|
||||
|
||||
|
||||
# ================================================================================================ #
|
||||
# ================================================================================================ #
|
||||
# NOTE: Always set this correctly:
|
||||
DOCKER = os.getenv("DOCKER") == "True"
|
||||
# ================================================================================================ #
|
||||
# ================================================================================================ #
|
||||
|
||||
# Constants
|
||||
CONFIGPATH = "/config" if DOCKER else "."
|
||||
USERCONFIGNAME = "Heidi_User.conf"
|
||||
|
||||
SOUNDDIR: str = "/sounds" if DOCKER else "./heidi-sounds"
|
||||
|
||||
# IDs of the servers Heidi is used on
|
||||
LINUS_GUILD = discord.Object(id=431154792308408340)
|
||||
TEST_GUILD = discord.Object(id=821511861178204161)
|
||||
|
||||
# Channel IDs
|
||||
HEIDI_SPAM_ID = 822223476101742682
|
||||
105
heidi_helpers.py
Normal file
105
heidi_helpers.py
Normal file
@ -0,0 +1,105 @@
|
||||
import asyncio
|
||||
import functools
|
||||
from typing import Union
|
||||
|
||||
import discord
|
||||
from discord import Interaction, VoiceChannel, Member
|
||||
|
||||
from heidi_constants import *
|
||||
|
||||
print("Debug: Importing heidi_helpers.py")
|
||||
|
||||
|
||||
# Checks -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# 1. @enforce_channel(ID) is added to a function, which evaluates to decorate with the channel_id in its closure
|
||||
# 2. The function is passed to decorate(function),
|
||||
def enforce_channel(channel_id):
|
||||
"""
|
||||
Only run a function if called from the correct channel.
|
||||
"""
|
||||
def decorate(function):
|
||||
|
||||
@functools.wraps(function)
|
||||
async def wrapped(*args, **kwargs):
|
||||
"""
|
||||
Sends an interaction response if the interaction is not triggered from the heidi_spam channel.
|
||||
"""
|
||||
interaction: Interaction = args[0]
|
||||
|
||||
# Do not call the decorated function if the channel_id doesn't match
|
||||
if not interaction.channel_id == channel_id:
|
||||
await interaction.response.send_message("Heidi sagt: Geh in heidi_spam du dulli", ephemeral=True)
|
||||
return
|
||||
|
||||
await function(*args, **kwargs)
|
||||
|
||||
return wrapped
|
||||
|
||||
return decorate
|
||||
|
||||
|
||||
# Sounds -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# @todo Normalize volume when playing
|
||||
async def play_voice_line(
|
||||
interaction: Union[Interaction, None],
|
||||
voice_channel: VoiceChannel,
|
||||
board: str,
|
||||
sound: str,
|
||||
) -> None:
|
||||
"""
|
||||
Play a voice line in the specified channel.
|
||||
"""
|
||||
try:
|
||||
open(f"{SOUNDDIR}/{board}/{sound}")
|
||||
except IOError:
|
||||
print(f"Error: Invalid soundfile {SOUNDDIR}/{board}/{sound}!")
|
||||
if interaction is not None:
|
||||
await interaction.response.send_message(
|
||||
f'Heidi sagt: "{board}/{sound}" kanninich finden bruder',
|
||||
ephemeral=True
|
||||
)
|
||||
return
|
||||
|
||||
if interaction is not None:
|
||||
await interaction.response.send_message(f'Heidi sagt: "{board}/{sound}"', ephemeral=True)
|
||||
|
||||
audio_source = discord.FFmpegPCMAudio(
|
||||
f"{SOUNDDIR}/{board}/{sound}"
|
||||
) # only works from docker
|
||||
voice_client = await voice_channel.connect()
|
||||
voice_client.play(audio_source)
|
||||
|
||||
while voice_client.is_playing():
|
||||
await asyncio.sleep(1)
|
||||
|
||||
await voice_client.disconnect()
|
||||
|
||||
|
||||
async def play_voice_line_for_member(
|
||||
interaction: Union[Interaction, None],
|
||||
member: Member,
|
||||
board: str,
|
||||
sound: str,
|
||||
) -> None:
|
||||
"""
|
||||
Play a voice line in the member's current channel.
|
||||
"""
|
||||
# Member needs to be in voice channel to hear audio (Heidi needs to know the channel to join)
|
||||
if (
|
||||
member is None
|
||||
or member.voice is None
|
||||
or member.voice.channel is None
|
||||
or not isinstance(member.voice.channel, VoiceChannel)
|
||||
):
|
||||
print("User not in (valid) voice channel!")
|
||||
if interaction is not None:
|
||||
await interaction.response.send_message("Heidi sagt: Komm in den Channel!", ephemeral=True)
|
||||
return
|
||||
|
||||
voice_channel: VoiceChannel = member.voice.channel
|
||||
|
||||
await play_voice_line(interaction, voice_channel, board, sound)
|
||||
@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd /home/christoph/HeidiBot
|
||||
git pull
|
||||
|
||||
docker pull registry.gitlab.com/churl/heidibot
|
||||
docker container rm -f heidibot
|
||||
docker run -d --env-file /home/christoph/HeidiBot/.env --mount src=/home/christoph/HeidiBot/voicelines,target=/sounds,type=bind --name heidibot registry.gitlab.com/churl/heidibot
|
||||
docker image prune -f
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user