1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +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 .leagueoflegends import LeagueoflegendsCommand
from .magickfiorygi import MagickfiorygiCommand from .magickfiorygi import MagickfiorygiCommand
from .magicktreasure import MagicktreasureCommand from .magicktreasure import MagicktreasureCommand
# from .matchmaking import MatchmakingCommand from .matchmaking import MatchmakingCommand
from .ping import PingCommand from .ping import PingCommand
from .pmots import PmotsCommand from .pmots import PmotsCommand
from .dog import DogCommand from .dog import DogCommand
@ -63,7 +63,7 @@ available_commands = [
LeagueoflegendsCommand, LeagueoflegendsCommand,
MagickfiorygiCommand, MagickfiorygiCommand,
MagicktreasureCommand, MagicktreasureCommand,
# MatchmakingCommand, MatchmakingCommand,
PingCommand, PingCommand,
PmotsCommand, PmotsCommand,
DogCommand, DogCommand,

View file

@ -70,13 +70,14 @@ class MatchmakingCommand(rc.Command):
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
"""Handle a matchmaking command call.""" """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 # Parse the arguments, either with the standard syntax or with the Proto syntax
dt, title, description = self._parse_args(args) dt, title, description = self._parse_args(args)
# Add the MMEvent to the database # Add the MMEvent to the database
async with data.session_acm() as session: async with data.session_acm() as session:
author = await data.find_author(session=session, required=True)
mmevent: MMEvent = self.alchemy.get(MMEvent)(creator=author, mmevent: MMEvent = self.alchemy.get(MMEvent)(creator=author,
datetime=dt, datetime=dt,
title=title, title=title,

View file

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

View file

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

View file

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