mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Possibly some mm bugfixes
This commit is contained in:
parent
1c5ce6502f
commit
4ebe2a5577
1 changed files with 15 additions and 4 deletions
|
@ -4,6 +4,7 @@ import os
|
||||||
import telegram
|
import telegram
|
||||||
import asyncio
|
import asyncio
|
||||||
import re
|
import re
|
||||||
|
import logging
|
||||||
from ..command import Command
|
from ..command import Command
|
||||||
from ..commandargs import CommandArgs
|
from ..commandargs import CommandArgs
|
||||||
from ..commanddata import CommandData
|
from ..commanddata import CommandData
|
||||||
|
@ -11,6 +12,8 @@ from ...database.tables import MMEvent, MMDecision, MMResponse
|
||||||
from ...error import *
|
from ...error import *
|
||||||
from ...utils import asyncify, telegram_escape, sleep_until
|
from ...utils import asyncify, telegram_escape, sleep_until
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class MmCommand(Command):
|
class MmCommand(Command):
|
||||||
"""Matchmaking command.
|
"""Matchmaking command.
|
||||||
|
@ -239,15 +242,13 @@ class MmCommand(Command):
|
||||||
chat_id=mmresponse.royal.telegram[0].tg_id,
|
chat_id=mmresponse.royal.telegram[0].tg_id,
|
||||||
text=telegram_escape(started_string()),
|
text=telegram_escape(started_string()),
|
||||||
parse_mode="HTML",
|
parse_mode="HTML",
|
||||||
disable_webpage_preview=True,
|
disable_webpage_preview=True)
|
||||||
reply_markup=response_keyboard)
|
|
||||||
else:
|
else:
|
||||||
await self.interface.bot.safe_api_call(client.send_message,
|
await self.interface.bot.safe_api_call(client.send_message,
|
||||||
chat_id=mmresponse.royal.telegram[0].tg_id,
|
chat_id=mmresponse.royal.telegram[0].tg_id,
|
||||||
text=telegram_escape(started_without_you_string),
|
text=telegram_escape(started_without_you_string),
|
||||||
parse_mode="HTML",
|
parse_mode="HTML",
|
||||||
disable_webpage_preview=True,
|
disable_webpage_preview=True)
|
||||||
reply_markup=response_keyboard)
|
|
||||||
await asyncify(self.interface.session.commit)
|
await asyncify(self.interface.session.commit)
|
||||||
await update_message()
|
await update_message()
|
||||||
|
|
||||||
|
@ -331,6 +332,16 @@ class MmCommand(Command):
|
||||||
self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_r_NO")
|
self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_r_NO")
|
||||||
self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_start")
|
self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_start")
|
||||||
|
|
||||||
|
def __init__(self, interface):
|
||||||
|
super().__init__(interface)
|
||||||
|
log.debug("Loading pending MMEvents from the database")
|
||||||
|
mmevents = self.interface.session.query(self.interface.alchemy.MMEvent) \
|
||||||
|
.filter(self.interface.alchemy.MMEvent.datetime > datetime.datetime.now()) \
|
||||||
|
.all()
|
||||||
|
log.info(f"Found {len(mmevents)} pending MMEvents")
|
||||||
|
for mmevent in mmevents:
|
||||||
|
interface.loop.create_task(self._run_mm(mmevent))
|
||||||
|
|
||||||
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
async def run(self, args: CommandArgs, data: CommandData) -> None:
|
||||||
if self.interface.name != "telegram":
|
if self.interface.name != "telegram":
|
||||||
raise UnsupportedError("mm is supported only on Telegram")
|
raise UnsupportedError("mm is supported only on Telegram")
|
||||||
|
|
Loading…
Reference in a new issue