227e5fda27
- 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
81 lines
3.0 KiB
Python
81 lines
3.0 KiB
Python
from asyncio import sleep
|
|
|
|
from pyrogram import Client, enums, filters
|
|
from pyrogram.raw import functions
|
|
from pyrogram.types import InputReplyToMessage, Message
|
|
from utils.misc import modules_help, prefix
|
|
from utils.scripts import format_exc
|
|
|
|
commands = {
|
|
'ftype': enums.ChatAction.TYPING,
|
|
'faudio': enums.ChatAction.UPLOAD_AUDIO,
|
|
'fvideo': enums.ChatAction.UPLOAD_VIDEO,
|
|
'fphoto': enums.ChatAction.UPLOAD_PHOTO,
|
|
'fdocument': enums.ChatAction.UPLOAD_DOCUMENT,
|
|
'flocation': enums.ChatAction.FIND_LOCATION,
|
|
'frvideo': enums.ChatAction.RECORD_VIDEO,
|
|
'frvoice': enums.ChatAction.RECORD_AUDIO,
|
|
'frvideor': enums.ChatAction.RECORD_VIDEO_NOTE,
|
|
'fvideor': enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
|
'fgame': enums.ChatAction.PLAYING,
|
|
'fcontact': enums.ChatAction.CHOOSE_CONTACT,
|
|
'fstop': enums.ChatAction.CANCEL,
|
|
'fscrn': 'screenshot',
|
|
}
|
|
|
|
|
|
# noinspection PyUnusedLocal
|
|
@Client.on_message(filters.command(list(commands), prefix) & filters.me)
|
|
async def fakeactions_handler(client: Client, message: Message):
|
|
cmd = message.command[0]
|
|
try:
|
|
sec = int(message.command[1])
|
|
if sec > 60:
|
|
sec = 60
|
|
except Exception:
|
|
sec = None
|
|
await message.delete()
|
|
|
|
action = commands[cmd]
|
|
|
|
try:
|
|
if action != 'screenshot':
|
|
if sec and action != enums.ChatAction.CANCEL:
|
|
while sec > 0:
|
|
await client.send_chat_action(chat_id=message.chat.id, action=action)
|
|
await sleep(1)
|
|
sec -= 1
|
|
return await client.send_chat_action(chat_id=message.chat.id, action=action)
|
|
else:
|
|
for _ in range(sec if sec else 1):
|
|
await client.invoke(
|
|
functions.messages.SendScreenshotNotification(
|
|
peer=await client.resolve_peer(message.chat.id),
|
|
reply_to=InputReplyToMessage(reply_to_message_id=message.reply_to_message.id),
|
|
random_id=client.rnd_id(),
|
|
)
|
|
)
|
|
await sleep(0.1)
|
|
except AttributeError:
|
|
return await client.send_message('me', 'Error in <b>fakeactions</b>reply to message is required')
|
|
except Exception as e:
|
|
return await client.send_message('me', 'Error in <b>fakeactions</b> module:\n' + format_exc(e))
|
|
|
|
|
|
modules_help['fakeactions'] = {
|
|
'ftype [sec]': 'Typing... action',
|
|
'faudio [sec]': 'Sending voice... action',
|
|
'fvideo [sec]': 'Sending video... action',
|
|
'fphoto [sec]': 'Sending photo... action',
|
|
'fdocument [sec]': 'Sending document... action',
|
|
'flocation [sec]': 'Find location... action',
|
|
'fcontact [sec]': 'Sending contact... action',
|
|
'frvideo [sec]': 'Recording video... action',
|
|
'frvoice [sec]': 'Recording voice... action',
|
|
'frvideor [sec]': 'Recording round video... action',
|
|
'fvideor [sec]': 'Uploading round video... action',
|
|
'fgame [sec]': 'Playing game... action',
|
|
'fstop': 'Stop actions',
|
|
'fscrn [amount] [reply_to_message]*': 'Make screenshot action',
|
|
}
|