1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 11:34:18 +00:00

mm doesn't work yet, and neither do breakpoints wtf

This commit is contained in:
Steffo 2020-09-04 00:37:19 +02:00
parent 08a052b79c
commit 2fcc651537
5 changed files with 24 additions and 14 deletions

View file

@ -22,7 +22,7 @@ from .help import HelpCommand
from .leagueoflegends import LeagueoflegendsCommand
from .magickfiorygi import MagickfiorygiCommand
from .magicktreasure import MagicktreasureCommand
# from .matchmaking import MatchmakingCommand
from .matchmaking import MatchmakingCommand
from .ping import PingCommand
from .pmots import PmotsCommand
from .dog import DogCommand
@ -63,7 +63,7 @@ available_commands = [
LeagueoflegendsCommand,
MagickfiorygiCommand,
MagicktreasureCommand,
# MatchmakingCommand,
MatchmakingCommand,
PingCommand,
PmotsCommand,
DogCommand,

View file

@ -70,13 +70,14 @@ class MatchmakingCommand(rc.Command):
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
"""Handle a matchmaking command call."""
author = await data.get_author(error_if_none=True)
# Parse the arguments, either with the standard syntax or with the Proto syntax
dt, title, description = self._parse_args(args)
# Add the MMEvent to the database
async with data.session_acm() as session:
author = await data.find_author(session=session, required=True)
mmevent: MMEvent = self.alchemy.get(MMEvent)(creator=author,
datetime=dt,
title=title,
@ -85,8 +86,8 @@ class MatchmakingCommand(rc.Command):
session.add(mmevent)
await ru.asyncify(session.commit)
# Create and run a task for the newly created MMEvent
task = MMTask(mmevent.mmid, command=self)
task.start()
# Create and run a task for the newly created MMEvent
task = MMTask(mmevent.mmid, command=self)
task.start()
await data.reply(f"🚩 Matchmaking creato!")

View file

@ -28,7 +28,6 @@ class DiscordCvEvent(rc.HeraldEvent):
guild: discord.Guild = client.get_guild(guild_id)
members: List[Union[discord.User, discord.Member]] = guild.members
channels: List[discord.VoiceChannel] = guild.voice_channels
results = []
@ -88,6 +87,5 @@ class DiscordCvEvent(rc.HeraldEvent):
"id": guild.id,
"name": guild.name,
"members": results,
"channels": channels,
}
}

View file

@ -1,5 +1,5 @@
# from .mmtask import MMTask
from .mmtask import MMTask
__all__ = [
# "MMTask",
"MMTask",
]

View file

@ -310,14 +310,17 @@ class MMTask:
return InKM(rows)
def register_telegram_keyboard(self, inkm: InKM):
# noinspection PyListCreation
assert isinstance(self.command.serf, rst.TelegramSerf)
royalnet_keyboard = self.royalnet_keyboard
for x, row in enumerate(inkm.inline_keyboard):
for y, key in enumerate(row):
key: InKB
self.command.serf.register_keyboard_key(key.callback_data, key=royalnet_keyboard[x][y])
self.command.serf.register_keyboard_key(key.callback_data,
key=royalnet_keyboard[x][y],
command=self.command)
def unregister_telegram_keyboard(self, inkm: InKM):
assert isinstance(self.command.serf, rst.TelegramSerf)
for row in inkm.inline_keyboard:
for key in row:
key: InKB
@ -332,14 +335,15 @@ class MMTask:
@property
def telegram_channel_id(self):
return self.command.config["Matchmaking"]["mm_telegram_channel_id"]
return self.command.config["matchmaking"]["channel_id"]
@property
def telegram_group_id(self):
return self.command.config["Matchmaking"]["mm_telegram_group_id"]
return self.command.config["matchmaking"]["group_id"]
@contextlib.asynccontextmanager
async def telegram_channel_message(self):
assert isinstance(self.command.serf, rst.TelegramSerf)
# Generate the InlineKeyboardMarkup
inkm = self.telegram_keyboard
@ -385,6 +389,9 @@ class MMTask:
async def telegram_channel_message_update(self):
log.debug(f"Updating message for: {self.mmid}")
assert isinstance(self.command.serf, rst.TelegramSerf)
try:
await ru.asyncify(
self.command.serf.client.edit_message_text,
@ -399,6 +406,8 @@ class MMTask:
log.warning(f"TelegramError during update: {e}")
async def telegram_group_message_start(self):
assert isinstance(self.command.serf, rst.TelegramSerf)
await self.command.serf.api_call(
self.command.serf.client.send_message,
chat_id=self.telegram_group_id,
@ -408,6 +417,8 @@ class MMTask:
)
async def telegram_group_message_delete(self):
assert isinstance(self.command.serf, rst.TelegramSerf)
await self.command.serf.api_call(
self.command.serf.client.send_message,
chat_id=self.telegram_group_id,