8a1da13383
Dockerfile fixes: - edu_master/phpsessid-bot: add --no-install-recommends, pin pip versions - edu_master/webinar-checker: pin pip versions with --no-cache-dir - userbot: add SHELL with pipefail for pipe operations Ruff fixes (173 → 0): - W293/W291/W292: whitespace clean via ruff format - N806: camelCase → snake_case (anilist, safone, hearts, flux, etc.) - ARG001/ARG002: prefix unused params with _ - SIM115: use context managers for file I/O - SIM117: combine nested with statements - S608: noqa on SQL f-strings (module name is validated) - E402/N812/N817: import fixes - B023: pass loop variable as argument - I001: auto-sorted imports - syntax: fixed = vs == in dtek_notif/main.py
92 lines
2.4 KiB
Python
92 lines
2.4 KiB
Python
import asyncio
|
|
import random
|
|
|
|
from pyrogram import Client, filters
|
|
from pyrogram.errors.exceptions.flood_420 import FloodWait
|
|
from pyrogram.types import Message
|
|
from utils.misc import modules_help, prefix
|
|
|
|
R = '❤️'
|
|
W = '🤍'
|
|
|
|
heart_list = [
|
|
W * 9,
|
|
W * 2 + R * 2 + W + R * 2 + W * 2,
|
|
W + R * 7 + W,
|
|
W + R * 7 + W,
|
|
W + R * 7 + W,
|
|
W * 2 + R * 5 + W * 2,
|
|
W * 3 + R * 3 + W * 3,
|
|
W * 4 + R + W * 4,
|
|
W * 9,
|
|
]
|
|
joined_heart = '\n'.join(heart_list)
|
|
|
|
heartlet_len = joined_heart.count(R)
|
|
|
|
SLEEP = 0.1
|
|
|
|
|
|
async def _wrap_edit(message: Message, text: str):
|
|
"""Floodwait-safe utility wrapper for edit"""
|
|
try:
|
|
await message.edit(text)
|
|
except FloodWait as fl:
|
|
await asyncio.sleep(fl.x)
|
|
|
|
|
|
async def phase1(message: Message):
|
|
"""Big scroll"""
|
|
big_scroll = '🧡💛💚💙💜🖤🤎'
|
|
await _wrap_edit(message, joined_heart)
|
|
for heart in big_scroll:
|
|
await _wrap_edit(message, joined_heart.replace(R, heart))
|
|
await asyncio.sleep(SLEEP)
|
|
|
|
|
|
async def phase2(message: Message):
|
|
"""Per-heart randomiser"""
|
|
all_hearts = ['❤️'] + list('🧡💛💚💙💜🤎🖤') # don't include white heart
|
|
|
|
format_heart = joined_heart.replace(R, '{}')
|
|
for _ in range(5):
|
|
heart = format_heart.format(*random.choices(all_hearts, k=heartlet_len)) # noqa: S311
|
|
await _wrap_edit(message, heart)
|
|
await asyncio.sleep(SLEEP)
|
|
|
|
|
|
async def phase3(message: Message):
|
|
"""Fill up heartlet matrix"""
|
|
await _wrap_edit(message, joined_heart)
|
|
await asyncio.sleep(SLEEP * 2)
|
|
repl = joined_heart
|
|
for _ in range(joined_heart.count(W)):
|
|
repl = repl.replace(W, R, 1)
|
|
await _wrap_edit(message, repl)
|
|
await asyncio.sleep(SLEEP)
|
|
|
|
|
|
async def phase4(message: Message):
|
|
"""Matrix shrinking"""
|
|
for i in range(7, 0, -1):
|
|
heart_matrix = '\n'.join([R * i] * i)
|
|
await _wrap_edit(message, heart_matrix)
|
|
await asyncio.sleep(SLEEP)
|
|
|
|
|
|
@Client.on_message(filters.command('hearts', prefix) & filters.me)
|
|
async def hearts(_client: Client, message: Message):
|
|
await phase1(message)
|
|
await phase2(message)
|
|
await phase3(message)
|
|
await phase4(message)
|
|
await asyncio.sleep(SLEEP * 3)
|
|
|
|
final_caption = ' '.join(message.command[1:])
|
|
if not final_caption:
|
|
final_caption = '💕 by @moonuserbot'
|
|
await message.edit(final_caption)
|
|
|
|
|
|
modules_help['hearts'] = {'hearts': 'Heart animation. May cause floodwaits, use at your own risk!'}
|