async def rtfd(_, message: Message): """Tell to RTFD (rude)""" await asyncio.gather( message.delete(), message.reply_photo("https://i.imgur.com/a08Ju2e.png", quote=False, caption=RTFD, reply_to_message_id=getattr( message.reply_to_message, "message_id", None)))
def on_user_join(client: Client, msg: Message) -> None: for user in msg.new_chat_members: if client.get_chat_member(msg.chat.id, user.id).can_send_messages == False: client.kick_chat_member(msg.chat.id, user.id, until_date=int(time.time()) + 36000) # 60*60*10 == 36000 == 10 hours msg.reply(f"Banned user {user.first_name} because they rejoined.") return client.restrict_chat_member( msg.chat.id, user.id, ChatPermissions( can_send_messages=False, can_change_info=False, can_invite_users=False, can_pin_messages=False, ), ) client.send_chat_action(msg.chat.id, "upload_photo") captchaSolution, captchaBytesIO = get_captcha() captchaBytesIO.name = "captcha.jpeg" correctEmoji = getattr(emoji, captchaSolution) msg.reply_photo( captchaBytesIO, caption= f"Welcome {user.first_name}\nYou must complete a captcha to chat.\nChoose the correct emoji.", reply_markup=get_keyboard( correctEmoji, user.id, ), )
async def sticker_image(_, message: Message): r = message.reply_to_message if not r: return await message.reply("Reply to a sticker.") if not r.sticker: return await message.reply("Reply to a sticker.") m = await message.reply("Sending..") f = await r.download(f"{r.sticker.file_unique_id}.png") await gather(*[ message.reply_photo(f), message.reply_document(f), ]) await m.delete() os.remove(f)
async def take_ss(_, message: Message): if len(message.command) < 2: return await eor(message, text="Give A Url To Fetch Screenshot.") if len(message.command) == 2: url = message.text.split(None, 1)[1] full = False elif len(message.command) == 3: url = message.text.split(None, 2)[1] full = message.text.split(None, 2)[2].lower().strip() in [ "yes", "y", "1", "true", ] else: return await eor(message, text="Invalid Command.") m = await eor(message, text="Capturing screenshot...") try: photo = await take_screenshot(url, full) if not photo: return await m.edit("Failed To Take Screenshot") m = await m.edit("Uploading...") if not full: # Full size images have problem with reply_photo, that's why # we need to only use reply_photo if we're not using full size await gather( *[message.reply_document(photo), message.reply_photo(photo)] ) else: await message.reply_document(photo) await m.delete() except Exception as e: await m.edit(str(e))