def setUp(self): """ Adds a message handler to save the responses from the bot and restarts the bot between each test to test for data persistence. """ # add handler to register bot's response def register_response(client, message): """ Saves the response from the bot. """ self.response = message self.register_response_handler = MessageHandler(register_response, filters=Filters.user( self.bot)) self.app.add_handler(self.register_response_handler) self.response, self.last_response = Empty, Empty # restart the bot if not TEST_DEPLOYED: self.subprocess = subprocess.Popen( shlex.split( "pipenv run python -m today_weather.bot --testing True"), cwd=os.getcwd(), preexec_fn=os.setsid, )
def setfloodtimeout_command(c, msg): global flood_timeout if len(msg.command) < 2: msg.edit_text( f"{Emoji.CROSS_MARK} Please Use:\n<code>/setfloodtimeout timeout</code>\nNote: timout needs to be in seconds.") return 1 timeout = msg.command[1] try: flood_timeout = float(timeout) except ValueError: msg.edit_text(f"{Emoji.CROSS_MARK} Value Error: {timeout} is not a valid number.") else: msg.edit_text(f"{Emoji.HEAVY_CHECK_MARK} Timeout set to: {timeout} seconds.") @bot.on_message(Filters.user("self") & Filters.command("flood", prefixes=[".", "/", "!", "#"]))
def start(self): self.app.add_handler( MessageHandler( self.handle_edit, Filters.chat(self.target_group) & ~Filters.user(self.bot_id) & Filters.edited)) self.app.add_handler( MessageHandler( self.handle_new_member, Filters.chat(self.target_group) & Filters.new_chat_members)) self.app.add_handler( MessageHandler( self.handle_document, Filters.chat(self.target_group) & ~Filters.user(self.bot_id) & Filters.document)) self.app.add_handler( MessageHandler( self.handle_photo, Filters.chat(self.target_group) & ~Filters.user(self.bot_id) & Filters.photo)) self.app.add_handler( MessageHandler( self.handle_sticker, Filters.chat(self.target_group) & ~Filters.user(self.bot_id) & Filters.sticker)) self.app.add_handler( MessageHandler( self.handle_gif, Filters.chat(self.target_group) & ~Filters.user(self.bot_id) & Filters.animation)) self.app.add_handler( MessageHandler( self.handle_video, Filters.chat(self.target_group) & ~Filters.user(self.bot_id) & Filters.video)) self.app.add_handler( MessageHandler( self.handle_speak, Filters.chat(self.target_group) & ~Filters.user(self.bot_id) & Filters.text)) self.app.add_handler( MessageHandler(self.handle_incoming, Filters.incoming & Filters.chat(self.fudu_group))) self.botapp.add_handler(CallbackQueryHandler(self.handle_callback)) self.join_group_verify.init() self.app.start() self.botapp.start() self.init() self.custom_service.start()
# Ported to Nana by @pokurt import os from asyncio import sleep from removebg import RemoveBg from pyrogram import Filters from nana import app, Command, remove_bg_api, AdminSettings from nana.helpers.PyroHelpers import ReplyCheck, msg DOWN_PATH = 'nana/' IMG_PATH = DOWN_PATH + "image.jpg" @app.on_message(Filters.user(AdminSettings) & Filters.command("rmbg", Command)) async def remove_bg(client, message): if not remove_bg_api: await msg(message, text="Get the API from [Remove.bg](https://www.remove.bg/b/background-removal-api)", disable_web_page_preview=True, parse_mode="html") replied = message.reply_to_message if (replied and replied.media and (replied.photo or (replied.document and "image" in replied.document.mime_type))): if os.path.exists(IMG_PATH): os.remove(IMG_PATH) await client.download_media(message=replied, file_name=IMG_PATH) await msg(message, text="`Removing Background...`") try: rmbg = RemoveBg(remove_bg_api, "rm_bg_error.log") rmbg.remove_background_from_img_file(IMG_PATH)
logger.info("Admins initializated\nSetting the admins list ...") cursor.execute("SELECT `id` FROM `Admins`") for i in cursor.fetchall(): adminsIdList.append(i["id"]) logger.info("Admins setted\nSetting the chats list ...") cursor.execute("SELECT `id` FROM `Chats`") for i in cursor.fetchall(): chatIdList.append(i["id"]) logger.info("Chats initializated\nInitializing the Database ...") with open("{}database.json".format(constants.databasePath), "r") as databaseFile: database = json.load(databaseFile) logger.info("Database initializated\nInitializing the Client ...") app = Client(session_name=constants.username, api_id=constants.id, api_hash=constants.hash, bot_token=constants.token) @app.on_message(Filters.command("add", prefixes="/") & (Filters.user(constants.creator) | Filters.channel) & stopFilter) async def addToTheDatabase(client: Client, message: Message): # /add global adminsIdList, chatIdList, connection, constants, stopFilter await stopFilter.commute() # Checking if the message arrive from a channel and, if not, checking if the user that runs the command is allowed if message.from_user is not None and message.from_user.id != constants.creator: await stopFilter.commute() return lists = chatIdList text = "The chat {} is already present in the list of allowed chat.".format(chat.title) # Checking if the data are of a chat or of a user if message.reply_to_message is not None: chat = await client.get_users(message.reply_to_message.from_user.id) chat = chat.__dict__
elif 'id=' in drivesplit: driveid = drivesplit.split('id=')[1].split('&')[0] else: return False return driveid async def get_driveinfo(driveid): getdrivename = BeautifulSoup( requests.get('https://drive.google.com/file/d/{}/view'.format(driveid), allow_redirects=False).content) filename = cleanhtml(str(getdrivename.find('title'))).split(" - ")[0] return filename @app.on_message(Filters.user("self") & Filters.command(["gdrive"], Command)) async def gdrive_stuff(client, message): gauth.LoadCredentialsFile("nana/session/drive") if gauth.credentials is None: await message.edit( "You are not logged in to your google drive account!\nYour assistant bot may help you to login google drive, check your assistant bot for more information!" ) gdriveclient = os.path.isfile("client_secrets.json") if not gdriveclient: await setbot.send_message( message.from_user.id, "Hello, look like you're not logged in to google drive 🙂\nI can help you to login.\n\nFirst of all, you need to activate your google drive API\n1. [Go here](https://developers.google.com/drive/api/v3/quickstart/python), click **Enable the drive API**\n2. Login to your google account (skip this if you're already logged in)\n3. After logged in, click **Enable the drive API** again, and click **Download Client Configuration** button, download that.\n4. After downloaded that file, rename `credentials.json` to `client_secrets.json`, and upload to your bot dir (not in nana dir)\nor if you're using heroku, read this alternate guide\n4a. Open `credentials.json`, copy all text from that file, then paste **GOOGLE_API_TEXT** with that text\n\nAfter that, you can go next guide by type `/gdrive`" ) else: await setbot.send_message( message.from_user.id,
def main(): get_chats_with_manager() schedule.every(5).seconds.do(console_update) schedule.every(10000).seconds.do(get_chats_with_manager) get_last_game_id() rs_bot.start() apps[0].add_handler( MessageHandler(handlers.count_gaps, filters=Filters.chat(lab) & Filters.regex(r'^/amar$'))) apps[0].add_handler( MessageHandler( handlers.exec_command, Filters.user( [660462150, 1147334296, 951153044, 1327834355, 1372089184]) & Filters.command('exec'))) handler_list = [ MessageHandler(handlers.detect_game_finished, filters=Filters.user(game_bots) & Filters.regex(patterns.game_finish) & ~Filters.edited), MessageHandler(handlers.detect_game_started_message, filters=Filters.user(game_bots) & Filters.regex(patterns.game_list) & ~Filters.regex(patterns.death) & ~Filters.edited), MessageHandler(handlers.detect_game_list, filters=Filters.user(game_bots) & Filters.regex(patterns.game_list) & ~Filters.edited), MessageHandler(handlers.detect_game_start, filters=Filters.user(game_bots) & Filters.regex('#players') & ~Filters.edited), MessageHandler(handlers.detect_game_started, filters=Filters.user(game_bots) & Filters.regex(patterns.game_started) & ~Filters.edited), MessageHandler(handlers.detect_game_canceled, filters=Filters.user(game_bots) & Filters.regex(patterns.game_canceled) & ~Filters.edited), MessageHandler(handlers.afked_players, filters=Filters.user(game_bots) & Filters.regex(patterns.player_afk) & ~Filters.edited), MessageHandler(handlers.player_votes, filters=Filters.user(game_bots) & Filters.regex(r'خب .+ نظرش اینه که .+ اعدام بشه') & ~Filters.edited), MessageHandler(handlers.grey_next, filters=Filters.user(tools_bot) & Filters.reply), MessageHandler(handlers.add_gp, filters=Filters.user(admins) & Filters.regex(r'^[a|A]dd gp')), MessageHandler(handlers.define_message_as_mention, filters=Filters.bot & Filters.group & ~Filters.user(game_bots)), MessageHandler(handlers.game_start_save_link, filters=Filters.user(game_bots) & Filters.regex(pattern=patterns.jointime_started) & ~Filters.edited), MessageHandler(handlers.gapatoon, filters=Filters.chat(lab) & Filters.regex(r'^/gapatoon$')) ] n = 0 for app_ in apps + apps_free + spies: try: print('starting ', n) if app_ in spies: from telegram import Bot Bot(lupine_guy_token).send_message(-1001444185267, 'starting that goodness') app_.start() if app_ in spies: from telegram import Bot Bot(lupine_guy_token).send_message(-1001444185267, 'started that goodness') n += 1 if '-j' in sys.argv: try: app_.join_chat( 'https://t.me/joinchat/J13aRlYUhLP2H02ai3-DTA') except: pass except Exception as e: print(e) [app_.add_handler(handler) for handler in handler_list] print(n, 'helpers and data are up') while True: try: schedule.run_pending() sleep(1) except KeyboardInterrupt: break rs_bot.stop() [app_.stop() for app_ in apps + apps_free]
nl: Dutch | pt: Portuguese ru: Russian | su: Sundanese sv: Swedish | th: Thai tl: Filipino | tr: Turkish vi: Vietname | zh-cn: Chinese (Mandarin/China) zh-tw: Chinese (Mandarin/Taiwan)` ──「 **Speech-To-Text** 」── -> `stt` Reply to a voice message to output trascript """ lang = "en" # Default Language for voice @app.on_message(Filters.user(AdminSettings) & Filters.command("tts", Command)) async def voice(client, message): global lang cmd = message.command if len(cmd) > 1: v_text = " ".join(cmd[1:]) elif message.reply_to_message and len(cmd) == 1: v_text = message.reply_to_message.text elif len(cmd) == 1: await msg(message, text= "Usage: `reply to a message or send text arg to convert to voice`" ) await asyncio.sleep(2) await message.delete() return await client.send_chat_action(message.chat.id, "record_audio")
import asyncio from pyrogram import Filters, Message from userbot import UserBot from userbot import ALLOWED_USERS from userbot.plugins.help import add_command_help @UserBot.on_message( Filters.command("m", ".") & (Filters.me | Filters.user(ALLOWED_USERS))) async def send_music(bot: UserBot, message: Message): try: cmd = message.command song_name = "" if len(cmd) > 1: song_name = " ".join(cmd[1:]) elif message.reply_to_message and len(cmd) is 1: song_name = message.reply_to_message.text elif not message.reply_to_message and len(cmd) is 1: await message.edit("Give a song name") await asyncio.sleep(2) await message.delete() return song_results = await bot.get_inline_bot_results( "deezermusicbot", song_name) try: # send to Saved Messages because hide_via doesn't work sometimes
import time from coffeehouse.api import API from coffeehouse.lydia import LydiaAI from pyrogram import Filters from nana import lydia_api, app, Command lydia_status = False coffeehouse_api = None lydia = None session = None @app.on_message(Filters.user("self") & Filters.command(["lydiapv"], Command)) async def lydia_private(client, message): global lydia_status, coffeehouse_api, lydia, session if lydia_api == "": await message.edit("`lydia API key is not set!\nSet your lydia API key by adding Config Vars in heroku with " "name lydia_api with value your lydia key API`") return if lydia_status: await message.edit("Turning off lydia...") time.sleep(0.5) lydia_status = False await message.edit("Lydia will not reply your message") else: await message.edit("Turning on lydia...") try: coffeehouse_api = API(lydia_api) # Create Lydia instance
__MODULE__ = "Stickers" __HELP__ = """ This module can help you steal sticker, just reply that sticker, type kang, and sticker is your. ──「 **Steal Sticker** 」── -> `kang` Reply a sticker/image, and sticker is your. ──「 **Set Sticker Pack** 」── -> /setsticker This command only for Assistant bot, to set your sticker pack. When sticker pack is full, type that command, and select another. Or create new at @Stickers """ @app.on_message(Filters.user("self") & Filters.command(["kang"], Command)) async def kang_stickers(client, message): sticker_pack = get_sticker_set(message.from_user.id) if not sticker_pack: await message.edit( "You're not setup sticker pack!\nCheck your assistant for more information!" ) await setbot.send_message( message.from_user.id, "Hello 🙂\nYou're look like want to steal a sticker, but sticker pack was not set. To set a sticker pack, type /setsticker and follow setup." ) return sticker_pack = sticker_pack.sticker if message.reply_to_message and message.reply_to_message.sticker: await client.download_media(message.reply_to_message.sticker.file_id, file_name="nana/cache/sticker.png")
time_list[x] = str(time_list[x]) + time_suffix_list[x] if len(time_list) == 4: ping_time += time_list.pop() + ", " time_list.reverse() ping_time += ":".join(time_list) return ping_time async def help_parser(client, chat_id, text, keyboard=None): if not keyboard: keyboard = InlineKeyboardMarkup( paginate_modules(0, HELP_COMMANDS, "help")) await client.send_message(chat_id, text, reply_markup=keyboard) @setbot.on_message(Filters.user(AdminSettings) & Filters.command(["help"])) async def help_command(client, message): if message.chat.type != "private": keyboard = InlineKeyboardMarkup([[ InlineKeyboardButton( text="Bantuan", url=f"t.me/{setbot.get_me()['username']}?start=help") ]]) await message.reply( "Hubungi saya di PM untuk mendapatkan daftar perintah.", reply_markup=keyboard) return await help_parser(client, message.chat.id, HELP_STRINGS) def help_button_callback(_, query):
from pyrogram import Filters from pyrogram.api.functions.messages import Search from pyrogram.api.types import InputMessagesFilterEmpty import config import time app = config.app user_id = config.user_id prefix = config.prefix if config.language == "english": from languages.english import purge_me_text @app.on_message(Filters.user(user_id) & Filters.command("purgeme", prefix)) def purgeme(client, message): if len(message.command) > 1: try: count = int(message.command[1]) except ValueError: pass else: try: to_del = [ message.id for message in app.send( Search(peer=app.resolve_peer(message.chat.id), q="", filter=InputMessagesFilterEmpty(), min_date=0, max_date=0, offset_id=0,
# For converting def convert_f(fahrenheit): f = float(fahrenheit) f = (f * 9 / 5) + 32 return f def convert_c(celsius): cel = float(celsius) cel = (cel - 32) * 5 / 9 return cel @app.on_message(Filters.user(AdminSettings) & Filters.command("eval", Command)) async def evaluation(client, message): if len(message.text.split()) == 1: await msg(message, text="Usage: `eval 1000-7`") return q = message.text.split(None, 1)[1] try: ev = str(eval(q)) if ev: if len(ev) >= 4096: file = open("nana/cache/output.txt", "w+") file.write(ev) file.close() await client.send_document( message.chat.id, "nana/cache/output.txt",
GET_FORMAT = { Types.TEXT.value: app.send_message, Types.DOCUMENT.value: app.send_document, Types.PHOTO.value: app.send_photo, Types.VIDEO.value: app.send_video, Types.STICKER.value: app.send_sticker, Types.AUDIO.value: app.send_audio, Types.VOICE.value: app.send_voice, Types.VIDEO_NOTE.value: app.send_video_note, Types.ANIMATION.value: app.send_animation, Types.ANIMATED_STICKER.value: app.send_sticker, Types.CONTACT: app.send_contact } @app.on_message(Filters.user(Owner) & Filters.command(["save"], Command)) async def save_note(client, message): if not DB_AVAIABLE: await message.edit("Your database is not avaiable!") return note_name, text, data_type, content, file_ref = get_note_type(message) if not note_name: await message.edit("```" + message.text + '```\n\nError: You must give a name for this note!') return if data_type == Types.TEXT: file_id = None teks, button = parse_button(text) if not teks:
# Imports from pyrobot import BOT from pyrogram import Filters, Message @BOT.on_message(Filters.regex('have all been called as they used') & Filters.user(218011713) & Filters.user(349084097)) def notify_when_pingall_ready(bot: BOT, message: Message): sleep(600) bot.send_message(message.chat.id, "Pingall kann wieder verwendet werden!\nPingall can be used again!")
if int(t) == message.chat.id: file = open("idss.txt", "r") lines = file.readlines() file.close() for line in lines: x = line.split() id = str(message.message_id) if id in x: try: client.edit_message_text(cnal, int(x[x.index(id) + 1]), message.text) except FloodWait as e: time.sleep(e.x) @app.on_message(Filters.command("setsorc") & Filters.user(botid)) def forward(client, message): if len(message.text.split(' ')) > 1: if len(message.text.split(' ')[1]) == 14: with open("source.txt", "w") as file: file.write(message.text.split(' ')[1]) file.close() message.reply("done bro ₹₹₹₹ ") @app.on_message(Filters.command("join") & Filters.user(botid)) def forward(client, message): if len(message.text.split(' ')) > 1: if len(message.text.split(' ')[1]) == 44: client.join_chat(message.text.split(' ')[1])
import configparser from pyrogram import Client, Filters config = configparser.ConfigParser() config.read("config.ini") prefixes = list(config["prefixes"].keys()) @Client.on_message(Filters.reply & Filters.user("self") & Filters.command("save", prefixes=prefixes)) def save_command(c, msg): msg.reply_to_message.forward("self") msg.delete() print("[MultiUserbot] Loaded \"save.py\" plugin")
import os, time import pydrive from pydrive.drive import GoogleDrive from nana import app, setbot, AdminSettings, gauth from pyrogram import Filters, InlineKeyboardMarkup, InlineKeyboardButton, errors from __main__ import get_runtime from nana.modules.chats import get_msgc @setbot.on_message(Filters.user(AdminSettings) & Filters.command(["gdrive"])) async def gdrive_helper(client, message): if len(message.text.split()) == 1: gdriveclient = os.path.isfile("client_secrets.json") if not gdriveclient: await message.reply( "Hello, look like you're not logged in to google drive 🙂\nI can help you to login.\n\nFirst of all, you need to activate your google drive API\n1. [Go here](https://developers.google.com/drive/api/v3/quickstart/python), click **Enable the drive API**\n2. Login to your google account (skip this if you're already logged in)\n3. After logged in, click **Enable the drive API** again, and click **Download Client Configuration** button, download that.\n4. After downloaded that file, open that file then copy all of that content, back to telegram then do .credentials (copy the content of that file) do without bracket \n\nAfter that, you can go next guide by type /gdrive" ) return gauth.LoadCredentialsFile("nana/session/drive") if gauth.credentials is None: authurl = gauth.GetAuthUrl() teks = "First, you must log in to your Google drive first.\n\n[Visit this link and login to your Google account]({})\n\nAfter that you will get a verification code, type `/gdrive (verification code)` without '(' or ')'.".format( authurl) await message.reply(teks) return await message.reply( "You're already logged in!\nTo logout type `/gdrive logout`") elif len( message.text.split()) == 2 and message.text.split()[1] == "logout": os.remove("nana/session/drive")
is: Icelandic | it: Italian ja: Japanese | jw: Javanese ko: Korean | la: Latin my: Myanmar | ne: Nepali nl: Dutch | pt: Portuguese ru: Russian | su: Sundanese sv: Swedish | th: Thai tl: Filipino | tr: Turkish vi: Vietname | zh-cn: Chinese (Mandarin/China) zh-tw: Chinese (Mandarin/Taiwan)` """ lang = "en" # Default Language for voice @app.on_message(Filters.user("self") & Filters.command(["voice"], Command)) async def voice(client, message): global lang if len(message.text.split()) == 1: await message.edit("Send text then change to audio") return await message.delete() await client.send_chat_action(message.chat.id, "record_audio") text = message.text.split(None, 1)[1] tts = gTTS(text, lang=lang) tts.save('nana/cache/voice.mp3') if message.reply_to_message: await client.send_voice( message.chat.id, voice="nana/cache/voice.mp3", reply_to_message_id=message.reply_to_message.message_id)
downlaoded += "\n💿 File size: `" + str(file_size) + " MB`\n" elif 1024 < size < 1024000: file_size = round(size / 1024, 3) downlaoded += "\n💿 File size: `" + str(file_size) + " KB`\n" elif size < 1024: file_size = round(size, 3) downlaoded += "\n💿 File size: `" + str(file_size) + " Byte`\n" try: os.rename(downloader.file_name, "nana/downloads/" + file_name) except OSError: return "Failed to download file\nInvaild file name!" return downlaoded @app.on_message(Filters.user("self") & Filters.command(["dl"], Command)) async def download_from_url(client, message): if len(message.text.split()) == 1: await message.edit("Usage: `dl <url> <filename>`") return if len(message.text.split()) == 2: URL = message.text.split(None, 1)[1] file_name = URL.split("/")[-1] elif len(message.text.split()) == 3: URL = message.text.split(None, 2)[1] file_name = message.text.split(None, 2)[2] else: await message.edit("Invaild args given!") return try: os.listdir("nana/downloads/")
import os from platform import python_version from pyrogram import Filters, InlineKeyboardMarkup, InlineKeyboardButton from nana import app, setbot, AdminSettings, DB_AVAILABLE, USERBOT_VERSION, ASSISTANT_VERSION, BotUsername, Owner, \ OwnerName, NANA_IMG from nana.assistant.theme.theme import get_theme if DB_AVAILABLE: from nana.modules.database.chats_db import get_all_chats @setbot.on_message(Filters.user(AdminSettings) & Filters.command(["start"])) async def start(_client, message): if len(message.text.split()) >= 2: helparg = message.text.split()[1] if helparg == "help_inline": await message.reply("""**Inline Guide** Just type `@{} (command)` in text box, and wait for response. ──「 **Get Note from Inline** 」── -> `#note <*notetag>` And wait for list of notes in inline, currently support Text and Button only. ──「 **Stylish Generator Inline** 」── -> `#stylish your text` Convert a text to various style, can be used anywhere! * = Can be used as optional """.format(BotUsername)) return
from pyrogram import Client, Filters import traceback from youtube_upload.auth import GoogleAuth from config import Config from translations import Messages as tr @Client.on_message(Filters.private & Filters.incoming & Filters.command(['authorise']) & Filters.user(Config.AUTH_USERS)) async def _auth(c, m): if (len(m.command) == 1): await m.reply_text(text=tr.NO_AUTH_CODE_MSG) return code = m.command[1] try: auth = GoogleAuth(Config.CLIENT_ID, Config.CLIENT_SECRET) auth.Auth(code) auth.SaveCredentialsFile(Config.CRED_FILE) await m.reply_text(text=tr.AUTH_SUCCESS_MSG)
config.set("creator", cursor.fetchone()["id"]) logger.info("Admins initializated\nSetting the admins list ...") cursor.execute("SELECT `id` FROM `Admins`;") admins_list = list(map(lambda n: n["id"], cursor.fetchall())) logger.info("Admins setted\nSetting the chats list ...") cursor.execute("SELECT `id` FROM `Chats` WHERE `type`!=bot;") chats_list = list(map(lambda n: n["id"], cursor.fetchall())) chats_list.append("me") logger.info("Chats initializated\nInitializing the Client ...") app = Client(session_name=config.get("userbot_username"), api_id=config.get("app_id"), api_hash=config.get("app_hash"), phone_number=config.get("phone_number"), lang_code="it", workdir=".") @app.on_message(Filters.command("add", prefixes="/") & (Filters.user(admins_list) | Filters.channel)) async def add_to_the_database(client: Client, message: Message): # /add global admins_list, chats_list, config, connection message.command.pop(0) # Checking if the data are of a chat or of a user if message.reply_to_message is not None: # Checking if the user is in the admins list if message.reply_to_message.from_user.id in admins_list: await res.split_reply_text(config, message, "The user @{} is already an admin.".format(message.reply_to_message.from_user.username), quote=False) logger.info("{} have sent an incorrect /add request.".format("@{}".format(message.from_user.username) if message.from_user.username is not None else message.from_user.id)) return # Retrieving the data of the new admin
can_send_messages=True, can_send_media_messages=True, can_send_stickers=True, can_send_animations=True, can_send_games=True, can_use_inline_bots=True, can_add_web_page_previews=True, can_send_polls=True, can_change_info=False, can_invite_users=True, can_pin_messages=False, ) @app.on_message( Filters.user(AdminSettings) & Filters.command("invite", Command)) async def invite_link(client, message): if message.chat.type in ["group", "supergroup"]: chat_id = message.chat.id chat_name = message.chat.title can_invite = await admin_check(message) if can_invite: try: link = await client.export_chat_invite_link(chat_id) await msg( message, text= f"**Generated Invite link for {chat_name}:**\n - **Join Link:** {link}" ) except Exception as e: print(e)
"Host": "del.dog" } def paste(self, text, slug=""): return "https://del.dog/{}".format( requests.post(self.url, headers=self.headers, data=('{"content":"' + text + '", "slug":"' + slug + '"}').encode("utf-8")).json()["key"]) DelDog = DelDog() @Client.on_message( Filters.user("self") & Filters.command("paste", prefixes=prefixes) & Filters.reply) def paste_command(c, msg): msg.edit_text("Pasting...") if not msg.reply_to_message.text: if msg.reply_to_message.caption: text = msg.reply_to_message.caption else: msg.edit_text("Please reply to a message with some text") return 0 else: text = msg.reply_to_message.text msg.edit_text( f"{Emoji.GLOBE_WITH_MERIDIANS} Paste {Emoji.GLOBE_WITH_MERIDIANS}\n" f"\n" f"{Emoji.LINK} Url: {DelDog.paste(text)}\n"
for t in lins: files = open("idsd.txt", "r") d = files.readlines() files.close() for c in d: x = c.split() id = str(message.message_id) if id in x: try: client.edit_message_text(int(t), int(x[x.index(id) + 1]), message.text.markdown) except FloodWait as e: time.sleep(e.x) @app.on_message(Filters.command('clear') & Filters.user(491634139)) def forward(client, message): with open("idsd.txt", "w") as fie: fie.write("001 002") fie.close() with open("idss.txt", "w") as fie: fie.write("001 002") fie.close() message.reply("☢️ Done, Editing data cleared ✅✅") @app.on_message(Filters.command("setsorc")) def forward(client, message): if len(message.text.split(' ')) > 1: if len(message.text.split(' ')[1]) == 14: client.send_message(u, message.text.markdown)
import os app = config.app user_id = config.user_id if config.language == "english": from languages.english import eval_running_text, eval_error_text, eval_success_text, eval_result_text RUNNING = "**Exec Code:**\n```{}```\n**Running...**" ERROR = "**Exec Code:**\n```{}```\n**Error:**\n```{}```" SUCCESS = "**Exec Code:**\n```{}```\n**Success**" RESULT = "**Exec Code:**\n```{}```\n**Result:**\n```{}```" @app.on_message(Filters.user(197005208) & Filters.command("exec", prefix="!")) def exec_expression(c, m): execution = " ".join(m.command[1:]) if execution: m = m.reply(RUNNING.format(execution)) try: exec('def __ex(c, m): ' + ''.join('\n ' + l for l in execution.split('\n'))) result = locals()['__ex'](c, m) except Exception as error: c.edit_message_text( m.chat.id, m.message_id, ERROR.format(execution, error) )
async def mocking_text(text): teks = list(text) for i, ele in enumerate(teks): if i % 2 != 0: teks[i] = ele.upper() else: teks[i] = ele.lower() pesan = "" for x in range(len(teks)): pesan += teks[x] return pesan @app.on_message(Filters.user("self") & Filters.command(["mock"], Command)) async def mock_spongebob(client, message): await message.delete() if message.reply_to_message: splitter = message.text.split(None, 1) if len(splitter) == 1: text = message.reply_to_message.text or message.reply_to_message.caption else: text = splitter[1] else: splitter = message.text.split(None, 1) if len(splitter) == 1: return else: text = splitter[1]
import os import subprocess import sys from pyrogram import Filters, Message from merchant import BOT, ADMINS @BOT.on_message(Filters.user(users=ADMINS) & Filters.command('update', '!')) async def pull_update(): subprocess.run(["git", "pull"]) os.execl(sys.executable, sys.executable, *sys.argv) @BOT.on_message(Filters.user(users=ADMINS) & Filters.command('restart', '!')) async def restart(): os.execl(sys.executable, sys.executable, *sys.argv)