7fb0a0e179
- 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
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 = ['❤️'] + list('🧡💛💚💙💜🤎🖤') # don't include white heart
|
|
|
|
format_heart = joined_heart.replace(R, '{}')
|
|
for _ in range(5):
|
|
heart = format_heart.format(*random.choices(ALL, 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!'}
|