Skip to content

Commit

Permalink
added scn to webapp link
Browse files Browse the repository at this point in the history
  • Loading branch information
bomzheg committed Jun 14, 2024
1 parent 2410ae7 commit b8ad208
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion shvatka/tgbot/dialogs/game_manage/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Calendar,
Cancel,
Start,
WebApp,
)
from aiogram_dialog.widgets.media import DynamicMedia
from aiogram_dialog.widgets.text import Const, Format, Case, Jinja
Expand Down Expand Up @@ -101,11 +102,15 @@
on_click=show_zip_scn,
),
SwitchTo(
Const("Сценарий игры"),
Const("Сценарий игры в tg"),
id="game_scn_channel",
state=states.CompletedGamesPanelSG.scenario_channel,
when=F["game"].results.published_chanel_id,
),
WebApp(
url=Format("{webapp_url}"),
text=Const("Сценарий игры на сайте"),
),
SwitchTo(
Const("🔙Назад к списку игр"),
id="to_games",
Expand Down
7 changes: 6 additions & 1 deletion shvatka/tgbot/dialogs/game_manage/getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from aiogram.enums import ContentType
from aiogram_dialog import DialogManager
from aiogram_dialog.api.entities import MediaAttachment, MediaId
from dishka import AsyncContainer
from telegraph import Telegraph

from shvatka.core.models import dto
Expand All @@ -28,11 +29,15 @@ async def get_completed_game(dao: HolderDao, dialog_manager: DialogManager, **_)
game_id = (
dialog_manager.dialog_data.get("game_id", None) or dialog_manager.start_data["game_id"]
)
dishka: AsyncContainer = dialog_manager.middleware_data["dishka_container"]
bot = await dishka.get(Bot)
username = (await bot.get_me()).username
return {
"game": await game.get_game(
id_=game_id,
dao=dao.game,
)
),
"webapp_url": f"https://t.me/{username}/games?startapp={game_id}",
}


Expand Down

0 comments on commit b8ad208

Please sign in to comment.