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
+74 -80
View File
@@ -1,75 +1,73 @@
from datetime import datetime
import io
import json
from datetime import datetime
import requests
from pyrogram import Client, enums, filters
from pyrogram.types import Message
import io
from utils.misc import modules_help, prefix
TIKTOK_API_URL = "https://api.maher-zubair.tech/stalk/tiktok?q="
INSTAGRAM_API_URL = "https://tools.betabotz.eu.org/tools/stalk-ig?q="
GH_STALK = "https://api.github.com/users/"
TIKTOK_API_URL = 'https://api.maher-zubair.tech/stalk/tiktok?q='
INSTAGRAM_API_URL = 'https://tools.betabotz.eu.org/tools/stalk-ig?q='
GH_STALK = 'https://api.github.com/users/'
@Client.on_message(filters.command(["tiktokstalk"], prefix) & filters.me)
@Client.on_message(filters.command(['tiktokstalk'], prefix) & filters.me)
async def tiktok_stalk(_, message: Message):
query = ""
query = ''
if len(message.command) > 1:
query = message.command[1]
elif message.reply_to_message:
query = message.reply_to_message.text.strip()
if not query:
await message.edit(
"Usage: `tiktokstalk <username>` or reply to a message containing the username."
)
await message.edit('Usage: `tiktokstalk <username>` or reply to a message containing the username.')
return
await message.edit("Fetching TikTok profile...")
url = f"{TIKTOK_API_URL}{query}"
await message.edit('Fetching TikTok profile...')
url = f'{TIKTOK_API_URL}{query}'
response = requests.get(url)
if response.status_code == 200:
data = response.json().get("result", {})
data = response.json().get('result', {})
if data:
profile_pic_url = data.get("profile", "")
profile_pic_url = data.get('profile', '')
profile_pic = requests.get(profile_pic_url).content
profile_pic_stream = io.BytesIO(profile_pic)
profile_pic_stream.name = "profile.jpg"
profile_pic_stream.name = 'profile.jpg'
await message.reply_photo(
photo=profile_pic_stream,
caption=(
f"</b>TikTok Profile:</b>\n"
f"</b>Name:</b> {data.get('name', 'N/A')}\n"
f"</b>Username:</b> {data.get('username', 'N/A')}\n"
f"</b>Followers:</b> {data.get('followers', 'N/A')}\n"
f"</b>Following:</b> {data.get('following', 'N/A')}\n"
f"</b>Likes:</b> {data.get('likes', 'N/A')}\n"
f"</b>Description:</b> {data.get('desc', 'N/A')}\n"
f"</b>Bio:</b> {data.get('bio', 'N/A')}"
f'</b>TikTok Profile:</b>\n'
f'</b>Name:</b> {data.get("name", "N/A")}\n'
f'</b>Username:</b> {data.get("username", "N/A")}\n'
f'</b>Followers:</b> {data.get("followers", "N/A")}\n'
f'</b>Following:</b> {data.get("following", "N/A")}\n'
f'</b>Likes:</b> {data.get("likes", "N/A")}\n'
f'</b>Description:</b> {data.get("desc", "N/A")}\n'
f'</b>Bio:</b> {data.get("bio", "N/A")}'
),
parse_mode=enums.ParseMode.MARKDOWN,
)
else:
await message.edit("No data found for this TikTok user.")
await message.edit('No data found for this TikTok user.')
await message.delete()
else:
await message.edit("An error occurred, please try again later.")
await message.edit('An error occurred, please try again later.')
@Client.on_message(filters.command("ipinfo", prefix) & filters.me)
@Client.on_message(filters.command('ipinfo', prefix) & filters.me)
async def ipinfo(_, message: Message):
searchip = message.text.split(" ", 1)
searchip = message.text.split(' ', 1)
if len(searchip) == 1:
await message.edit_text(f"Usage:{prefix}ipinfo [ip]")
await message.edit_text(f'Usage:{prefix}ipinfo [ip]')
return
searchip = searchip[1]
m = await message.edit_text("Searching...")
await m.edit_text("🔎")
m = await message.edit_text('Searching...')
await m.edit_text('🔎')
try:
url = requests.get(
f"http://ip-api.com/json/{searchip}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query"
f'http://ip-api.com/json/{searchip}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query'
)
response = json.loads(url.text)
text = f"""
@@ -98,10 +96,10 @@ async def ipinfo(_, message: Message):
<b>Hosting:</b> <code>{response['hosting']}</code>"""
await m.edit_text(text)
except:
await m.edit_text("Unable To Find Info!")
await m.edit_text('Unable To Find Info!')
@Client.on_message(filters.command("instastalk", prefix) & filters.me)
@Client.on_message(filters.command('instastalk', prefix) & filters.me)
async def instagram_stalk(_, message: Message):
if len(message.command) > 1:
query = message.text.split(maxsplit=1)[1]
@@ -109,43 +107,43 @@ async def instagram_stalk(_, message: Message):
query = message.reply_to_message.text
else:
await message.edit(
f"Usage: <code>{prefix}instastalk <username></code> or reply to a message containing the username."
f'Usage: <code>{prefix}instastalk <username></code> or reply to a message containing the username.'
)
return
await message.edit("Fetching Instagram profile...")
url = f"{INSTAGRAM_API_URL}{query}"
await message.edit('Fetching Instagram profile...')
url = f'{INSTAGRAM_API_URL}{query}'
response = requests.get(url)
if response.status_code == 200:
data = response.json().get("result", {}).get("user_info", {})
data = response.json().get('result', {}).get('user_info', {})
if data:
profile_pic_url = data.get("profile_pic_url", "")
profile_pic_url = data.get('profile_pic_url', '')
profile_pic = requests.get(profile_pic_url).content
profile_pic_stream = io.BytesIO(profile_pic)
profile_pic_stream.name = "profile.jpg"
profile_pic_stream.name = 'profile.jpg'
await message.reply_photo(
photo=profile_pic_stream,
caption=(
f"</b>Instagram Profile:</b>\n"
f"</b>Full Name:</b> {data.get('full_name', 'N/A')}\n"
f"</b>Username:</b> {data.get('username', 'N/A')}\n"
f"</b>Biography:</b> {data.get('biography', 'N/A')}\n"
f"</b>External URL:</b> {data.get('external_url', 'N/A')}\n"
f"</b>Posts:</b> {data.get('posts', 'N/A')}\n"
f"</b>Followers:</b> {data.get('followers', 'N/A')}\n"
f"</b>Following:</b> {data.get('following', 'N/A')}"
f'</b>Instagram Profile:</b>\n'
f'</b>Full Name:</b> {data.get("full_name", "N/A")}\n'
f'</b>Username:</b> {data.get("username", "N/A")}\n'
f'</b>Biography:</b> {data.get("biography", "N/A")}\n'
f'</b>External URL:</b> {data.get("external_url", "N/A")}\n'
f'</b>Posts:</b> {data.get("posts", "N/A")}\n'
f'</b>Followers:</b> {data.get("followers", "N/A")}\n'
f'</b>Following:</b> {data.get("following", "N/A")}'
),
parse_mode=enums.ParseMode.MARKDOWN,
)
else:
await message.edit("No data found for this Instagram user.")
await message.edit('No data found for this Instagram user.')
await message.delete()
else:
await message.edit("An error occurred, please try again later.")
await message.edit('An error occurred, please try again later.')
@Client.on_message(filters.command("ghstalk", prefix) & filters.me)
@Client.on_message(filters.command('ghstalk', prefix) & filters.me)
async def github_stalk(_, message: Message):
if len(message.command) > 1:
query = message.text.split(maxsplit=1)[1]
@@ -153,48 +151,44 @@ async def github_stalk(_, message: Message):
query = message.reply_to_message.text
else:
await message.edit(
f"Usage: <code>{prefix}ghstalk <username></code> or reply to a message containing the username."
f'Usage: <code>{prefix}ghstalk <username></code> or reply to a message containing the username.'
)
return
await message.edit("Fetching GitHub profile...")
url = f"{GH_STALK}{query}"
await message.edit('Fetching GitHub profile...')
url = f'{GH_STALK}{query}'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
created_at = data.get("created_at", "N/A")
formatted_date = (
datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S%z")
if created_at != "N/A"
else None
)
created_at = data.get('created_at', 'N/A')
formatted_date = datetime.strptime(created_at, '%Y-%m-%dT%H:%M:%S%z') if created_at != 'N/A' else None
if data:
await message.reply_photo(
photo=data.get("avatar_url", "").replace("?v=4", ""),
caption=f"</b>GitHub Profile:</b>\n"
f"</b>Name:</b> {data.get('name', 'N/A')}\n"
f"</b>Username:</b> {data.get('login', 'N/A')}\n"
f"</b>Bio:</b> {data.get('bio', 'N/A')}\n"
photo=data.get('avatar_url', '').replace('?v=4', ''),
caption=f'</b>GitHub Profile:</b>\n'
f'</b>Name:</b> {data.get("name", "N/A")}\n'
f'</b>Username:</b> {data.get("login", "N/A")}\n'
f'</b>Bio:</b> {data.get("bio", "N/A")}\n'
f"</b>Public Repositories:</b> <a href='{data.get('repos_url', '')}'>{data.get('public_repos', 'N/A')}</a>\n"
f"</b>Public Gists:</b> <a href='{data.get('gists_url', '')}'>{data.get('public_gists', 'N/A')}</a>\n"
f"</b>Company:</b> {data.get('company', 'N/A')}\n"
f"</b>Location:</b> {data.get('location', 'N/A')}\n"
f"</b>Email:</b> {data.get('email', 'N/A')}\n"
f"</b>Website:</b> {data.get('blog', 'N/A')}\n"
f"</b>Created At:</b> {formatted_date.strftime('%Y-%m-%d %I:%M:%S %p') if formatted_date else 'N/A'}\n"
f"</b>Hireable:</b> {data.get('hireable', 'N/A')}\n"
f"</b>Followers:</b> {data.get('followers', 'N/A')}\n"
f"</b>Following:</b> {data.get('following', 'N/A')}",
f'</b>Company:</b> {data.get("company", "N/A")}\n'
f'</b>Location:</b> {data.get("location", "N/A")}\n'
f'</b>Email:</b> {data.get("email", "N/A")}\n'
f'</b>Website:</b> {data.get("blog", "N/A")}\n'
f'</b>Created At:</b> {formatted_date.strftime("%Y-%m-%d %I:%M:%S %p") if formatted_date else "N/A"}\n'
f'</b>Hireable:</b> {data.get("hireable", "N/A")}\n'
f'</b>Followers:</b> {data.get("followers", "N/A")}\n'
f'</b>Following:</b> {data.get("following", "N/A")}',
)
else:
await message.edit("No data found for this GitHub user.")
await message.edit('No data found for this GitHub user.')
else:
await message.edit("An error occurred, please try again later.")
await message.edit('An error occurred, please try again later.')
modules_help["socialstalk"] = {
"tiktokstalk [username]*": "Get TikTok profile information",
"ipinfo [IP address]*": "Get information about an IP address",
"instastalk [username]*": "Get Instagram profile information",
"ghstalk [username]*": "Get GitHub profile information",
modules_help['socialstalk'] = {
'tiktokstalk [username]*': 'Get TikTok profile information',
'ipinfo [IP address]*': 'Get information about an IP address',
'instastalk [username]*': 'Get Instagram profile information',
'ghstalk [username]*': 'Get GitHub profile information',
}