This commit is contained in:
2026-04-29 10:22:59 +03:00
parent 2904a6b730
commit b380b0ce9b
4 changed files with 18 additions and 49 deletions
-22
View File
@@ -1,22 +0,0 @@
import asyncio
from aiogram import Bot
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from dutylog.infrastructure.utils.config import load_config
USER_ID = 983321451
async def main():
config = load_config()
bot = Bot(token=config.bot.token, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
await bot.send_message(USER_ID, "✅ <b>Ответ от администрации</b> ⬇️")
await bot.send_message(USER_ID, "Да. Анонимно")
await bot.session.close()
if __name__ == "__main__":
asyncio.run(main())
@@ -648,13 +648,13 @@ resident_info_window = Window(
Format("{info_content}"), Format("{info_content}"),
Row( Row(
Button( Button(
Const("Добавить часы"), Const(" Добавить"),
id="add_hours_btn", id="add_hours_btn",
on_click=lambda c, b, m: m.switch_to(AdminMenuSG.add_hours_select), on_click=lambda c, b, m: m.switch_to(AdminMenuSG.add_hours_select),
when=~F["is_admin"], when=~F["is_admin"],
), ),
Button( Button(
Const("Отнять часы"), Const("Отнять"),
id="remove_hours_btn", id="remove_hours_btn",
on_click=lambda c, b, m: m.switch_to(AdminMenuSG.remove_hours_select), on_click=lambda c, b, m: m.switch_to(AdminMenuSG.remove_hours_select),
when=~F["is_admin"], when=~F["is_admin"],
@@ -672,6 +672,7 @@ resident_info_window = Window(
on_click=on_rebind_resident, on_click=on_rebind_resident,
when=~F["is_admin"], when=~F["is_admin"],
), ),
Row(
Button( Button(
Const("🚪 Разлогинить"), Const("🚪 Разлогинить"),
id="logout_resident_btn", id="logout_resident_btn",
@@ -679,10 +680,11 @@ resident_info_window = Window(
when=F["is_busy"] & ~F["is_admin"], when=F["is_busy"] & ~F["is_admin"],
), ),
Button( Button(
Const("🗑 Удалить резидента"), Const("🗑 Удалить"),
id="delete_resident_btn", id="delete_resident_btn",
on_click=lambda c, b, m: m.switch_to(AdminMenuSG.resident_delete_confirm), on_click=lambda c, b, m: m.switch_to(AdminMenuSG.resident_delete_confirm),
when=~F["is_admin"], when=~F["is_admin"],
)
), ),
SwitchTo( SwitchTo(
Const("◀️ Назад к результатам поиска"), Const("◀️ Назад к результатам поиска"),
@@ -38,6 +38,9 @@ async def start_handler(
last_name=message.from_user.last_name, last_name=message.from_user.last_name,
) )
if user and user.username != message.from_user.username:
await users_repository.update_user(user_id=message.from_user.id, username=message.from_user.id)
is_creator = message.from_user.id == config.bot.creator_id is_creator = message.from_user.id == config.bot.creator_id
is_admin = user.is_admin if user else False is_admin = user.is_admin if user else False
@@ -24,20 +24,6 @@ class UsersRepository:
user = await self.users_dao.create(user) user = await self.users_dao.create(user)
return user return user
async def update_user_info(
self,
user_id: int,
username: str | None = None,
first_name: str | None = None,
last_name: str | None = None,
) -> User | None:
return await self.users_dao.update(
user_id,
username=username,
first_name=first_name,
last_name=last_name,
)
async def set_admin_status(self, user_id: int, is_admin: bool) -> User | None: async def set_admin_status(self, user_id: int, is_admin: bool) -> User | None:
return await self.users_dao.update(user_id, is_admin=is_admin) return await self.users_dao.update(user_id, is_admin=is_admin)