feat: add about command
This commit is contained in:
parent
3fb147bcbe
commit
7920ee0567
4 changed files with 51 additions and 1 deletions
|
@ -19,7 +19,7 @@ from core.promote import handle_promote_command
|
|||
from core.repeater import MessageRepeater
|
||||
from core.report_links import report_broken_links
|
||||
from core.simple import handle_start_command, handle_baka, dummy_handler, handle_info_command, handle_ping_command, \
|
||||
handle_tips_command
|
||||
handle_tips_command, handle_about_command
|
||||
from core.actions import handle_actions, handle_reverse_actions
|
||||
from core.stats import handle_stats_command
|
||||
from core.middleware.stats import MessageStatsMiddleware
|
||||
|
@ -46,6 +46,7 @@ class TelegramAdapter:
|
|||
# Register handlers on router
|
||||
router.message(CommandStart())(handle_start_command)
|
||||
router.message(Command('info'))(handle_info_command)
|
||||
router.message(Command('about'))(handle_about_command)
|
||||
router.message(Command('ping'))(handle_ping_command)
|
||||
router.message(Command('tips'))(handle_tips_command)
|
||||
# bitflip 模块
|
||||
|
|
|
@ -3,6 +3,8 @@ import asyncio
|
|||
from aiogram import html
|
||||
from aiogram.types import Message
|
||||
|
||||
import config
|
||||
|
||||
|
||||
async def handle_start_command(message: Message) -> None:
|
||||
"""Handle /start command"""
|
||||
|
@ -55,6 +57,33 @@ async def handle_tips_command(message: Message) -> None:
|
|||
await asyncio.sleep(60)
|
||||
await tips_message.delete()
|
||||
|
||||
async def handle_about_command(message: Message) -> None:
|
||||
"""Handle /about command"""
|
||||
import time
|
||||
bot_time_start = time.time()
|
||||
about_message = await message.reply('Loading...')
|
||||
from dulwich.repo import Repo
|
||||
git_commit_hash = Repo('.').head().decode('utf-8')[:7] # Get the first 7 characters of the commit hash
|
||||
response = f"realbot@g{git_commit_hash}\n\n"
|
||||
response += "孩子不懂随便写的 bot\n"
|
||||
if message.chat.id == config.config.get_admin_id():
|
||||
response += '\nDebug Info:\n'
|
||||
import os
|
||||
response += 'Python Version: ' + str(os.sys.version) + '\n'
|
||||
response += 'System Info: ' + '\n' + ' '.join(str(x) for x in os.uname()) + '\n'
|
||||
response += '\n这个命令比较慢,dulwich 负全责(小声),'
|
||||
bot_time_end = time.time()
|
||||
time_diff = bot_time_end - bot_time_start
|
||||
if time_diff < 1:
|
||||
response += f"也就大概花了 {round(time_diff * 1000, 2)} ms..."
|
||||
elif time_diff < 60:
|
||||
response += f"也就大概花了 {round(time_diff, 2)} 秒..."
|
||||
else:
|
||||
minutes = int(time_diff // 60)
|
||||
seconds = round(time_diff % 60, 2)
|
||||
response += f"也就大概花了 {minutes} 分 {seconds} 秒..."
|
||||
await about_message.edit_text(response)
|
||||
|
||||
async def dummy_handler(message: Message) -> None:
|
||||
"""A handler to catch all other messages"""
|
||||
pass
|
|
@ -6,6 +6,7 @@ requires-python = ">=3.13"
|
|||
dependencies = [
|
||||
"aiodns==3.5.0",
|
||||
"aiogram==3.21.0",
|
||||
"dulwich==0.24.1",
|
||||
"mastodon-py==2.0.1",
|
||||
"matrix-nio==0.25.2",
|
||||
"python-abp==0.2.0",
|
||||
|
|
19
uv.lock
generated
19
uv.lock
generated
|
@ -197,6 +197,23 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190, upload-time = "2025-02-24T04:41:32.565Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dulwich"
|
||||
version = "0.24.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "urllib3" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/2b/f3/13a3425ddf04bd31f1caf3f4fa8de2352700c454cb0536ce3f4dbdc57a81/dulwich-0.24.1.tar.gz", hash = "sha256:e19fd864f10f02bb834bb86167d92dcca1c228451b04458761fc13dabd447758", size = 806136, upload-time = "2025-08-01T10:26:46.887Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/5e/a5/3f4760169fea1b90df7aea88172699807af6f4f667c878de6a9ee554170f/dulwich-0.24.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1a11ec69fc6604228804ddfc32c85b22bc627eca4cf4ff3f27dbe822e6f29477", size = 1080923, upload-time = "2025-08-01T10:26:28.011Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/71/d9/7aadd6318aed6f0e1242fa63bd61d80142716d13ea4e307c8b19fc61c9ae/dulwich-0.24.1-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:a9800df7238b586b4c38c00432776781bc889cf02d756dcfb8dc0ecb8fc47a33", size = 1159246, upload-time = "2025-08-01T10:26:29.487Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/90/5d/df4256fe009c714e0392817df4fdc1748a901523504f58796d675fce755f/dulwich-0.24.1-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:3baab4a01aff890e2e6551ccbd33eb2a44173c897f0f027ad3aeab0fb057ec44", size = 1163646, upload-time = "2025-08-01T10:26:31.279Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8d/fe/850115d6fa7ad03756e20466ad5b72be54d1b59c1ff7d2b3c13bc4de965f/dulwich-0.24.1-cp313-cp313-win32.whl", hash = "sha256:b39689aa4d143ba1fb0a687a4eb93d2e630d2c8f940aaa6c6911e9c8dca16e6a", size = 762612, upload-time = "2025-08-01T10:26:33.223Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/47/7f/f79940e0773efda2ed0e666a0ca0ae7c734fdce4f04b5b60bc5ed268b7cb/dulwich-0.24.1-cp313-cp313-win_amd64.whl", hash = "sha256:8fca9b863b939b52c5f759d292499f0d21a7bf7f8cbb9fdeb8cdd9511c5bc973", size = 779168, upload-time = "2025-08-01T10:26:35.303Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c9/bc/a2557d1b0afa5bf1e140f42f8cbca1783e43d7fa17665859c63060957952/dulwich-0.24.1-py3-none-any.whl", hash = "sha256:57cc0dc5a21059698ffa4ed9a7272f1040ec48535193df84b0ee6b16bf615676", size = 440765, upload-time = "2025-08-01T10:26:45.415Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "frozenlist"
|
||||
version = "1.7.0"
|
||||
|
@ -624,6 +641,7 @@ source = { virtual = "." }
|
|||
dependencies = [
|
||||
{ name = "aiodns" },
|
||||
{ name = "aiogram" },
|
||||
{ name = "dulwich" },
|
||||
{ name = "mastodon-py" },
|
||||
{ name = "matrix-nio" },
|
||||
{ name = "python-abp" },
|
||||
|
@ -635,6 +653,7 @@ dependencies = [
|
|||
requires-dist = [
|
||||
{ name = "aiodns", specifier = "==3.5.0" },
|
||||
{ name = "aiogram", specifier = "==3.21.0" },
|
||||
{ name = "dulwich", specifier = "==0.24.1" },
|
||||
{ name = "mastodon-py", specifier = "==2.0.1" },
|
||||
{ name = "matrix-nio", specifier = "==0.25.2" },
|
||||
{ name = "python-abp", specifier = "==0.2.0" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue