Skip to content

Commit

Permalink
added debug tool
Browse files Browse the repository at this point in the history
  • Loading branch information
bomzheg committed Oct 11, 2023
1 parent af24aca commit ac6a2d3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/handlers/superuser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Iterable

from aiogram import Bot, Router
from aiogram import Bot, Router, enums
from aiogram.filters import Command
from aiogram.types import Message, BufferedInputFile
from functools import partial
Expand All @@ -25,6 +25,16 @@ async def get_dump(_: Message, config: Config, bot: Bot):
await bot.send_document(config.dump_chat_id, BufferedInputFile(f.read(), "karma.db"))


async def show_tagged_users(message: Message):
result = ""
for e in message.reply_to_message.entities:
if e.type == "text_mention":
result += f"\n{e.type} - {e.user.full_name}"
if e.type == "mention":
result += f"\n{e.type} - {e.extract_from(message.text or message.caption)}"
await message.reply(result)


def setup_superuser(bot_config: Config) -> Router:
router = Router(name=__name__)
is_superuser_ = partial(is_superuser, superusers=bot_config.superusers)
Expand All @@ -33,5 +43,6 @@ def setup_superuser(bot_config: Config) -> Router:
router.message.register(exception, Command(commands="exception"))
router.message.register(leave_chat, Command(commands="get_out"))
router.message.register(get_dump, Command(commands="dump"))
router.message.register(show_tagged_users, Command(commands="entities", prefix="!/"))

return router

0 comments on commit ac6a2d3

Please sign in to comment.