await event.edit(f"```Looking for latest OTA for {model}...```") async with bot.conversation(username) as bot_conv: if True: response = await silently_send_message(bot_conv, "/start") if not response.text.startswith("Hey!"): await event.edit(f"{response.text}") return response = await silently_send_message(bot_conv, f"/GetLatestOTA {model}") if response.text.startswith("There"): await event.edit(f"{response.text}") return await event.edit(response.text) async def silently_send_message(conv, text): await conv.send_message(text) response = await conv.get_response() await conv.mark_read(message=response) return response syntax.update({ "rmota": "\ ```.rmota <device_model>```\ \nUsage: Returns latest update info for specified device.\nUses @Realme_3ProBot to get update information.\ " })
# For The-TG-Bot-3.0 # By Priyam Kalra import time from userbot import syntax @bot.on(command(pattern="log ?(.*)")) async def _(event): if event.fwd_from: return rep = await event.get_reply_message() msg = rep.text await log(msg) await event.delete() async def log(text): LOGGER = Config.LOGGER_GROUP await bot.send_message(LOGGER, text) syntax.update({ "log": "\ ```.log (as a reply to target message)```\ \nUsage: Simply log the replied msg to logger group.\ " })
# By Priyam Kalra # Syntax (.say <text_to_print>) import time from userbot import syntax @bot.on(command(pattern="say ?(.*)")) async def _(event): if event.fwd_from: return input = event.pattern_match.group(1) if not input: abe = await event.get_reply_message() input = abe.text strings = input.split() count = 0 output = "" for _ in strings: output += f"{strings[count]}\n" count += 1 await event.edit(output) time.sleep(0.25) syntax.update({ "say": "\ ```.say <text_to_print> (or as a reply to target message)```\ \nUsage: Says anything you want it to say.\ " })
m_list = fd.readlines() message = "" for m in m_list: message += m.decode("UTF-8") + "\r\n" os.remove(downloaded_file_name) else: message = previous_message.message else: message = "SYNTAX: `.paste <long text to include>`" url = "https://del.dog/documents" r = requests.post(url, data=message.encode("UTF-8")).json() url = f"https://del.dog/{r['key']}" end = datetime.now() ms = (end - start).seconds if r["isUrl"]: nurl = f"https://del.dog/v/{r['key']}" await event.edit( "Pasted to {} in {} seconds. Goto Original URL: {}".format( url, ms, nurl)) else: await event.edit("Pasted to {} in {} seconds".format(url, ms)) syntax.update({ "pastebin": "\ ```.paste (as a reply to the msg you want to paste)```\ \nUsage: Pastes the target message to del.dog.\ " })
# For The-TG-Bot-3.0 # By Priyam Kalra # Syntax (.link <text_to_highlight> <link>) import asyncio from userbot import syntax @bot.on(command(pattern="link ?(.*)")) async def _(event): if event.fwd_from: return string = event.pattern_match.group(1) strings = string.split() link = strings[-1] strings = strings[:-1] string = " ".join(strings) output = f"[{string}]({link})" await event.edit(output) syntax.update({ "hyperlink": "\ ```.link <text> <paste_link_here>```\ \nUsage: Generate a hyperlink using the provided link.\ " })
if not prg.text[0].isalpha(): await prg.edit("**Purging all notes.**") await prg.edit( "**All notes have been purged successfully.**\n```This auto generated message will be deleted in a few seconds...```" ) rm_all_notes(str(prg.chat_id)) time.sleep(5) await prg.delete() status = f"**Successfully purged all notes at** ```{prg.chat_id}```" await log(status) async def log(text): LOGGER = Config.LOGGER_GROUP await bot.send_message(LOGGER, text) syntax.update({ "notes": "\ ```.get <notename>```\ \nUsage: Gets the note with name <notename>\ \n\n```.save <notename>``` (as a reply to message to save)\ \nUsage: Saves target message as a note with the name <notename>\ \n\n```.clear <notename>```\ \nUsage: Deletes the note with name <notename>.\ \n\n```.notes <notename>```\ \nUsage: Prints the list of notes saved in the current chat.\ " })
process = await asyncio.create_subprocess_shell( cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) stdout, stderr = await process.communicate() e = stderr.decode() if not e: e = "No Error" o = stdout.decode() if not o: o = "**Tip**: \n`Use .syntax bash to get help regarding this module.`" else: _o = o.split("\n") o = "\n".join(_o) OUTPUT = f"**QUERY:**\n__Command:__\n`{cmd}` \n__PID:__\n`{process.pid}`\n\n**stderr:** \n`{e}`\n**Output:**\n`{o}`" if len(OUTPUT) > Config.MAX_MESSAGE_SIZE_LIMIT: with io.BytesIO(str.encode(OUTPUT)) as out_file: out_file.name = "exec.text" await bot.send_file(event.chat_id, out_file, force_document=True, allow_cache=False, caption=cmd, reply_to=reply_to_id) await event.delete() await event.edit(OUTPUT) syntax.update({"bash": "\ ```.bash <code>```\ \nUsage: Evaluate bash code.\ "})
await log("Error : `{}`".format(str(file.error_message))) return await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await progress_status(gid, event, previous) else: await event.edit(f"```{file.name}``` leeched successfully!") return except Exception as e: if " not found" in str(e) or "'file'" in str(e): await log(str(e)) return await event.delete() elif " depth exceeded" in str(e): file.remove(force=True) await log(str(e)) else: await log(str(e)) return await event.delete() syntax.update({ "leech": "\ ```.l2d <magnet-link> (or as a reply to a magnet link)```\ \nUsage: Mirrors the torrent to gdrive.\ \n\n```.l2d setup```\ \nUsage: Get gdrive setup guide.\ ```.leech <magnet-link> (or as a reply to a magnet link)```\ \nUsage: Downloads the torrent to the local machine.\ ```.l2tg <magnet-link> (or as a reply to a magnet link)```\ \nUsage: Uploads the torrent to telegram (TG API limitations might cause problems, don't blame me :P)..\ " })
if event.fwd_from: return r = random.randint(1, 100) input_str = event.pattern_match.group(1) if input_str: input_str = input_str.lower() if r % 2 == 1: if input_str == "heads": await event.edit("**Heads**. \n You were correct.") elif input_str == "tails": await event.edit("**Heads**. \n Better luck next time!...") else: await event.edit("**Heads**.") elif r % 2 == 0: if input_str == "tails": await event.edit("**Tails**. \n You were correct.") elif input_str == "heads": await event.edit("**Tails**. \n Better luck next time!...") else: await event.edit("**Tails**.") else: await event.edit("¯\_(ツ)_/¯") syntax.update({ "coinflip": "\ ```.coinflip <optional_choice>```\ \nUsage: Flips a virtual coin and returns the outcome, test your luck!\ " })
user_id = user_object.id replied_user = await event.client( GetFullUserRequest(user_id)) return replied_user, None except Exception as e: return None, e elif event.is_private: try: user_id = event.chat_id replied_user = await event.client(GetFullUserRequest(user_id)) return replied_user, None except Exception as e: return None, e else: try: user_object = await event.client.get_entity(int(input_str)) user_id = user_object.id replied_user = await event.client(GetFullUserRequest(user_id)) return replied_user, None except Exception as e: return None, e syntax.update({ "whois": "\ ```.whois``` [as a reply to a message of a user]\ \nUsage: Get statistics of the a user.\ " })
msgs = [] from_user = None input_str = event.pattern_match.group(1) if input_str: from_user = await bot.get_entity(input_str) logger.info(from_user) async for message in bot.iter_messages( event.chat_id, min_id=event.reply_to_msg_id, from_user=from_user ): i = i + 1 msgs.append(message) if len(msgs) == 100: await bot.delete_messages(event.chat_id, msgs) msgs = [] if len(msgs) <= 100: await bot.delete_messages(event.chat_id, msgs) msgs = [] await event.delete() else: await event.edit("**PURGE** Failed!") syntax.update({ "purge": "\ ```.purge (as a reply to a msg)```\ \nUsage: Purge all msgs until the target message.\ " })
# check for "lock" "bots" if is_locked(event.chat_id, "bots"): # bots are limited Telegram accounts, # and cannot join by themselves if event.user_added: users_added_by = event.action_message.from_id is_ban_able = False rights = types.ChatBannedRights(until_date=None, view_messages=True) added_users = event.action_message.action.users for user_id in added_users: user_obj = await bot.get_entity(user_id) if user_obj.bot: is_ban_able = True try: await bot( functions.channels.EditBannedRequest( event.chat_id, user_obj, rights)) except Exception as e: await event.reply( "I don't seem to have ADMIN permission here. \n`{}`" .format(str(e))) update_lock(event.chat_id, "bots", False) break syntax.update({ "locks": "```.lock <specify_item_to_lock>```\nUsage: Locks a specified lockable.\nList of items:\nmsg, media, sticker, gif, gamee, ainline, gpoll, adduser, cpin, changeinfo, bots, commands, email, forward, url" })
# For The-TG-Bot-3.0 # Syntax .ping from datetime import datetime from userbot import syntax @bot.on(command("ping")) async def _(event): if event.fwd_from: return start = datetime.now() await event.edit("Pong!") end = datetime.now() ms = (end - start).microseconds / 1000 await event.edit("Pong!\n{}".format(ms)) syntax.update({ "ping": "\ ```.ping```\ \nUsage: Check your internet connection's ping speed.\ " })