return try: check = re.match(repl, to_fix, flags=re.IGNORECASE) if check and check.group(0).lower() == to_fix.lower(): await command.edit("`Boi!, that's a reply. Don't use sed`") return if "i" in flags and "g" in flags: text = re.sub(repl, repl_with, to_fix, flags=re.I).strip() elif "i" in flags: text = re.sub(repl, repl_with, to_fix, count=1, flags=re.I).strip() elif "g" in flags: text = re.sub(repl, repl_with, to_fix).strip() else: text = re.sub(repl, repl_with, to_fix, count=1).strip() except sre_err: await command.edit("B O I! [Learn Regex](https://regexone.com)" ) return if text: await command.edit(f"Did you mean? \n\n{text}") CMD_HELP.update({ "sed": ".s<delimiter><old word(s)><delimiter><new word(s)>\ \nUsage: Replaces a word or words using sed.\ \nDelimiters: `/, :, |, _`" })
await ups.edit(changelog_str) await ups.respond('`do \".update now\" to update`') return await ups.edit('`New update found, updating...`') ups_rem.fetch(ac_br) repo.git.reset('--hard', 'FETCH_HEAD') # reqs_upgrade = await update_requirements() await ups.edit('`Successfully Updated!\n' 'Bot is restarting... Wait for a second!`') # Spin a new instance of bot args = [sys.executable, "-m", "tg_userbot"] execle(sys.executable, *args, environ) return @register(outgoing=True, pattern="^.reboot(?: |$)(.*)") async def upstream(ups): await ups.edit('`Rebooting...`') args = [sys.executable, "-m", "tg_userbot"] execle(sys.executable, *args, environ) await ups.edit("`Sucessfully rebooted!`") return CMD_HELP.update({ "updater": "`.update`: Check if the main repository has any updates and show changelog if so.\ \n\n`.update now`: Update tguserbot if there are any updates available." })
id=stickerset_attr.stickerset.id, access_hash=stickerset_attr.stickerset.access_hash))) pack_emojis = [] for document_sticker in get_stickerset.packs: if document_sticker.emoticon not in pack_emojis: pack_emojis.append(document_sticker.emoticon) OUTPUT = f"**Sticker Title:** `{get_stickerset.set.title}\n`" \ f"**Sticker Short Name:** `{get_stickerset.set.short_name}`\n" \ f"**Official:** `{get_stickerset.set.official}`\n" \ f"**Archived:** `{get_stickerset.set.archived}`\n" \ f"**Stickers In Pack:** `{len(get_stickerset.packs)}`\n" \ f"**Emojis In Pack:**\n{' '.join(pack_emojis)}" await event.edit(OUTPUT) CMD_HELP.update({ "stickers": "`.kang`\ \nUsage: Reply .kang to a sticker or an image to kang it to your userbot pack.\ \n\n`.kang [emoji('s)]`\ \nUsage: Works just like .kang but uses the emoji('s) you picked.\ \n\n`.kang [number]`\ \nUsage: Kang's the sticker/image to the specified pack but uses 🤔 as emoji.\ \n\n`.kang [emoji('s)] [number]`\ \nUsage: Kang's the sticker/image to the specified pack and uses the emoji('s) you picked.\ \n\n`.stkrinfo`\ \nUsage: Gets info about the sticker pack." })
if len(args) >= 2 and not request.reply_to_msg_id: reason = str(message.split(' ', 1)[1]) elif len(args) == 1 and not request.reply_to_msg_id: reason = "" elif len(args) == 0 and not request.reply_to_msg_id: await request.edit("`Lemme gban you for not giving a proper username!`") return else: reason = message gbantext = '/gkick ' + user + ' ' + reason for GBAN_BOT in GBAN_BOTS: if GBAN_BOT=="MissRose_bot": # rose doesn't have fed kick pass async with bot.conversation(GBAN_BOT) as conv: await conv.send_message(gbantext) x = await conv.get_response() if x: pass else: x = GBAN_BOT + ' didn\'t respond' response += GBAN_BOT + ': ' + x.text.replace("**", "").replace("`", "").replace("tg://user?id=", "") + '\n\n' await request.edit("```" + response + "```") else: await request.edit("`You haven't enabled GBANS!`") CMD_HELP.update({ 'gbans': '`.gban, .ungban, .gkick\nUsage: You\'ll know if you\'ve ever had a bot. Does exactly as it says.`' })
mph = str(wind * 2.237).split(".") def fahrenheit(f): temp = str(((f - 273.15) * 9 / 5 + 32)).split(".") return temp[0] def celsius(c): temp = str((c - 273.15)).split(".") return temp[0] def sun(unix): xx = datetime.fromtimestamp( unix, tz=ctimezone).strftime("%H:%M").lstrip("0").replace(" 0", " ") return xx await weather.edit(f"**{cityname}, {fullc_n}**\n" + f"`{time}`\n\n" + f"**Temperature:** `{celsius(curtemp)}°C\n`" + f"**Condition:** `{condmain}, {conddet}` " + f"{icon}\n" + f"**Humidity:** `{humidity}%`\n" + f"**Wind:** `{kmph[0]} km/h`\n" + f"**Sunrise**: `{sun(sunrise)}`\n" + f"**Sunset**: `{sun(sunset)}`") CMD_HELP.update({ "weather": ".weather <city> or .weather <city>, <country name/code>\ \nUsage: Gets the weather of a city." })
with open(downloaded_file_name, "rb") as file: m_list = file.readlines() message = "" for media in m_list: message += media.decode("UTF-8") + "\r\n" os.remove(downloaded_file_name) else: message = previous_message.message qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4) qr.add_data(message) qr.make(fit=True) img = qr.make_image(fill_color="black", back_color="white") img.save("img_file.webp", "PNG") await makeqr.client.send_file(makeqr.chat_id, "img_file.webp", reply_to=reply_msg_id) os.remove("img_file.webp") await makeqr.delete() CMD_HELP.update({ 'qrcode': ".decode <reply to barcode/qrcode>\ \nUsage: Get the content from the replied QR Code/Bar Code.\ \n\n.makeqr <content>\ \nUsage: Make a QR Code from the given content." })
@register(outgoing=True, pattern="^\.delayspam (.*)") async def spammer(e): if not e.text[0].isalpha() and e.text[0] in ("."): spamDelay = float(e.pattern_match.group(1).split(' ', 2)[0]) counter = int(e.pattern_match.group(1).split(' ', 2)[1]) spam_message = str(e.pattern_match.group(1).split(' ', 2)[2]) await e.delete() for i in range(1, counter): await e.respond(spam_message) await sleep(spamDelay) if BOTLOG: await e.client.send_message( BOTLOG_CHATID, "#DelaySPAM\n\nDelaySpam was executed successfully") CMD_HELP.update({ "spam": "`.tspam <text>`\ \nUsage: Spam the text letter by letter.\ \n\n`.wspam <text>`\ \nUsage: Spam the text word by word.\ \n\n`.spam <count> <text>`\ \nUsage: Floods text in the chat !!\ \n\n`.delayspam <delay> <count> <text>`\ \nUsage: spams with a time delay.\ \n\n\n**NOTE : Spam at your own risk !!**" })
pfplist = await delpfp.client( GetUserPhotosRequest(user_id=delpfp.from_id, offset=0, max_id=0, limit=lim)) input_photos = [] for sep in pfplist.photos: input_photos.append( InputPhoto(id=sep.id, access_hash=sep.access_hash, file_reference=sep.file_reference)) await delpfp.client(DeletePhotosRequest(id=input_photos)) await delpfp.edit( f"`Successfully deleted {len(input_photos)} profile picture(s).`") CMD_HELP.update({ "profile": ".username <new_username>\ \nUsage: Changes your Telegram username.\ \n\n.name <firstname> or .name <firstname> <lastname>\ \nUsage: Changes your Telegram name.(First and last name will get split by the first space)\ \n\n.setpfp\ \nUsage: Reply with .setpfp to an image to change your Telegram profie picture.\ \n\n.setbio <new_bio>\ \nUsage: Changes your Telegram bio.\ \n\n.delpfp or .delpfp <number>/<all>\ \nUsage: Deletes your Telegram profile picture(s)." })
user_obj = await event.client.get_entity(user) except (TypeError, ValueError) as err: await event.edit(str(err)) return None return user_obj CMD_HELP.update({ "admin": "`.promote`\ \nUsage: Reply to someone's message with .promote to promote them.\ \n\n`.demote`\ \nUsage: Reply to someone's message with .demote to revoke their admin permissions.\ \n\n`.ban`\ \nUsage: Reply to someone's message with .ban to ban them.\ \n\n`.unban`\ \nUsage: Reply to someone's message with .unban to unban them in this chat.\ \n\n`.mute`\ \nUsage: Reply to someone's message with .mute to mute them.\ \n\n`.unmute`\ \nUsage: Reply to someone's message with .unmute to unmute them.\ \n\n`.delusers`\ \nUsage: Searches for deleted accounts in a group. Use .delusers clean to remove deleted accounts from the group.\ \n\n`.adminlist`\ \nUsage: Retrieves all admins in a chat.\ \n\n`.userslist` or `.userslist <name>`\ \nUsage: Retrieves all users in a chat.\ \n\n`.kick`\ \nUsage: Reply to someone's message with .kick to kick them." })
send_messages=msg, send_media=media, send_stickers=sticker, send_gifs=gif, send_games=gamee, send_inline=ainline, send_polls=gpoll, invite_users=adduser, pin_messages=cpin, change_info=changeinfo, ) try: await event.client( EditChatDefaultBannedRightsRequest(peer=peer_id, banned_rights=unlock_rights)) await event.edit(f"`Unlocked {what} for this chat !!`") except BaseException as e: await event.edit( f"`Do I have proper rights for that ??`\n**Error:** {str(e)}") return CMD_HELP.update({ "locks": ".lock <all (or) type(s)> or .unlock <all (or) type(s)>\ \nUsage: Allows you to lock/unlock some common message types in the chat.\ [NOTE: Requires proper admin rights in the chat !!]\ \n\nAvailable message types to lock/unlock are: \ \n`all, msg, media, sticker, gif, game, inline, poll, invite, pin, info`" })
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) stdout, stderr = await process.communicate() result = str(stdout.decode().strip()) + str(stderr.decode().strip()) if len(result) > 4096: output = open("output.txt", "w+") output.write(result) output.close() await term.client.send_file( term.chat_id, "output.txt", reply_to=term.id, caption="`Output too large, sending as file`") remove("output.txt") return if uid is 0: await term.edit("`" f"{curruser}:~# {command}" f"\n{result}" "`") else: await term.edit("`" f"{curruser}:~$ {command}" f"\n{result}" "`") if BOTLOG: await term.client.send_message( BOTLOG_CHATID, "Terminal Command " + command + " was executed sucessfully") CMD_HELP.update({ "terminal": ".exec print('hello')\nUsage: Execute small python scripts.\ \n\n.term <bash_command>\nUsage: Run bash commands and scripts on your server." })
print("sdfjds") m_list = None with open(downloaded_file_name, "rb") as fd: 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: await event.edit("Syntax: `.dog <text>`") if message == "Syntax: `.dog <text>`": await event.edit("Syntax: `.dog <text>`") return await event.edit("`Uploading...`") 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. [link]({}).".format(url, ms, nurl)) else: await event.edit("Pasted to {} in {} seconds.".format(url, ms)) CMD_HELP.update({ 'deldog': ".dog <text>\ \nUsage: Create a del.dog from text."})
async def delnote(event): name = event.pattern_match.group(1) notes = [name] if " " in name: notes = name.split() deleted = 0 delnames = "" for n in notes: npath = "notes/" + n + ".txt" if not path.exists(npath): await event.edit(f"Note `{n}` doesn't exist.\n" + f"Type `.save {n} <text> to create the note.") return os.remove(npath) deleted = deleted + 1 delnames = delnames + n + ", " await event.edit( f"Deleted note{'s:' if deleted > 1 else ''} `{delnames.rstrip(',')}`.") CMD_HELP.update({ 'notes': ".note <notename>\ \nUsage: Send a note.\ \n\n.save <notename> <text>\ \nUsage: Save a note.\ \n\n.notes\ \nUsage: Get all of your notes.\ \n\n.delnote <notename>\ \nUsage: Delete a note." })
if currrent_entity.bot: b += 1 else: u += 1 elif isinstance(currrent_entity, Chat): g += 1 elif isinstance(currrent_entity, Channel): if currrent_entity.broadcast: bc += 1 else: c += 1 else: print(d) result += f"`Users:`\t**{u}**\n" result += f"`Groups:`\t**{g}**\n" result += f"`Super Groups:`\t**{c}**\n" result += f"`Channels:`\t**{bc}**\n" result += f"`Bots:`\t**{b}**" await event.edit(result) CMD_HELP.update({ "user_info": "`.info <username>` or as a reply to someones text\ \nUsage: Gets info of an user.\ \n\n.stats\ \nUsage: Gets your stats." })
i = 1 await smsg.delete() @register(outgoing=True, pattern="^\.del$") async def delete_it(delme): if not delme.text[0].isalpha() and delme.text[0] in ("."): msg_src = await delme.get_reply_message() if delme.reply_to_msg_id: try: await msg_src.delete() await delme.delete() if BOTLOG: await delme.client.send_message( BOTLOG_CHATID, "Deletion of message was successful") except rpcbaseerrors.BadRequestError: if BOTLOG: await delme.client.send_message( BOTLOG_CHATID, "Well, I can't delete a message") CMD_HELP.update({ 'deletions': '`.purge`\ \nUsage: Purges all messages starting from the reply.\ \n\n`.purgeme <x>`\ \nUsage: Deletes x amount of your latest messages.\ \n\n`.del`\ \nUsage: Deletes the message replied to' })
} if isinstance(entity, telethon.tl.types.MessageEntityBold): md_item["Type"] = "bold" elif isinstance(entity, telethon.tl.types.MessageEntityItalic): md_item["Type"] = "italic" elif isinstance(entity, (telethon.tl.types.MessageEntityMention, telethon.tl.types.MessageEntityTextUrl, telethon.tl.types.MessageEntityMentionName, telethon.tl.types.MessageEntityHashtag, telethon.tl.types.MessageEntityCashtag, telethon.tl.types.MessageEntityBotCommand, telethon.tl.types.MessageEntityUrl)): md_item["Type"] = "link" elif isinstance(entity, telethon.tl.types.MessageEntityCode): md_item["Type"] = "code" elif isinstance(entity, telethon.tl.types.MessageEntityStrike): md_item["Type"] = "stroke" elif isinstance(entity, telethon.tl.types.MessageEntityUnderline): md_item["Type"] = "underline" else: logger.warning("Unknown entity: " + str(entity)) markdown.append(md_item) return markdown CMD_HELP.update({ "quotly": "`.q <reply_message>` \ \nUsage: Enhance ur text to sticker. \ \n\nNote: please add Q_API_TOKEN in config. \ \n you can get those from http://antiddos.systems . " })
from tg_userbot import bot, CMD_HELP, GBAN_BOTS, GBANS from tg_userbot.events import register from tg_userbot.modules.user_info import get_user @register(outgoing=True, pattern=r"^.scramble(\s+[\S\s]+|$)") async def scramble_message(e): reply_message = await e.get_reply_message() text = e.pattern_match.group(1) or reply_message.text words = re.split(r"\s", text) scrambled = map(scramble_word, words) text = ' '.join(scrambled) await e.edit(text) def scramble_word(word): if len(word) < 4: return word first_letter = word[0] last_letter = word[-1] middle_letters = list(word[1:-1]) random.shuffle(middle_letters) return first_letter + ''.join(middle_letters) + last_letter CMD_HELP.update({"scramble": ".scramble <text>\ \nUsage: Scrambles text."})
f"RTT: {rtt}\n" f"Automation: {automationData}\n" f"\n" f"Telethon: {version.__version__} \n" f"Python: {python_version()} \n" f"GitHub API: {gitver} \n" f"CAS API: {casver}" "`") @register(outgoing=True, pattern="^.shutdown$") @errors_handler async def shutdown(event): #bot shutdown if not event.text[0].isalpha() and event.text[0] in ("."): await event.edit("`Powering off...`") if BOTLOG: await event.client.send_message(BOTLOG_CHATID, "#SHUTDOWN \n" "Bot shut down") await event.client.disconnect() CMD_HELP.update({ "systools": ".sysd\ \nUsage: Shows system information using neofetch.\ \n\n.status\ \nUsage: Type .status to see wether your bot is working or not.\ \n\n.shutdown\ \nUsage: Type .shutdown to shutdown the bot." })
banned_users = "" async for user in cas.client.iter_participants(info.id): if cas_api.banchecker(user.id): cas_count += 1 if not user.deleted: banned_users += f"{user.first_name} {user.id}\n" else: banned_users += f"Deleted Account {user.id}\n" members_count += 1 text = "Warning! `{}` of `{}` users are CAS Banned:\n".format( cas_count, members_count) text += banned_users if not cas_count: text = "No CAS Banned users found!" except ChatAdminRequiredError as carerr: await cas.edit("`CAS check failed: Admin privileges are required`") print("ChatAdminRequiredError:", carerr) return except BaseException as be: await cas.edit("`CAS check failed`") print("BaseException:", be) return await cas.edit(text) CMD_HELP.update({ "cas_interface": "`.cascheck` <reply/username/user id>\ \nChecks the CAS Status of a specified user" })
async def cping(args): if not args.text[0].isalpha() and args.text[0] in ("."): commandParser = str(args.message.message).split(' ') if len(commandParser) != 2: await args.edit("`Bad arguments!`") else: dns = commandParser[1] try: duration = check_output("ping -c 1 " + dns + " | grep -oP '.*time=\K(\d*\.\d*).*'", shell=True).decode() except: await args.edit("`There was a problem parsing the IP/Hostname`" ) return await args.edit("`DNS: " + dns + "\n" + "Ping speed: " + duration + "`") CMD_HELP.update({ "webtools": ".speedtest\ \nUsage: Does a speedtest and shows the results.\ \n\n.dc\ \nUsage: Finds the nearest datacenter from your server.\ \n\n.ping\ \nUsage: Shows your real time ping\ \n\n.cping <dns/ip>\ \nUsage: Pings a specific IP." })
import time import random from tg_userbot import CMD_HELP from tg_userbot.events import register @register(outgoing=True, pattern=r"^.flash (.*)") async def flasher(event): if not event.text[0].isalpha() and event.text[0] in ("."): r = random.randint(1, 10000) text = event.pattern_match.group(1) if len(text.split(" ")) > 1: await event.edit("`Cannot flash file!`") return await event.edit(f"`Flashing` {text}.zip`...`") time.sleep(4) if r % 2 == 1: await event.edit(f"`Successfully flashed` {text}.zip`!`") elif r % 2 == 0: await event.edit(f"`Flashing` {text}.zip `failed successfully!`") CMD_HELP.update( {"flasher": ".flash <text>\ \nUsage: Flash the .zip file."})
reply += error if not mirrors: reply += error return reply for item in mirrors: name = item['name'] dl_url = item['url'] reply += f'[{name}]({dl_url}) ' return reply def useragent(): useragents = BeautifulSoup( requests.get( 'https://developers.whatismybrowser.com/' 'useragents/explore/operating_system_name/android/').content, 'lxml').findAll('td', {'class': 'useragent'}) user_agent = choice(useragents) return user_agent.text CMD_HELP.update({ "direct_lnk": ".downlink <url>\n" "Usage: Reply to a link or paste a URL to\n" "generate a direct download link\n\n" "List of supported URLs:\n" "`Google Drive - MEGA.nz - Cloud Mail - Yandex.Disk - AFH - " "ZippyShare - MediaFire - SourceForge - OSDN - GitHub`" })
CMD_HELP.update({ "memes": ".vapor\ \nUsage: Vaporize everything!\ \n\n.str\ \nUsage: Stretch it.\ \n\n.zal\ \nUsage: Invoke the feeling of chaos.\ \n\n.oof\ \nUsage: Ooooof\ \n\n.caps <text>\ \nUsage: Converts text to uppercase.\ \n\n.small <text>\ \nUsage: Converts text to uppercase.\ \n\n.hi\ \nUsage: Greet everyone!\ \n\n.coinflip <heads/tails>\ \nUsage: Flip a coin !!\ \n\n.slap\ \nUsage: reply to slap them with random objects !!\ \n\n.mock\ \nUsage: Do it and find the real fun.\ \n\n.clap\ \nUsage: Praise people!\ \n\n.f <emoji/character>\ \nUsage: Pay Respects.\ \n\n.bt\ \nUsage: Believe me, you will find this useful.\ \n\n.punch\ \nUsage: show who's boss\ \n\n.noformat\ \nUsage: Returns text without formatting.\ \n\n.gei\ \nUsage: Use this as a reply if your friend does something gei.\ \n\n.nou\ \nUsage: Return whatever someone said to themself.\ \n\n.type\ \nUsage: Just a small command to make your keyboard become a typewriter!\ \n\n.lfy <query>\ \nUsage: Let me Google that for you real quick !!\ \n\n.decide [Optional: (yes, no, maybe)]\ \nUsage: Make a quick decision.\ \n\n.scam <action> <time>\ \n[Available Actions: (typing, contact, game, location, voice, round, video, photo, document, cancel)]\ \nUsage: Create fake chat actions, for fun. (Default action: typing)\ \n\n\nThanks to 🅱️ottom🅱️ext🅱️ot (@NotAMemeBot) for some of these." })
caption += f"Slow mode: {slowmode}" if hasattr(chat_obj_info, "slowmode_enabled") and chat_obj_info.slowmode_enabled: caption += f", <code>{slowmode_time}s</code>\n\n" else: caption += "\n\n" if not broadcast: caption += f"Supergroup: {supergroup}\n\n" if hasattr(chat_obj_info, "restricted"): caption += f"Restricted: {restricted}\n" if chat_obj_info.restricted: caption += f"> Platform: {chat_obj_info.restriction_reason[0].platform}\n" caption += f"> Reason: {chat_obj_info.restriction_reason[0].reason}\n" caption += f"> Text: {chat_obj_info.restriction_reason[0].text}\n\n" else: caption += "\n" if hasattr(chat_obj_info, "scam") and chat_obj_info.scam: caption += "Scam: <b>Yes</b>\n\n" if hasattr(chat_obj_info, "verified"): caption += f"Verified by Telegram: {verified}\n\n" if description: caption += f"Description: \n<code>{description}</code>\n" return caption CMD_HELP.update({ "chatinfo": ".chatinfo [optional: <reply/tag/chat id/invite link>]\ \nUsage: Gets info of a chat. Some info might be limited due to missing permissions." })
text = "Top **{}** active members in **{}**:\n\n".format( count, chat_name) count = 1 for key, value in users.items(): text += "{}. {}: `{}` Messages\n".format(count, key, value) count += 1 await event.edit(text) return CMD_HELP.update({ "chat": "`.chatid`\ \nUsage: Fetches the current chat's ID\ \n\n`.userid`\ \nUsage: Fetches the ID of the user in reply, if its a forwarded message, finds the ID for the source.\ \n\n`.log`\ \nUsage: Forwards the message you've replied to in your bot logs group.\ \n\n`.inactive`\ \nUsage: Shows every inactive user in the group.\ \n\n`.pinact <message>`\ \nUsage: Pings every inactive user in the group.\ \n\n.count [optional: <reply/tag>]\ \nUsage: Counts the messages from an user in a chat.\ \n\n.topusers [optional: <tag/id>]\ \nUsage: Lists the top members in a chat.\ \nNote: The more members a chat have the longer the process takes." })
from tg_userbot import CMD_HELP, BOTLOG, BOTLOG_CHATID, bot from tg_userbot.events import register from asyncio import sleep from tg_userbot.modules.admin import get_user_from_event @register(outgoing=True, pattern="^\.kickme$") async def kickme(leave): """ Basically it's .kickme command """ await leave.edit("`Nope, no, no, I go away`") await sleep(0.1) await leave.client.kick_participant(leave.chat_id, 'me') CMD_HELP.update({ 'kickme': '`.kickme\nUsage:- kicks you out of the group.`' })
return url = get(f'https://dl.twrp.me/{device}/') if url.status_code == 404: reply = f"`Couldn't find twrp downloads for {device}!`\n" await request.edit(reply) return page = BeautifulSoup(url.content, 'lxml') download = page.find('table').find('tr').find('a') dl_link = f"https://dl.twrp.me{download['href']}" dl_file = download.text size = page.find("span", {"class": "filesize"}).text date = page.find("em").text.strip() reply = f'**Latest TWRP for {device}:**\n' \ f'[{dl_file}]({dl_link}) - __{size}__\n' \ f'**Updated:** __{date}__\n' await request.edit(reply) CMD_HELP.update({ "android": ".magisk\ \nGet latest Magisk releases\ \n\n.device <codename>\ \nUsage: Get info about android device codename or model.\ \n\n.codename <brand> <device>\ \nUsage: Search for android device codename.\ \n\n.specs <brand> <device>\ \nUsage: Get device specifications info.\ \n\n.twrp <codename>\ \nUsage: Get latest twrp download for android device." })
from tg_userbot import BOTLOG, BOTLOG_CHATID, AUTOMATION_ENABLED, AUTOMATION_SENDERS, AUTOMATION_COMMANDS, \ AUTOMATION_TRIGGERS, CMD_HELP from tg_userbot.events import register AUTOMATOR_REPLIES = "Testing Automation again" @register(incoming=True) async def automator(sender): if AUTOMATION_ENABLED and sender.is_private and (sender.sender_id in AUTOMATION_SENDERS): value = 0 for trigger in AUTOMATION_TRIGGERS: if trigger in sender.raw_text: commandId = AUTOMATION_TRIGGERS.index(trigger) command = AUTOMATION_COMMANDS[commandId] x = sender.raw_text.split(trigger) data = x[1] replyStr = command + " " + data + " " + AUTOMATOR_REPLIES await sender.reply(replyStr) if BOTLOG: await sender.client.send_message(BOTLOG_CHATID, "#AUTOMATION \n\n The command '" + replyStr + "' has been executed in " + str( sender.sender_id)) CMD_HELP.update({ "automation": "Automation is based of config settings for now.\ \nPlease refer to your configuration settings or to tguserbot's owner manual."})
@register(outgoing=True, pattern="^\.repo$") async def repo_is_here(wannasee): """ For .repo command, just returns the repo URL. """ await wannasee.edit( f"Click [here]({UPSTREAM_REPO_URL}) to open my userbot's repository.") @register(outgoing=True, pattern="^\.logoff$") async def logoff(event): # bot shutdown if not event.text[0].isalpha() and event.text[0] in ("."): await event.edit("`Farewell!`") if BOTLOG: await event.client.send_message(BOTLOG_CHATID, "logoff") await event.client.log_out() CMD_HELP.update({ "systools": "`.sysd`\ \nUsage: Shows system information using neofetch.\ \n\n`.status`\ \nUsage: Type .status to see wether your bot is working or not.\ \n\n`.botver`\ \nUsage: Shows the userbot version.\ \n\n`.shutdown`\ \nUsage: Type .shutdown to shutdown the bot.\ \n\n`.logoff`\ \nUsage: Log off.\ \n\n`.repo`\ \nUsage: Shows bot github repo." })
DocumentAttributeVideo( duration=0, w=1, h=1, round_message=True, supports_streaming=True, ) ], progress_callback=lambda d, t: asyncio.get_event_loop( ).create_task( progress(d, t, uas_event, c_time, "Uploading...", file_name))) elif spam_big_messages: await uas_event.edit("TBD: Not (yet) Implemented") return os.remove(thumb) await uas_event.edit("Uploaded successfully !!") except FileNotFoundError as err: await uas_event.edit(str(err)) else: await uas_event.edit("404: File Not Found") CMD_HELP.update({ "upload_download": "`.download <link|filename>` or reply to media\ \nUsage: Downloads file to the server.\ \n\n`.upload <path in server>`\ \nUsage: Uploads a locally stored file to the chat." })