Files
forust 0506aaaac8 chore(userbot): apply ruff check --fix and ruff format
- ruff check --fix: 210 auto-fixed errors (import sorting, trailing
  whitespace, unused imports, f-string fixups, deprecated annotations)
- ruff format: 104 files reformatted to consistent style
- 268 non-auto-fixable issues remain (S113 requests timeout, etc.)
2026-06-19 12:19:01 +02:00

95 lines
3.5 KiB
Python

# Moon-Userbot - telegram userbot
# Copyright (C) 2020-present Moon Userbot Organization
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import datetime
import random
from pyrogram import Client, filters
from pyrogram.types import Message
from utils.misc import gitrepo, modules_help, prefix, python_version, userbot_version
@Client.on_message(filters.command(['support', 'repo'], prefix) & filters.me)
async def support(_, message: Message):
devs = ['@Qbtaumai', '@H4T3H46K3R']
random.shuffle(devs)
commands_count = 0.0
for module in modules_help:
for _cmd in module:
commands_count += 1
await message.edit(
f'<b>Moon-Userbot\n\n'
'GitHub: <a href=https://github.com/The-MoonTg-project/Moon-Userbot>Moon-Userbot</a>\n'
'Custom modules repository: <a href=https://github.com/The-MoonTg-project/custom_modules>'
'custom_modules</a>\n'
'License: <a href=https://github.com/The-MoonTg-project/Moon-Userbot/blob/master/LICENSE>GNU GPL v3</a>\n\n'
'Channel: @moonuserbot\n'
'Custom modules: @moonub_modules\n'
'Chat [EN]: @moonub_chat\n'
f'Main developers: {", ".join(devs)}\n\n'
f'Python version: {python_version}\n'
f'Modules count: {len(modules_help) / 1}\n'
f'Commands count: {commands_count}</b>',
disable_web_page_preview=True,
)
@Client.on_message(filters.command(['version', 'ver'], prefix) & filters.me)
async def version(client: Client, message: Message):
changelog = ''
ub_version = '.'.join(userbot_version.split('.')[:2])
async for m in client.search_messages('moonuserbot', query=f'{userbot_version}.'):
if ub_version in m.text:
changelog = m.message_id
await message.delete()
if gitrepo is not None:
remote_url = list(gitrepo.remote().urls)[0]
commit_time = (
datetime.datetime.fromtimestamp(gitrepo.head.commit.committed_date)
.astimezone(datetime.UTC)
.strftime('%Y-%m-%d %H:%M:%S %Z')
)
git_info = (
(
f'\n<b>Branch: <a href={remote_url}/tree/{gitrepo.active_branch}>{gitrepo.active_branch}</a>\n'
if gitrepo.active_branch != 'master'
else '\n'
)
+ f'Commit: <a href={remote_url}/commit/{gitrepo.head.commit.hexsha}>'
f'{gitrepo.head.commit.hexsha[:7]}</a> by {gitrepo.head.commit.author.name}\n'
f'Commit time: {commit_time}</b>'
)
else:
git_info = ''
await message.reply(
f'<b>Moon Userbot version: {userbot_version}\n'
f'Changelog </b><i><a href=https://t.me/moonuserbot/{changelog}>in channel</a></i>.<b>\n'
f'Changelog written by </b><i>'
f'<a href=https://t.me/Qbtaumai>Abhi</a></i>\n\n'
f'{git_info}',
)
modules_help['support'] = {
'support': 'Information about userbot',
'version': 'Check userbot version',
}