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.)
This commit is contained in:
2026-06-19 12:19:01 +02:00
parent 95cec59263
commit 7ba6bc44f2
104 changed files with 4338 additions and 5319 deletions
+24 -34
View File
@@ -17,72 +17,62 @@
import datetime
from pyrogram import Client, filters, types
from utils.db import db
from utils.misc import modules_help, prefix
# avoid using global variables
afk_info = db.get(
"core.afk",
"afk_info",
'core.afk',
'afk_info',
{
"start": 0,
"is_afk": False,
"reason": "",
'start': 0,
'is_afk': False,
'reason': '',
},
)
is_afk = filters.create(lambda _, __, ___: afk_info["is_afk"])
is_afk = filters.create(lambda _, __, ___: afk_info['is_afk'])
is_support = filters.create(lambda _, __, message: message.chat.is_support)
@Client.on_message(
is_afk
& (filters.private | filters.mentioned)
& ~filters.channel
& ~filters.me
& ~filters.bot
& ~is_support
is_afk & (filters.private | filters.mentioned) & ~filters.channel & ~filters.me & ~filters.bot & ~is_support
)
async def afk_handler(_, message: types.Message):
start = datetime.datetime.fromtimestamp(afk_info["start"])
start = datetime.datetime.fromtimestamp(afk_info['start'])
end = datetime.datetime.now().replace(microsecond=0)
afk_time = end - start
await message.reply(
f"<b>I'm AFK {afk_time}\nReason:</b> <i>{afk_info['reason']}</i>"
)
await message.reply(f"<b>I'm AFK {afk_time}\nReason:</b> <i>{afk_info['reason']}</i>")
@Client.on_message(filters.command("afk", prefix) & filters.me)
@Client.on_message(filters.command('afk', prefix) & filters.me)
async def afk(_, message):
if len(message.text.split()) >= 2:
reason = message.text.split(" ", maxsplit=1)[1]
reason = message.text.split(' ', maxsplit=1)[1]
else:
reason = "None"
reason = 'None'
afk_info["start"] = int(datetime.datetime.now().timestamp())
afk_info["is_afk"] = True
afk_info["reason"] = reason
afk_info['start'] = int(datetime.datetime.now().timestamp())
afk_info['is_afk'] = True
afk_info['reason'] = reason
await message.edit(f"<b>I'm going AFK.\n" f"Reason:</b> <i>{reason}</i>")
await message.edit(f"<b>I'm going AFK.\nReason:</b> <i>{reason}</i>")
db.set("core.afk", "afk_info", afk_info)
db.set('core.afk', 'afk_info', afk_info)
@Client.on_message(filters.command("unafk", prefix) & filters.me)
@Client.on_message(filters.command('unafk', prefix) & filters.me)
async def unafk(_, message):
if afk_info["is_afk"]:
start = datetime.datetime.fromtimestamp(afk_info["start"])
if afk_info['is_afk']:
start = datetime.datetime.fromtimestamp(afk_info['start'])
end = datetime.datetime.now().replace(microsecond=0)
afk_time = end - start
await message.edit(
f"<b>I'm not AFK anymore.\n" f"I was afk {afk_time}</b>"
)
afk_info["is_afk"] = False
await message.edit(f"<b>I'm not AFK anymore.\nI was afk {afk_time}</b>")
afk_info['is_afk'] = False
else:
await message.edit("<b>You weren't afk</b>")
db.set("core.afk", "afk_info", afk_info)
db.set('core.afk', 'afk_info', afk_info)
modules_help["afk"] = {"afk [reason]": "Go to afk", "unafk": "Get out of AFK"}
modules_help['afk'] = {'afk [reason]': 'Go to afk', 'unafk': 'Get out of AFK'}