chore: batch lint fixes across userbot and edu_master
- S113: Add timeout=10 to all requests calls (74 fixes) - E722: Replace bare except: with except Exception: - B904: Replace redundant re-raise with bare raise - E402: Add noqa for intentional late imports after import_library() - S102/S307/S310/S311/S603/S605/S606/S607/S108: Add noqa for intentional usage - F601: Fix duplicate dict key in unsplash.py - N802: Rename ReplyCheck -> reply_check with backward compat alias - N813: Rename bs -> BS in icons.py - B007/B020: Rename loop var _j in animations.py - SIM102: Collapse nested if in autofwd.py - SIM113: Use enumerate() in calculator.py - A002: Add noqa for builtin shadowing in admlist.py - F811: Add noqa for cohere redefinition - edu_master: Fix ARG001, S108, S110, SIM117, apply --unsafe-fixes - Add modules_list.txt with full module inventory
This commit is contained in:
+13
-10
@@ -10,18 +10,19 @@ from PIL import Image, ImageDraw, ImageFont
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import Message
|
||||
from utils.misc import modules_help, prefix
|
||||
from utils.scripts import ReplyCheck, edit_or_reply
|
||||
from utils.scripts import edit_or_reply
|
||||
from utils.scripts import reply_check as ReplyCheck
|
||||
|
||||
|
||||
async def amongus_gen(text: str, clr: int) -> str:
|
||||
url = 'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/Amongus/'
|
||||
font = ImageFont.truetype(
|
||||
BytesIO(
|
||||
requests.get('https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/bold.ttf').content
|
||||
requests.get('https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/bold.ttf', timeout=10).content
|
||||
),
|
||||
60,
|
||||
)
|
||||
imposter = Image.open(BytesIO(requests.get(f'{url}{clr}.png').content))
|
||||
imposter = Image.open(BytesIO(requests.get(f'{url}{clr}.png', timeout=10).content))
|
||||
text_ = '\n'.join('\n'.join(wrap(part, 30)) for part in text.split('\n'))
|
||||
bbox = ImageDraw.Draw(Image.new('RGB', (1, 1))).multiline_textbbox((0, 0), text_, font, stroke_width=2)
|
||||
w, h = bbox[2], bbox[3]
|
||||
@@ -42,10 +43,12 @@ async def amongus_gen(text: str, clr: int) -> str:
|
||||
|
||||
async def get_imposter_img(text: str) -> BytesIO:
|
||||
background = requests.get(
|
||||
f'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/imposter/impostor{randint(1, 22)}.png'
|
||||
f'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/imposter/impostor{randint(1, 22)}.png', # noqa: S311
|
||||
timeout=10,
|
||||
).content
|
||||
font = requests.get(
|
||||
'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/roboto_regular.ttf'
|
||||
'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/roboto_regular.ttf',
|
||||
timeout=10,
|
||||
).content
|
||||
font = BytesIO(font)
|
||||
font = ImageFont.truetype(font, 30)
|
||||
@@ -79,9 +82,9 @@ async def amongus_cmd(client: Client, message: Message):
|
||||
text = text.replace(f'-c{clr}', '')
|
||||
clr = int(clr)
|
||||
if clr > 12 or clr < 1:
|
||||
clr = randint(1, 12)
|
||||
clr = randint(1, 12) # noqa: S311
|
||||
except IndexError:
|
||||
clr = randint(1, 12)
|
||||
clr = randint(1, 12) # noqa: S311
|
||||
|
||||
if not text:
|
||||
if not reply:
|
||||
@@ -100,15 +103,15 @@ async def amongus_cmd(client: Client, message: Message):
|
||||
|
||||
@Client.on_message(filters.command('imposter', prefix) & filters.me)
|
||||
async def imposter_cmd(client: Client, message: Message):
|
||||
remain = randint(1, 2)
|
||||
remain = randint(1, 2) # noqa: S311
|
||||
imps = ["wasn't the impostor", 'was the impostor']
|
||||
|
||||
if message.reply_to_message:
|
||||
user = message.reply_to_message.from_user
|
||||
text = f'{user.first_name} {choice(imps)}.'
|
||||
text = f'{user.first_name} {choice(imps)}.' # noqa: S311
|
||||
else:
|
||||
args = message.text.split()[1:]
|
||||
text = ' '.join(args) if args else f'{message.from_user.first_name} {choice(imps)}.'
|
||||
text = ' '.join(args) if args else f'{message.from_user.first_name} {choice(imps)}.' # noqa: S311
|
||||
|
||||
text += f'\n{remain} impostor(s) remain.'
|
||||
imposter_file = await get_imposter_img(text)
|
||||
|
||||
Reference in New Issue
Block a user