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
+33 -33
View File
@@ -1,46 +1,46 @@
from pyrogram import Client, filters
from pyrogram.types import Message
import aiohttp
from datetime import datetime
import aiohttp
from pyrogram import Client, filters
from pyrogram.types import Message
from utils.misc import modules_help, prefix
# Aladhan API credentials
ALADHAN_API_URL = "https://api.aladhan.com/v1/timingsByCity"
ALADHAN_API_URL = 'https://api.aladhan.com/v1/timingsByCity'
DEFAULT_METHOD = 2 # Islamic Society of North America
DEFAULT_CITY = "Lahore"
DEFAULT_COUNTRY = "PK"
DEFAULT_CITY = 'Lahore'
DEFAULT_COUNTRY = 'PK'
async def fetch_namaz_times(city_name: str, country_name: str) -> dict:
params = {"city": city_name, "country": country_name, "method": DEFAULT_METHOD}
params = {'city': city_name, 'country': country_name, 'method': DEFAULT_METHOD}
async with aiohttp.ClientSession() as session:
try:
async with session.get(ALADHAN_API_URL, params=params) as response:
response.raise_for_status()
return await response.json()
except Exception as e:
return {"error": str(e)}
return {'error': str(e)}
def format_time_12hr(time_str: str) -> str:
try:
# Split time into hours and minutes
hours, minutes = map(int, time_str.split(":"))
hours, minutes = map(int, time_str.split(':'))
# Convert to 12-hour format
period = "AM" if hours < 12 else "PM"
period = 'AM' if hours < 12 else 'PM'
if hours == 0:
hours = 12
elif hours > 12:
hours -= 12
elif hours == 12:
period = "PM"
return f"{hours}:{minutes:02d} {period}"
period = 'PM'
return f'{hours}:{minutes:02d} {period}'
except Exception as e:
return f"Error formatting time: {str(e)}"
return f'Error formatting time: {str(e)}'
@Client.on_message(filters.command("prayer", prefix) & filters.me)
@Client.on_message(filters.command('prayer', prefix) & filters.me)
async def namaz_times(client: Client, message: Message):
if message.reply_to_message:
city_name = message.reply_to_message.text
@@ -59,32 +59,32 @@ async def namaz_times(client: Client, message: Message):
data = await fetch_namaz_times(city_name, country_name)
if "error" in data:
result = f"<b>Error:</b> <i>{data['error']}</i>"
elif "data" in data:
timings = data["data"]["timings"]
today = datetime.now().strftime("%Y-%m-%d")
if 'error' in data:
result = f'<b>Error:</b> <i>{data["error"]}</i>'
elif 'data' in data:
timings = data['data']['timings']
today = datetime.now().strftime('%Y-%m-%d')
formatted_timings = {
"Fajr": format_time_12hr(timings["Fajr"]),
"Dhuhr": format_time_12hr(timings["Dhuhr"]),
"Asr": format_time_12hr(timings["Asr"]),
"Maghrib": format_time_12hr(timings["Maghrib"]),
"Isha": format_time_12hr(timings["Isha"]),
'Fajr': format_time_12hr(timings['Fajr']),
'Dhuhr': format_time_12hr(timings['Dhuhr']),
'Asr': format_time_12hr(timings['Asr']),
'Maghrib': format_time_12hr(timings['Maghrib']),
'Isha': format_time_12hr(timings['Isha']),
}
result = (
f"<b>Prayer Times for {city_name}, {country_name} on {today}:</b>\n\n"
f"<b>Fajr:</b> {formatted_timings['Fajr']}\n"
f"<b>Dhuhr:</b> {formatted_timings['Dhuhr']}\n"
f"<b>Asr:</b> {formatted_timings['Asr']}\n"
f"<b>Maghrib:</b> {formatted_timings['Maghrib']}\n"
f"<b>Isha:</b> {formatted_timings['Isha']}\n"
f'<b>Prayer Times for {city_name}, {country_name} on {today}:</b>\n\n'
f'<b>Fajr:</b> {formatted_timings["Fajr"]}\n'
f'<b>Dhuhr:</b> {formatted_timings["Dhuhr"]}\n'
f'<b>Asr:</b> {formatted_timings["Asr"]}\n'
f'<b>Maghrib:</b> {formatted_timings["Maghrib"]}\n'
f'<b>Isha:</b> {formatted_timings["Isha"]}\n'
)
else:
result = "<b>Error:</b> <i>Unable to get prayer times for the specified location.</i>"
result = '<b>Error:</b> <i>Unable to get prayer times for the specified location.</i>'
await message.edit_text(result)
modules_help["namaz"] = {
"prayer [city_name] [country_name]": "Shows the prayer times. Default to Pakistan if no country is provided"
modules_help['namaz'] = {
'prayer [city_name] [country_name]': 'Shows the prayer times. Default to Pakistan if no country is provided'
}