-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Natalenko
committed
Jan 4, 2024
1 parent
fb67334
commit 968def6
Showing
245 changed files
with
3,377 additions
and
2,288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from aiogram_dialog import Dialog | ||
|
||
from idb.bot.dialogs.admins.feedbacks.answer.windows.confirm import ( | ||
window as confirm_window, | ||
) | ||
from idb.bot.dialogs.admins.feedbacks.answer.windows.input_message import ( | ||
window as input_message_window, | ||
) | ||
|
||
dialog = Dialog( | ||
input_message_window, | ||
confirm_window, | ||
) |
File renamed without changes.
44 changes: 44 additions & 0 deletions
44
idb/bot/dialogs/admins/feedbacks/answer/windows/confirm.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from datetime import UTC, datetime | ||
|
||
from aiogram.types import CallbackQuery | ||
from aiogram_dialog import DialogManager, Window | ||
from aiogram_dialog.widgets.kbd import Button, Row | ||
from aiogram_dialog.widgets.text import Const | ||
|
||
from idb.bot.dialogs.admins.states import FeedbackAnswerSG | ||
from idb.bot.dialogs.utils.buttons import CANCEL | ||
from idb.db.uow import UnitOfWork | ||
from idb.logic.answer import create_feedback_answer | ||
from idb.logic.feedback import update_answered_feedback | ||
|
||
|
||
async def on_click( | ||
c: CallbackQuery, button: Button, dialog_manager: DialogManager | ||
) -> None: | ||
uow: UnitOfWork = dialog_manager.middleware_data["uow"] | ||
feedback_id = int(dialog_manager.start_data["feedback_id"]) | ||
text = str(dialog_manager.current_context().widget_data["input_answer"]) | ||
answer = await create_feedback_answer( | ||
uow=uow, | ||
feedback_id=feedback_id, | ||
text=text, | ||
from_user_id=dialog_manager.event.from_user.id, # type: ignore[union-attr] | ||
) | ||
|
||
await c.bot.send_message( # type: ignore[union-attr] | ||
chat_id=answer.to_user_id, | ||
text=answer.text, | ||
) | ||
await update_answered_feedback( | ||
uow=uow, | ||
feedback_id=feedback_id, | ||
dt=datetime.now(UTC), | ||
) | ||
await dialog_manager.done() | ||
|
||
|
||
window = Window( | ||
Const("Отправить сообщение?"), | ||
Row(CANCEL, Button(text=Const("📨 Да"), id="send_message", on_click=on_click)), | ||
state=FeedbackAnswerSG.confirm, | ||
) |
27 changes: 27 additions & 0 deletions
27
idb/bot/dialogs/admins/feedbacks/answer/windows/input_message.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from aiogram.types import Message | ||
from aiogram_dialog import DialogManager, Window | ||
from aiogram_dialog.widgets.input import ManagedTextInput, TextInput | ||
from aiogram_dialog.widgets.text import Const | ||
|
||
from idb.bot.dialogs.admins.states import FeedbackAnswerSG | ||
from idb.bot.dialogs.utils.buttons import CANCEL | ||
|
||
|
||
async def on_success_next( | ||
message: Message, | ||
widget: ManagedTextInput[str], | ||
dialog_manager: DialogManager, | ||
value: str, | ||
) -> None: | ||
await dialog_manager.next() | ||
|
||
|
||
window = Window( | ||
Const("Введите сообщение"), | ||
TextInput( | ||
id="input_answer", | ||
on_success=on_success_next, # type: ignore[arg-type] | ||
), | ||
CANCEL, | ||
state=FeedbackAnswerSG.input_message, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from aiogram_dialog import Dialog | ||
|
||
from idb.bot.dialogs.admins.feedbacks.read import ( | ||
item, | ||
menu, | ||
new, | ||
viewed, | ||
) | ||
|
||
dialog = Dialog( | ||
menu.window, | ||
new.window, | ||
viewed.window, | ||
item.window, | ||
) |
Oops, something went wrong.