return for trigger in filters: pattern = ( r"( |^|[^\w])" + escape(trigger.keyword) + r"( |$|[^\w])") pro = search(pattern, name, flags=IGNORECASE) if pro and trigger.f_mesg_id: msg_o = await handler.client.get_messages( entity=BOTLOG_CHATID, ids=int(trigger.f_mesg_id)) await handler.reply(msg_o.message, file=msg_o.media) elif pro and trigger.reply: await handler.reply(trigger.reply) except AttributeError: pass register(outgoing=True, pattern=r"^.filter (.*)") async def add_new_filter(new_handler): """ For .filter command, allows adding new filters in a chat """ try: from userbot.modules.sql_helper.filter_sql import add_filter except AttributeError: await new_handler.edit("`Running on Non-SQL mode!`") return value = new_handler.pattern_match.group(1).split(None, 1) """ - The first words after .filter(space) is the keyword - """ keyword = value[0] try: string = value[1] except IndexError:
from sqlalchemy.exc import IntegrityError from userbot import (COUNT_PM, CMD_HELP, BOTLOG, BOTLOG_CHATID, PM_AUTO_BAN, LASTMSG, LOGS) from userbot.events import register # ========================= CONSTANTS ============================ UNAPPROVED_MSG = ( "`Alexa : Do I know you ??.`\n" "`Wait till my master to look into this`\n" "`He doesn't approave retards tho xD..`\n" ======================== @register(incoming=True, disable_edited=True, disable_errors=True) async def permitpm(event): """ Prohibits people from PMing you without approval. \ Will block retarded nibbas automatically. """ if PM_AUTO_BAN: self_user = await event.client.get_me() if event.is_private and event.chat_id != 777000 and event.chat_id != self_user.id and not ( await event.get_sender()).bot: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved from userbot.modules.sql_helper.globals import gvarstatus except AttributeError: return apprv = is_approved(event.chat_id) notifsoff = gvarstatus("NOTIF_OFF")
from io import BytesIO from userbot.events import register from telethon import types from userbot import bot from telethon.errors import PhotoInvalidDimensionsError from telethon.tl.functions.messages import SendMediaRequest register(outgoing=True, pattern="^.png$") async def on_file_to_photo(event): await event.delete() target = await event.get_reply_message() try: image = target.media.document except AttributeError: return if not image.mime_type.startswith('image/'): return # This isn't an image if image.mime_type == 'image/webp': return # Telegram doesn't let you directly send stickers as photos if image.size > 10 * 2560 * 1440: return # We'd get PhotoSaveFileInvalidError otherwise file = await bot.download_media(target, file=BytesIO()) file.seek(0) img = await bot.upload_file(file) img.name = 'image.png' try:
# ========================= CONSTANTS ============================ UNAPPROVED_MSG = ("`Welcome, You are a wonderful person with a wonderful view of life.'\n\n" "`Your companionship is always an opportunity But Sed This line is not for you.'" "`So just tell why you are here ?\n\n" "`Your message has been received will be responded when I'm free don't sit here whole day coz there is lots of pending message😶 don't message my master again and again otherwise I block u,' # ================================================================= @register(incoming=True) async def permitpm(event): """ Permits people from PMing you without approval. \ Will block retarded nibbas automatically. """ if PM_AUTO_BAN: if event.sender_id in BRAIN_CHECKER: return if event.is_private and not (await event.get_sender()).bot: try: from userbot.modules.sql_helper.pm_permit_sql import is_approved except AttributeError: return apprv = is_approved(event.chat_id) # This part basically is a sanity check # If the message that sent before is Unapproved Message
size2new = size2 * scale else: scale = 512 / size2 size1new = size1 * scale size2new = 512 size1new = math.floor(size1new) size2new = math.floor(size2new) sizenew = (size1new, size2new) image = image.resize(sizenew) else: image.thumbnail(maxsize) return image @register(outgoing=True, pattern="^.stkrinfo$") async def get_pack_info(event): if not event.is_reply: await event.edit("`I can't fetch info from nothing, can I ?!`") return rep_msg = await event.get_reply_message() if not rep_msg.document: await event.edit("`Reply to a sticker to get the pack details`") return try: stickerset_attr = rep_msg.document.attributes[1] await event.edit( "`Fetching details of the sticker pack, please wait..`") except BaseException: