Compare commits
No commits in common. "59ce255fda2f5fbe76114b1c1f370c30afe2465c" and "ec01447440d0d702974cb638246b38c61eb8b7e3" have entirely different histories.
59ce255fda
...
ec01447440
3 changed files with 19 additions and 17 deletions
|
@ -3,17 +3,19 @@ import logging
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from .commands import lsstuff
|
from .commands import lsstuff
|
||||||
from .post import ev_post
|
from .post import post
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class LenaverseBot(discord.Client):
|
class LenaverseBot(discord.Client):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__(intents=discord.Intents.default())
|
intents = discord.Intents.default()
|
||||||
|
|
||||||
|
super().__init__(intents=intents)
|
||||||
|
|
||||||
self.tree = discord.app_commands.CommandTree(self)
|
self.tree = discord.app_commands.CommandTree(self)
|
||||||
self.tree.add_command(ev_post)
|
self.tree.add_command(post)
|
||||||
self.tree.add_command(lsstuff)
|
self.tree.add_command(lsstuff)
|
||||||
|
|
||||||
async def setup_hook(self):
|
async def setup_hook(self):
|
||||||
|
@ -21,5 +23,7 @@ class LenaverseBot(discord.Client):
|
||||||
_logger.info("Commands synced")
|
_logger.info("Commands synced")
|
||||||
|
|
||||||
async def on_ready(self) -> None:
|
async def on_ready(self) -> None:
|
||||||
assert self.user is not None
|
if self.user is None:
|
||||||
|
return
|
||||||
|
|
||||||
_logger.info(f"{self.user.name} has connected to Discord!")
|
_logger.info(f"{self.user.name} has connected to Discord!")
|
||||||
|
|
|
@ -60,23 +60,17 @@ class PostModal(ui.Modal, title="Post verfassen"):
|
||||||
post_content = f"{self.content.value}\n> Gepostet von <@{interaction.user.id}>"
|
post_content = f"{self.content.value}\n> Gepostet von <@{interaction.user.id}>"
|
||||||
|
|
||||||
# Vorschau mit Buttons
|
# Vorschau mit Buttons
|
||||||
view = PostConfirm()
|
|
||||||
await interaction.response.send_message(
|
await interaction.response.send_message(
|
||||||
content=f"## Post-Vorschau\n\n{post_content}",
|
content=f"## Post-Vorschau\n\n{post_content}",
|
||||||
view=view,
|
view=(view := PostConfirm()),
|
||||||
# nur für ausführenden User
|
# nur für ausführenden User
|
||||||
ephemeral=True,
|
ephemeral=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# warten auf User-Entscheidung
|
# warten auf User-Entscheidung
|
||||||
if await view.wait() is True:
|
await view.wait()
|
||||||
# Entscheidungszeit abgelaufen
|
|
||||||
await interaction.user.send("Zeit abgelaufen, Post verworfen ")
|
|
||||||
_logger.info(
|
|
||||||
f"User {interaction.user.name}({interaction.user.id}) timeout during /post"
|
|
||||||
)
|
|
||||||
|
|
||||||
elif view.action is Action.PUBLISH:
|
if view.action is Action.PUBLISH:
|
||||||
# Post veröffentlichen
|
# Post veröffentlichen
|
||||||
_logger.info(
|
_logger.info(
|
||||||
f"User {interaction.user.name}({interaction.user.id}) published a /post"
|
f"User {interaction.user.name}({interaction.user.id}) published a /post"
|
||||||
|
@ -85,14 +79,18 @@ class PostModal(ui.Modal, title="Post verfassen"):
|
||||||
await target.send(post_content)
|
await target.send(post_content)
|
||||||
|
|
||||||
elif view.action is Action.ABORT:
|
elif view.action is Action.ABORT:
|
||||||
# Post abbrechen
|
|
||||||
_logger.info(
|
_logger.info(
|
||||||
f"User {interaction.user.name}({interaction.user.id}) aborted a /post"
|
f"User {interaction.user.name}({interaction.user.id}) aborted a /post"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
elif view.action is Action.TIMEOUT:
|
||||||
|
_logger.info(
|
||||||
|
f"User {interaction.user.name}({interaction.user.id}) timeout during /post"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@discord.app_commands.command()
|
@discord.app_commands.command()
|
||||||
async def ev_post(interaction: discord.Interaction) -> None:
|
async def post(interaction: discord.Interaction):
|
||||||
"""
|
"""
|
||||||
Einen Post im Lenaisten-Bereich verfassen (nur für ausgewählte Mitglieder verfügbar)
|
Einen Post im Lenaisten-Bereich verfassen (nur für ausgewählte Mitglieder verfügbar)
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
authors = ["Jörn-Michael Miehe <joern-michael.miehe@lenaisten.de>"]
|
authors = ["Jörn-Michael Miehe <joern-michael.miehe@lenaisten.de>"]
|
||||||
description = ""
|
description = ""
|
||||||
name = "lenaverse_bot"
|
name = "lenaverse-bot"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
discord-py = "^2.3.2"
|
discord-py = "^2.3.2"
|
||||||
pydantic = "^2.5.1"
|
|
||||||
python = "^3.11"
|
python = "^3.11"
|
||||||
|
pydantic = "^2.5.1"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
black = "^23.11.0"
|
black = "^23.11.0"
|
||||||
|
|
Loading…
Reference in a new issue