os.system(f". venv/bin/activate && python userbot//helpers//skyrim.py \"{text}\" {level}") except Exception: await message.edit("```Failed to generate skill```") time.sleep(2) await message.delete() try: await UserBot.send_photo( message.chat.id, 'userbot/downloads/skyrim.png', reply_to_message_id=ReplyCheck(message) ) await message.delete() except Exception: await message.edit("```Failed to send skill```") time.sleep(2) await message.delete() finally: os.remove('userbot/downloads/skyrim.png') except Exception as e: print(e) # Command help section add_command_help( 'skyrim', [ ['.skyrim', 'Generate skyrim skill image.\n .skyrim <before> <after>'], ['.skill', 'Generate skyrim skill image.\n .skill <before> <after>'], ] )
progress = await bot.send_message(message.chat.id, "`Processed 0 messages...`") total = 0 async for msg in bot.iter_history(message.chat.id, 1000): total += 1 if total % 100 == 0: await progress.edit_text(f"`Processed {total} messages...`") time.sleep(0.5) if msg.text: for word in msg.text.split(): words[word.lower()] += 1 if msg.caption: for word in msg.caption.split(): words[word.lower()] += 1 freq = sorted(words, key=words.get, reverse=True) out = "Word Counter\n" for i in range(25): out += f"{i + 1}. **{words[freq[i]]}**: {freq[i]}\n" await progress.edit_text(out) # Command help section add_command_help('metrics', [ [ '.wordcount', 'Finds the 25 most used words in the last 1000 messages in a group or private chat. Use in ' 'chat you want to find the metric in.' ], ])
# print(crosref) if "title" in list(word1): out += ("**__Error Note__**\n\n▪️`" + word1["title"] + "\n\n▪️" + word1["message"] + "\n\n▪️<i>" + word1["resolution"] + "</i>`") return out if not input_string: await message.edit("`Plz enter word to search‼️`") else: word = input_string r_dec = await AioHttp().get_json( f"https://api.dictionaryapi.dev/api/v1/entries/en/{word}") v_word = input_string if isinstance(r_dec, list): r_dec = r_dec[0] v_word = r_dec['word'] last_output = out_print(r_dec) if last_output: await message.edit("`Search reasult for `" + f" {v_word}\n\n" + last_output) else: await message.edit('`No result found from the database.`') # Command help section add_command_help('dictionary', [ ['.define | .dict', 'Define the word you send or reply to.'], ])
async def urban_dictionary(bot, message): if len(message.text.split()) == 1: await message.edit("Usage: `ud example`") return try: text = message.text.split(None, 1)[1] response = await AioHttp().get_json( f"http://api.urbandictionary.com/v0/define?term={text}") word = response["list"][0]["word"] definition = response["list"][0]["definition"] example = response["list"][0]["example"] resp = (f"**Text: {replace_text(word)}**\n" f"**Meaning:**\n`{replace_text(definition)}`\n\n" f"**Example:**\n`{replace_text(example)}` ") await message.edit(resp) return except Exception as e: await message.edit("`The Urban Dictionary API could not be reached`") print(e) await sleep(3) await message.delete() # Command help section add_command_help( "dictionary", [ [".ubran | .ud", "Define the word you send or reply to."], ], )
from userbot import UserBot from pyrogram import Filters, Message import requests from userbot.plugins.help import add_command_help DOGBIN = "https://del.dog/" @UserBot.on_message( Filters.command(['dogbin', 'bin', 'paste'], ".") & Filters.me) async def dogbin(bot: UserBot, message: Message): await message.edit_text("`pasting...`") text = message.reply_to_message.text try: paste = requests.post(f"{DOGBIN}/documents", data=text).json()["key"] except requests.exceptions.RequestException as e: await message.edit_text("`Pasting failed`") print(e) else: await message.edit_text(f"{DOGBIN}/{paste}", disable_web_page_preview=True) add_command_help('dogbin', [ ['.dogbin', 'Show the creator of this userbot.'], ['.bin', 'Show the creator of this userbot.'], ['.paste', 'Show the creator of this userbot.'], ])
'me', f'#userbot_restart, {message.chat.id}, {message.message_id}') if 'p' in message.text and 'g' in message.text: asyncio.get_event_loop().create_task( UserBot.restart(git_update=True, pip=True)) elif 'p' in message.text: asyncio.get_event_loop().create_task(UserBot.restart(pip=True)) elif 'g' in message.text: asyncio.get_event_loop().create_task(UserBot.restart(git_update=True)) else: asyncio.get_event_loop().create_task(UserBot.restart()) # Command help section add_command_help('start', [['.alive', 'Check if the bot is alive or not.'], ['.repo', 'Display the repo of this userbot.'], ['.creator', 'Show the creator of this userbot.'], ['.id', 'Send id of what you replied to.'], ['.up `or` .uptime', 'Check bot\'s current uptime.']]) add_command_help('restart', [ ['.restart', 'You are retarded if you do not know what this does.'], ['.restart g', 'Pull latest changes from git repo and restarts.'], ['.restart p', 'Installs pip requirements restarts.'], [ '.restart gp', 'Pull latest changes from git repo, install pip requirements and restarts.' ], ])
try: data = await AioHttp().get_json(fact_link) fact_text = data["fact"] except Exception: await message.edit("```The fact API could not be reached```") await asyncio.sleep(3) await message.delete() else: await message.edit(fact_text, disable_web_page_preview=True) else: await message.edit("`Unsupported animal...`") await asyncio.sleep(2) await message.delete() # Animal image help animal_image_help = [] for x in animals_without_facts: animal_image_help.append([f".{x}", f"Sends a random picture of a {x}"]) animal_image_help.append( ["These commands", "Works without the command prefix also"]) add_command_help("animals", animal_image_help) add_command_help( "facts", [[f".fact {x}", f"Send a random fact about {x}"] for x in animals_with_facts], )
except Exception: await message.edit_text("`Pasting failed`") await asyncio.sleep(2) await message.delete() return else: url = f'https://nekobin.com/{key}' reply_text = f'Nekofied to **Nekobin** : {url}' delete = True if len(message.command) > 1 \ and message.command[1] in ['d', 'del'] \ and message.reply_to_message.from_user.is_self else False if delete: await asyncio.gather( UserBot.send_message(message.chat.id, reply_text, disable_web_page_preview=True), message.reply_to_message.delete(), message.delete()) else: await message.edit_text( reply_text, disable_web_page_preview=True, ) add_command_help('paste', [ [ '.paste `or` .bin `or` .neko `or` .nekobin', 'Create a Nekobin paste using replied to message.' ], ])
# Construct the help from the same loop eh. command = f".{dv}" if "alts" in dhivehi_text_memes[dv]: for y in dhivehi_text_memes[dv]["alts"]: command += f" __or__ .{y}" fixed_memes_help.append([command, dhivehi_text_memes[dv]["help"]]) @UserBot.on_message( filters.command(dhivehi_text_memes_commands, ".") & filters.me) async def dhivehi_memes(_, message: Message): cmd = message.command[0] meme = None if cmd not in dhivehi_text_memes: for x in dhivehi_text_memes: if "alts" in dhivehi_text_memes[x] and cmd in dhivehi_text_memes[ x]["alts"]: meme = dhivehi_text_memes[x] break else: meme = dhivehi_text_memes[message.command[0]] if meme: await message.edit(meme["meme"]) # Command help section add_command_help("dhivehi", fixed_memes_help)
@UserBot.on_message(Filters.command("hmention", ".") & Filters.me) async def hidden_mention(_, message: Message): if len(message.command) < 3: await message.edit("Incorrect format\nExample: .hmention @Athfan") await asyncio.sleep(3) await message.delete() return try: user = await UserBot.get_users(message.command[1]) except Exception: await message.edit("User not found") await asyncio.sleep(3) await message.delete() return _hmention = hmention(user.id, ' '.join(message.command[2:])) await message.edit(_hmention) # Command help section add_command_help( 'mention', [[ '.mention', 'Mention a user with a different name\nExample: `.mention @Athfan CTO`' ], [ '.hmention', 'Mention a user with a hidden text\nExample: `.hmention @Athfan`' ]])
from pyrogram.types import Message from userbot import UserBot from userbot.plugins.help import add_command_help @UserBot.on_message( filters.command(["screenshot", "ss"], ".") & filters.private & filters.me) async def screenshot(bot: UserBot, message: Message): await asyncio.gather( message.delete(), bot.send( functions.messages.SendScreenshotNotification( peer=await UserBot.resolve_peer(message.chat.id), reply_to_msg_id=0, random_id=UserBot.rnd_id(), )), ) # Command help section add_command_help( "screenshot", [ [ ".screenshot", "Send a notification in a private chat (not secret) to annoy or troll your friends.", ], ], )
) else: await UserBot.send_photo( message.chat.id, user_pic[0].file_id, caption=WHOIS_PIC.format( full_name=FullName(user), user_id=user.id, first_name=user.first_name, last_name=user.last_name or "", username=user.username or "", last_online=LastOnline(user), profile_pics=pic_count, common_groups=len(common.chats), bio=desc or "`No bio set up.`", profile_pic_update=ProfilePicUpdate(user_pic), ), reply_to_message_id=ReplyCheck(message), file_ref=user_pic[0].file_ref, ) await message.delete() add_command_help('whois', [[ '.whois', 'Finds out who the person is. Reply to message sent by the person' 'you want information from and send the command. Without the dot also works.' ]])
drawing = svg2rlg(f"{file_name}.svg") renderPM.drawToFile(drawing, f"{file_name}.png") except UnboundLocalError: await message.edit("Username does not exist!") await sleep(2) await message.delete() return await asyncio.gather( bot.send_photo( chat_id=message.chat.id, photo=f"{file_name}.png", caption=git_user, reply_to_message_id=ReplyCheck(message), ), message.delete(), ) for file in iglob(f"{file_name}.*"): os.remove(file) # Command help section add_command_help( "git", [ [".lastcommit | .lc", "Gets the last commit message."], [".ggraph | .commitgraph", "Gets the commit graph for a Github user."], ], )
message.chat.id, message.reply_to_message.message_id, disable_notification=disable_notification ) await message.edit("`Pinned message!`") else: # You didn't reply to a message and we can't pin anything. ffs await message.edit( "`Reply to a message so that I can pin the god damned thing...`") else: # You have no business running this command. await message.edit("`I am not an admin here lmao. What am I doing?`") else: # Are you f*****g dumb this is not a group ffs. await message.edit("`This is not a place where I can pin shit.`") # And of course delete your lame attempt at changing the group picture. # RIP you. # You're probably gonna get ridiculed by everyone in the group for your failed attempt. # RIP. await asyncio.sleep(3) await message.delete() # Command help section add_command_help( 'admin', [ ['.pin', 'Pin the replied to message.'] ] )
resp = await AioHttp.get_raw(url) f = await aiofiles.open(f"{file_name}.svg", mode='wb') await f.write(resp) await f.close() try: drawing = svg2rlg(f"{file_name}.svg") renderPM.drawToFile(drawing, f"{file_name}.png") except UnboundLocalError: await message.edit("Username does not exist!") await sleep(2) await message.delete() return await asyncio.gather( bot.send_photo(chat_id=message.chat.id, photo=f"{file_name}.png", caption=git_user, reply_to_message_id=ReplyCheck(message)), message.delete()) for file in iglob(f"{file_name}.*"): os.remove(file) # Command help section add_command_help('git', [ ['.lastcommit | .lc', 'Gets the last commit message.'], ['.ggraph | .commitgraph', 'Gets the commit graph for a Github user.'], ])
sleep(3) await message.delete() else: await message.edit(fact_text, disable_web_page_preview=True) else: await message.edit("`Unsupported animal...`") await asyncio.sleep(2) await message.delete() # Animal image help animal_image_help = [] for x in animals: animal_image_help.append([f".{x}", f"Sends a random picture of a {x}"]) animal_image_help.append(['These commands', "Works without the command prefix also"]) add_command_help( 'animals', animal_image_help ) # Animal fact help fact_help = [] for x in animals: if x != 'redpanda': fact_help.append([f".fact {x}", f"Send a random fact about {x}"]) add_command_help( 'facts', fact_help )
import asyncio import aiohttp from pyrogram import Filters, Message from userbot import UserBot from userbot.helpers.PyroHelpers import ReplyCheck, GetChatID from userbot.plugins.help import add_command_help @UserBot.on_message(Filters.command(['pat', 'pats'], '.') & Filters.me) async def give_pats(bot: UserBot, message: Message): URL = "https://some-random-api.ml/animu/pat" async with aiohttp.ClientSession() as session: async with session.get(URL) as request: if request.status == 404: return await message.edit("`no Pats for u :c") result = await request.json() url = result.get("link", None) await asyncio.gather( message.delete(), bot.send_video(GetChatID(message), url, reply_to_message_id=ReplyCheck(message))) # Command help section add_command_help('pats', [ ['.pat | .pats', 'Give pats.'], ])
msg = await bot.get_history("@QuotLyBot", 1) print(msg) is_sticker = True except: await sleep(1) progress += random.randint(0, 5) if progress > 100: await message.edit('There was a long running error') return try: await message.edit("```Making a Quote\nProcessing {}%```".format(progress)) except: await message.edit("ERROR") if msg_id := msg[0]['message_id']: await asyncio.gather( message.delete(), bot.forward_messages(message.chat.id, "@QuotLyBot", msg_id) ) # Command help section add_command_help( 'quotly', [ ['.q | .quote', 'Make a quote with reply to message.'], ] )
await sleep(2) await message.delete() @UserBot.on_message(Filters.command('carbonlang', '!') & Filters.me) async def send_carbon_lang(_, message: Message): """ Edits message to show current set carbon language """ await message.edit_text(get_carbon_lang()) await sleep(5) await message.delete() def get_carbon_lang(): """ Gets carbon language. Default py """ return CARBON_LANG add_command_help( 'carbon', [ ['.carbon', 'Generates a carbon image of your code.\nUsage: `.carbon` reply to message or command args'], ['.carbonlang', 'Change carbon language for syntax highlighting.\nUsage: `.carbonlang` reply to message or ' 'command args\n' 'Please use file extensions for best results.'], ['!carbonlang', 'Show current carbon language. Default is python.\nUsage: `!carbonlang`'], ] )
@UserBot.on_message(Filters.me & Filters.command(["ud"], '.')) async def urban_dictionary(bot, message): if len(message.text.split()) == 1: await message.edit("Usage: `ud example`") return try: text = message.text.split(None, 1)[1] response = await AioHttp().get_json( f"http://api.urbandictionary.com/v0/define?term={text}") word = response['list'][0]['word'] definition = response['list'][0]['definition'] example = response['list'][0]['example'] resp = f"**Text: {replace_text(word)}**\n" \ f"**Meaning:**\n`{replace_text(definition)}`\n\n" \ f"**Example:**\n`{replace_text(example)}` " await message.edit(resp) return except Exception as e: await message.edit("`The Urban Dictionary API could not be reached`") print(e) await sleep(3) await message.delete() # Command help section add_command_help('dictionary', [ ['.ubran | .ud', 'Define the word you send or reply to.'], ])
'emoji': '🎲', 'help': 'The special dice emoji' }, 'bb': { 'emoji': '🏀', 'help': 'The special basketball emoji' }, } special_emoji_commands = [x for x in special_emojis_dict] @UserBot.on_message(Filters.command(special_emoji_commands, '.') & Filters.me) async def special_emojis(_, message: Message): emoji = special_emojis_dict[message.command[0]] await message.delete() await UserBot.send_dice(message.chat.id, emoji['emoji']) # Command help section special_emoji_help = [['.moon', 'Cycles all the phases of the moon emojis.'], ['.clock', 'Cycles all the phases of the clock emojis.'], ['.thunder', 'Cycles thunder.'], ['.heart', 'Cycles heart emojis.'], ['.earth `or` .globe', 'Make the world go round.']] for x in special_emojis_dict: command = f'.{x}' special_emoji_help.append([command, special_emojis_dict[x]['help']]) add_command_help('emoji', special_emoji_help)
async def generate_qr(bot: UserBot, message: Message): if qr_text := await UserBot.extract_command_text(message): img = qrcode.make(qr_text) with open('downloads/qr.png', 'wb') as f: img.save(f) await asyncio.gather( bot.send_photo(message.chat.id, 'downloads/qr.png'), message.delete() ) @UserBot.on_message(filters.command('qrscan', '.') & filters.reply & filters.me) async def scan_qr(_, message: Message): await message.reply_to_message.download('downloads/qr.png') img = cv2.imread('downloads/qr.png') detector = cv2.QRCodeDetector() data, bbox, straight_qrcode = detector.detectAndDecode(img) await message.edit_text(data) # Command help section add_command_help( "qr", [ [".qr", "Generate QR codes for given input."], [".qrscan", "Scan a QR code and send it's contents."], ], )
# Construct the help from the same loop eh. command = f'.{dv}' if 'alts' in dhivehi_text_memes[dv]: for y in dhivehi_text_memes[dv]['alts']: command += f' __or__ .{y}' fixed_memes_help.append([command, dhivehi_text_memes[dv]['help']]) @UserBot.on_message(filters.command(dhivehi_text_memes_commands, ".") & filters.me) async def dhivehi_memes(_, message: Message): cmd = message.command[0] meme = None if cmd not in dhivehi_text_memes: for x in dhivehi_text_memes: if 'alts' in dhivehi_text_memes[x] and cmd in dhivehi_text_memes[x]['alts']: meme = dhivehi_text_memes[x] break else: meme = dhivehi_text_memes[message.command[0]] if meme: await message.edit(meme['meme']) # Command help section add_command_help( 'dhivehi', fixed_memes_help )
from pyrogram import Filters, Message from userbot import UserBot from userbot.plugins.help import add_command_help the_regex = "^r\/([^\s\/])+" # Generate full Reddit link with subreddit @UserBot.on_message(Filters.regex(the_regex) & Filters.me) async def subreddit_link(bot: UserBot, message: Message): html = "<a href='{link}'>{string}</a>" await message.edit(html.format(link="https://reddit.com/" + message.text, string=message.text), disable_web_page_preview=True, parse_mode="html") # Command help section add_command_help('reddit', [ [ 'r/telegram', 'As long as your message starts with r/, it will automatically generate a subreddit link and ' 'hyperlink your message.' ], ])
word1["message"] + "\n\n▪️<i>" + word1["resolution"] + "</i>`") return out if not input_string: await message.edit("`Plz enter word to search‼️`") else: word = input_string r_dec = await AioHttp().get_json( f"https://api.dictionaryapi.dev/api/v1/entries/en/{word}") v_word = input_string if isinstance(r_dec, list): r_dec = r_dec[0] v_word = r_dec["word"] last_output = out_print(r_dec) if last_output: await message.edit("`Search result for `" + f" {v_word}\n\n" + last_output) else: await message.edit("`No result found from the database.`") # Command help section add_command_help( "dictionary", [ [".define | .dict", "Define the word you send or reply to."], ], )
txt = None if message.caption: txt = message.caption elif message.text: txt = message.text for word in bad_words: try: txt = re.sub(word, "bruh", txt, flags=re.IGNORECASE) except Exception: pass if message.caption: if txt != message.caption: await message.edit_caption(txt) elif message.text: if txt != message.text: await message.edit(txt) except MessageNotModified: return # Command help section add_command_help( "vulgar", [ [".vulgar", "Toggles bad word filtering on and off."], ], )
add_command_help('text', [ ['.nice', 'Replaces command with NICENICENICENICE.'], ['.compliment', 'Replaces command with a nice compliment.'], [ '.devexcuse', 'Replaces command with an excuse that a developer would give.' ], ['.reverse', 'Sends ASCII version of the Uno reverse card.'], [ '.slap', 'Sends a randomly generated slap text. Can become very random at some times.' ], [ '.insult', 'Sends a randomly generated insult. Can become very random at some times.' ], ['.vapor', 'Vaporizes the text.'], ['.weeb `or` .weebify', 'Weebifies the text.'], ['.ok', 'Sends -_____- with a fast animation.'], ['-_-', 'Extends to -________-'], ['.f', 'Pay respects'], ['.F', 'Pay respects but filled'], ['#f', 'Pay respects but calligraphy.'], ['.mockt', 'Mock (text only version)'], ['.dice', 'Send dice animation'], ['.target', 'Send target animation'], ['oof', 'Oof'], [';_; `or` .sad `or` cri', ';_;'], ['.ht', 'Heads or Tails'], ['.reverset', 'Reverses the text'], ['.shrug', 'Random shrug'], ])
f = filters.chat([]) @UserBot.on_message(f) async def auto_read(_, message: Message): await UserBot.read_history(message.chat.id) message.continue_propagation() @UserBot.on_message(filters.command("autoscroll", ".") & filters.me) async def add_to_auto_read(_, message: Message): if message.chat.id in f: f.remove(message.chat.id) await message.edit("Autoscroll deactivated") else: f.add(message.chat.id) await message.edit("Autoscroll activated") # Command help section add_command_help( "autoscroll", [ [ ".autoscroll", "Send .autoscroll in any chat to automatically read all sent messages until you call " "autoscroll again. This is useful if you have Telegram open on another screen.", ], ], )
api = text_apis_data[api_key] try: try: data = await AioHttp().get_json(api['url']) resp_json = data[api['target_key']] if 'format' in api: txt = api['format'].format(resp_json) else: txt = resp_json.capitalize() if message.from_user.is_self: await message.edit(txt) else: await message.reply(txt) except Exception: data = await AioHttp().get_text(api['url']) if message.from_user.is_self: await message.edit(data) else: await message.reply(data) except ClientError as e: print(e) await message.delete() # Command help section for x in text_apis_data: add_command_help('text', [ [f'.{x}', text_apis_data[x]['help']], ])
from userbot import UserBot from pyrogram import Filters, Message from userbot.helpers.constants import First from userbot.plugins.help import add_command_help import time @UserBot.on_message(Filters.command("spam", ".") & Filters.me) async def alive(bot: UserBot, message: Message): # Get current chat and spam to there. # if in group and replied to user, then spam replying to user. times = message.command[1] to_spam = message.command[2] if message.chat.type in ['supergroup', 'group'] and message.reply_to_message: for x in range(int(times)): await bot.send_message(message.chat.id, to_spam, reply_to_message_id=message.reply_to_message.message_id) time.sleep(0.15) if message.chat.type is "private": for x in range(int(times)): await bot.send_message(message.chat.id, to_spam) time.sleep(0.15) # Command help section add_command_help( 'spam', [['.spam', 'Spam something.']] )