def restart(update, context): restart_message = sendMessage("Restarting, Please wait!", context.bot, update) # Save restart message ID and chat ID in order to edit it after restarting with open(".restartmsg", "w") as f: f.truncate(0) f.write(f"{restart_message.chat.id}\n{restart_message.message_id}\n") fs_utils.clean_all() os.execl(executable, executable, "-m", "bot")
def list_drive(update, context): if update.message.text == f'/{BotCommands.ListCommand}': sendMessage( f'Send a search key along with {BotCommands.ListCommand} command', context.bot, update) else: search = update.message.text.split(' ', maxsplit=1)[1] LOGGER.info(f"Searching: '{search}'...") reply = sendMessage('Searching..... Please Wait!', context.bot, update) gdrive = GoogleDriveHelper(None) msg, button = gdrive.drive_list(search) if msg: if button: editMessage(msg, reply, button) else: editMessage(msg, reply) else: editMessage('No results found', reply)
def _watch(bot: Bot, update: Update, args: list, isTar=False): try: link = args[0] except IndexError: sendMessage( f'/{BotCommands.WatchCommand} [yt_dl supported link] to mirror with youtube_dl', bot, update) return reply_to = update.message.reply_to_message tag = reply_to.from_user.username if reply_to is not None else None listener = MirrorListener(bot, update, isTar, tag) ydl = YoutubeDLHelper(listener) threading.Thread(target=ydl.add_download, args=(link, f'{DOWNLOAD_DIR}{listener.uid}')).start() sendStatusMessage(update, bot) if len(Interval) == 0: Interval.append( setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages))
def authorize(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: user_id = int(message_[1]) if user_id in AUTHORIZED_CHATS: msg = 'User Already Authorized!' elif DB_URI is not None: msg = DbManger().user_auth(user_id) AUTHORIZED_CHATS.add(user_id) else: AUTHORIZED_CHATS.add(user_id) with open('authorized_chats.txt', 'a') as file: file.write(f'{user_id}\n') msg = 'User Authorized' elif reply_message is None: # Trying to authorize a chat chat_id = update.effective_chat.id if chat_id in AUTHORIZED_CHATS: msg = 'Chat Already Authorized!' elif DB_URI is not None: msg = DbManger().user_auth(chat_id) AUTHORIZED_CHATS.add(chat_id) else: AUTHORIZED_CHATS.add(chat_id) with open('authorized_chats.txt', 'a') as file: file.write(f'{chat_id}\n') msg = 'Chat Authorized' else: # Trying to authorize someone by replying user_id = reply_message.from_user.id if user_id in AUTHORIZED_CHATS: msg = 'User Already Authorized!' elif DB_URI is not None: msg = DbManger().user_auth(user_id) AUTHORIZED_CHATS.add(user_id) else: AUTHORIZED_CHATS.add(user_id) with open('authorized_chats.txt', 'a') as file: file.write(f'{user_id}\n') msg = 'User Authorized' sendMessage(msg, context.bot, update)
def list_drive(update, context): try: file_paths = [ os.path.join(DOWNLOAD_DIR, i) for i in os.listdir(DOWNLOAD_DIR) ] mes = ''.join([ f'<code>{os.path.split(i)[-1]}</code> {get_FileSize(i)} {get_FileModifyTime(i)}\n' for i in file_paths ]) except Exception as e: mes = None if mes: reply_message = sendMessage(mes, context.bot, update) else: reply_message = sendMessage('There is no file', context.bot, update) threading.Thread(target=auto_delete_message, args=(context.bot, update.message, reply_message)).start()
def countNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] msg = sendMessage(f"๐ Counting : <code>{link}</code>", context.bot, update) gd = GoogleDriveHelper() result = gd.count(link) deleteMessage(context.bot, msg) if update.message.from_user.username: uname = f'@{update.message.from_user.username}' else: uname = f'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>' if uname is not None: cc = f'\n\n๐ค ๐๐ผ๐๐ป๐๐ฒ๐ฟ : {uname}\n\n๐ฅ ๐ฃ๐ฟ๐ถ๐ถ๐ถ๐ถ๐๐ผ ๐ ๐ถ๐ฟ๐ฟ๐ผ๐ฟ ๐ญ๐ผ๐ป๐\n\n๐ฅ ๐๐ฟ๐ผ๐๐ฝ : @PriiiiyoMirror\n\nโซ๏ธ#Uploaded To Team Drive โ \n\n๐ซ ๐๐ผ ๐ก๐ผ๐ ๐ฆ๐ต๐ฎ๐ฟ๐ฒ ๐๐ป๐ฑ๐ฒ๐ ๐๐ถ๐ป๐ธ \n\nโ ๐ฃ๐ผ๐๐ฒ๐ฟ๐ฒ๐ฑ ๐๐ : @PriiiiyoBOTs' sendMessage(result + cc, context.bot, update) else: sendMessage("Provide G-Drive Shareable Link to Count.", context.bot, update)
def unauthorize(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: user_id = int(message_[1]) if user_id in AUTHORIZED_CHATS: if DB_URI is not None: msg = DbManger().db_unauth(user_id) else: AUTHORIZED_CHATS.remove(user_id) msg = 'โ User Unauthorized' else: msg = 'โ User Already Unauthorized' else: if reply_message is None: # Trying to unauthorize a chat chat_id = update.effective_chat.id if chat_id in AUTHORIZED_CHATS: if DB_URI is not None: msg = DbManger().db_unauth(chat_id) else: AUTHORIZED_CHATS.remove(chat_id) msg = 'โ Chat Unauthorized' else: msg = 'โ Chat Already Unauthorized' else: # Trying to authorize someone by replying user_id = reply_message.from_user.id if user_id in AUTHORIZED_CHATS: if DB_URI is not None: msg = DbManger().db_unauth(user_id) else: AUTHORIZED_CHATS.remove(user_id) msg = 'โ User Unauthorized' else: msg = 'โ User Already Unauthorized' with open('authorized_chats.txt', 'a') as file: file.truncate(0) for i in AUTHORIZED_CHATS: file.write(f'{i}\n') sendMessage(msg, context.bot, update)
def list_buttons(update, context): user_id = update.message.from_user.id if len(update.message.text.split(" ", maxsplit=1)) < 2: return sendMessage('Send a search key along with command', context.bot, update) buttons = button_build.ButtonMaker() buttons.sbutton("Drive Root", f"types {user_id} root") buttons.sbutton("Recursive", f"types {user_id} recu") buttons.sbutton("Cancel", f"types {user_id} cancel") button = InlineKeyboardMarkup(buttons.build_menu(2)) sendMarkup('Choose option to list.', context.bot, update, button)
def _watch(bot: Bot, update, isZip=False): mssg = update.message.text message_args = mssg.split(" ") name_args = mssg.split("|") try: link = message_args[1] except IndexError: msg = f"/{BotCommands.WatchCommand} [yt_dl supported link] [quality] |[CustomName] to mirror with youtube_dl.\n\n" msg += "<b>Note :- Quality and custom name are optional</b>\n\nExample of quality :- audio, 144, 240, 360, 480, 720, 1080, 2160." msg += "\n\nIf you want to use custom filename, plz enter it after |" msg += f"\n\nExample :-\n<code>/{BotCommands.WatchCommand} https://youtu.be/ocX2FN1nguA 720 |My video bro</code>\n\n" msg += "This file will be downloaded in 720p quality and it's name will be <b>My video bro</b>" sendMessage(msg, bot, update) return try: if "|" in mssg: mssg = mssg.split("|") qual = mssg[0].split(" ")[2] if qual == "": raise IndexError else: qual = message_args[2] if qual != "audio": qual = f"bestvideo[height<={qual}]+bestaudio/best[height<={qual}]" except IndexError: qual = "bestvideo+bestaudio/best" try: name = name_args[1] except IndexError: name = "" reply_to = update.message.reply_to_message tag = reply_to.from_user.username if reply_to is not None else None pswd = "" listener = MirrorListener(bot, update, pswd, isZip, tag) ydl = YoutubeDLHelper(listener) threading.Thread( target=ydl.add_download, args=(link, f"{DOWNLOAD_DIR}{listener.uid}", qual, name), ).start() sendStatusMessage(update, bot) if len(Interval) == 0: Interval.append( setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages))
def countNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] msg = sendMessage(f"Counting: <code>{link}</code>", context.bot, update) gd = GoogleDriveHelper() result = gd.count(link) deleteMessage(context.bot, msg) if update.message.from_user.username: uname = f'@{update.message.from_user.username}' else: uname = f'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>' if uname is not None: cc = f'\n\n<b>cc:</b> {uname}' sendMessage(result + cc, context.bot, update) else: sendMessage("Provide G-Drive Shareable Link to Count.", context.bot, update)
def list_drive(update, context): try: search = update.message.text.split(' ', maxsplit=1)[1] LOGGER.info(f"Searching: {search}") reply = sendMessage('Searching..... Please wait!', context.bot, update) gdrive = GoogleDriveHelper(None) msg, button = gdrive.drive_list(search) if button: editMessage(msg, reply, button) else: editMessage( 'รฐลธหยฌError!! Please Go To https://testing.bunny.workers.dev/0: To Searchรฐลธยคยช', reply, button) except IndexError: sendMessage( 'รฐลธหยฌError!! Please Go To https://testing.bunny.workers.dev/0: To Searchรฐลธยคยช', context.bot, update)
def _watch(bot: Bot, update, isTar=False): mssg = update.message.text message_args = mssg.split(' ') name_args = mssg.split('|') try: link = message_args[1] except IndexError: msg = f"/{BotCommands.WatchCommand} [yt_dl supported link] [quality] |[CustomName] to mirror with youtube_dl.\n\n" msg += "<b>Note :- Quality and custom name are optional</b>\n\nExample of quality :- audio, 144, 240, 360, 480, 720, 1080, 2160." msg += "\n\nIf you want to use custom filename, plz enter it after |" msg += f"\n\nExample :-\n<code>/{BotCommands.WatchCommand} https://youtu.be/Pk_TthHfLeE 720 |Slam</code>\n\n" msg += "This file will be downloaded in 720p quality and it's name will be <b>Slam</b>" sendMessage(msg, bot, update) return try: if "|" in mssg: mssg = mssg.split("|") qual = mssg[0].split(" ")[2] if qual == "": raise IndexError else: qual = message_args[2] if qual != "audio": qual = f'bestvideo[height<={qual}]+bestaudio/best[height<={qual}]' except IndexError: qual = "bestvideo+bestaudio/best" try: name = name_args[1] except IndexError: name = "" reply_to = update.message.reply_to_message if reply_to is not None: tag = reply_to.from_user.username else: tag = None pswd = "" listener = MirrorListener(bot, update, pswd, isTar, tag) ydl = YoutubeDLHelper(listener) threading.Thread(target=ydl.add_download,args=(link, f'{DOWNLOAD_DIR}{listener.uid}', qual, name)).start() sendMessage(f"<b>โ Your YTDL Link Has Been Added To Download Queue.\nโ Obey Rules On Pinned Message To Avoid Being Banned.\nโ Check Status To See Current Progress</b> /{BotCommands.StatusCommand}", bot, update) if len(Interval) == 0: Interval.append(setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages))
def list_drive(update, context): try: search = update.message.text.split(' ', maxsplit=1)[1] LOGGER.info(f"Searching: {search}") reply = sendMessage('<b>๐Sแดแดสแดสษชษดษข...Pสแดแดsแด Wแดษชแด!</b>', context.bot, update) gdrive = GoogleDriveHelper(None) msg, button = gdrive.drive_list(search) if button: editMessage(msg, reply, button) else: editMessage( '<b>โผNแด Rแดsแดสแดs Fแดแดษดแด Fแดส Yแดแดส Fษชสแด Nแดแดแด Kแดสแดกแดสแด :(</b>', reply, button) except IndexError: sendMessage( '<b>โผSแดษดแด แด Fษชสแด Nแดแดแด As Kแดสแดกแดสแด Tแด Sแดแดสแดส., Aสแดษดษข Wษชแดส</b> <b>/list</b> <b>Cแดแดแดแดษดแด </b>', context.bot, update)
def list_drive(update, context): try: search = update.message.text.split(' ', maxsplit=1)[1] if "'" in search: search = search.replace("'", "\\'") except IndexError: sendMessage( '<b>โฝBแดแด: โผSแดษดแด แด Fษชสแด Kแดสแดกแดสแด Tแด Sแดแดสแดส, Aสแดษดษข Wษชแดส /search Cแดแดแดแดษดแด </b>', context.bot, update) return reply = sendMessage('<b>๐Sแดแดสแดสษชษดษข...Pสแดแดsแด Wแดษชแด!</b>', context.bot, update) LOGGER.info(f"Searching: {search}") gdrive = GoogleDriveHelper(None) msg, button = gdrive.drive_list(search) editMessage(msg, reply, button)
def mirrorcf(update, context): bot = context.bot message_args = update.message.text.split(' ') try: link = message_args[1] except IndexError: link = '' LOGGER.info(link) link = link.strip() tag = None if not bot_utils.is_url(link) and not bot_utils.is_magnet(link): sendMessage('No download source provided', bot, update) return parsed_link = urlparse(link) headers = {"Content-Type": "application/json"} data = { "cmd": "request.get", "url": f"{parsed_link.scheme}://{parsed_link.netloc}", "maxTimeout": 60000 } r = requests.post('http://localhost:8191/v1', headers=headers, json=data) solution = r.json()['solution'] cf_clearance = solution['cookies'][0] cookie_string = f"{cf_clearance['name']}={cf_clearance['value']};" aria_options = { "header": f"Cookie:{cookie_string}", "user-agent": solution['userAgent'] } listener = MirrorListener(bot, update, False, tag) ariaDlManager.add_download(f'{DOWNLOAD_DIR}/{listener.uid}/', [link], listener, aria_options) sendStatusMessage(update, bot) if len(Interval) == 0: Interval.append( bot_utils.setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages))
def cancel_mirror(update, context): args = update.message.text.split(" ", maxsplit=1) mirror_message = None if len(args) > 1: gid = args[1] dl = getDownloadByGid(gid) if not dl: sendMessage(f"GID: <code>{gid}</code> not found.", context.bot, update) return with download_dict_lock: keys = list(download_dict.keys()) mirror_message = dl.message elif update.message.reply_to_message: mirror_message = update.message.reply_to_message with download_dict_lock: keys = list(download_dict.keys()) dl = download_dict[mirror_message.message_id] if len(args) == 1: if mirror_message is None or mirror_message.message_id not in keys: if BotCommands.MirrorCommand in mirror_message.text or \ BotCommands.TarMirrorCommand in mirror_message.text: msg = "Mirror already have been cancelled" sendMessage(msg, context.bot, update) return else: msg = "Please reply to the /mirror message which was used to start the download or /cancel gid to cancel it!" sendMessage(msg, context.bot, update) return if dl.status() == "Uploading": sendMessage("Upload in Progress, Don't Cancel it.", context.bot, update) return elif dl.status() == "Archiving": sendMessage("Archival in Progress, Don't Cancel it.", context.bot, update) return else: dl.download().cancel_download() sleep(1) # Wait a Second For Aria2 To free Resources. clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}/')
def add_gd_download(link, listener, is_gdtot): res, size, name, files = GoogleDriveHelper().helper(link) if res != "": return sendMessage(res, listener.bot, listener.update) if STOP_DUPLICATE and not listener.isLeech: LOGGER.info('Checking File/Folder if already in Drive...') if listener.isZip: gname = name + ".zip" elif listener.extract: try: gname = get_base_name(name) except: gname = None if gname is not None: gmsg, button = GoogleDriveHelper().drive_list(gname, True) if gmsg: msg = "File/Folder is already available in Drive.\nHere are the search results:" return sendMarkup(msg, listener.bot, listener.update, button) if STORAGE_THRESHOLD is not None: acpt = check_storage_threshold(size, True) if not acpt: msg = f'You must leave {STORAGE_THRESHOLD}GB free storage.' msg += f'\nYour File/Folder size is {get_readable_file_size(size)}' return sendMessage(msg, listener.bot, listener.update) if ZIP_UNZIP_LIMIT is not None: LOGGER.info('Checking File/Folder Size...') if size > ZIP_UNZIP_LIMIT * 1024**3: msg = f'Zip/Unzip limit is {ZIP_UNZIP_LIMIT}GB.\nYour File/Folder size is {get_readable_file_size(size)}.' return sendMessage(msg, listener.bot, listener.update) LOGGER.info(f"Download Name: {name}") drive = GoogleDriveHelper(name, listener) gid = ''.join(random.SystemRandom().choices(string.ascii_letters + string.digits, k=12)) download_status = GdDownloadStatus(drive, size, listener, gid) with download_dict_lock: download_dict[listener.uid] = download_status sendStatusMessage(listener.update, listener.bot) drive.download(link) if is_gdtot: drive.deletefile(link)
def _watch(bot: Bot, update, isTar=False): mssg = update.message.text message_args = mssg.split(' ') name_args = mssg.split('|') try: link = message_args[1] except IndexError: msg = f"/{BotCommands.WatchCommand} [youtube-dl supported link] [quality] |[CustomName] to mirror with youtube-dl.\n\n" msg += "<b>Note: Quality and custom name are optional</b>\n\nExample of quality: audio, 144, 240, 360, 480, 720, 1080, 2160." msg += "\n\nIf you want to use custom filename, enter it after |" msg += f"\n\nExample:\n<code>/{BotCommands.WatchCommand} https://youtu.be/Pk_TthHfLeE 720 |Slam</code>\n\n" msg += "This file will be downloaded in 720p quality and it's name will be <b>Slam</b>" sendMessage(msg, bot, update) return try: if "|" in mssg: mssg = mssg.split("|") qual = mssg[0].split(" ")[2] if qual == "": raise IndexError else: qual = message_args[2] if qual != "audio": qual = f'bestvideo[height<={qual}]+bestaudio/best[height<={qual}]' except IndexError: qual = "bestvideo+bestaudio/best" try: name = name_args[1] except IndexError: name = "" pswd = "" listener = MirrorListener(bot, update, pswd, isTar) ydl = YoutubeDLHelper(listener) threading.Thread(target=ydl.add_download, args=(link, f'{DOWNLOAD_DIR}{listener.uid}', qual, name)).start() sendStatusMessage(update, bot)
def removeSudo(update,context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: chat_id = int(message_[1]) if chat_id in SUDO_USERS: msg = DbManger().db_rmsudo(chat_id) else: msg = 'Not a Sudo' else: if reply_message is None: msg = "Give ID or Reply To message of whom you want to remove from Sudo" else: user_id = reply_message.from_user.id if user_id in SUDO_USERS: msg = DbManger().db_rmsudo(user_id) else: msg = 'Not a Sudo' sendMessage(msg, context.bot, update)
def addSudo(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: chat_id = int(message_[1]) if chat_id not in SUDO_USERS: msg = DbManger().db_addsudo(chat_id) else: msg = 'Already Sudo' elif reply_message is None: msg = "Give ID or Reply To message of whom you want to Promote" else: # Trying to authorize someone in specific user_id = reply_message.from_user.id if user_id not in SUDO_USERS: msg = DbManger().db_addsudo(user_id) else: msg = 'Already Sudo' sendMessage(msg, context.bot, update)
def removeSudo(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: chat_id = int(message_[1]) if chat_id in SUDO_USERS: msg = DbManger().db_rmsudo(chat_id) else: msg = 'Not a Sudo' else: if reply_message is None: msg = "๐ถ๐๐๐ ๐ธ๐ณ ๐๐ ๐๐๐๐๐ข ๐๐ ๐๐๐๐๐๐๐ ๐๐ ๐ ๐๐๐ ๐ข๐๐ ๐ ๐๐๐ ๐๐ ๐๐๐๐๐๐ ๐๐๐๐ ๐๐๐๐" else: user_id = reply_message.from_user.id if user_id in SUDO_USERS: msg = DbManger().db_rmsudo(user_id) else: msg = '๐ฝ๐๐ ๐ ๐๐๐๐' sendMessage(msg, context.bot, update)
def removeSudo(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: chat_id = int(message_[1]) if chat_id in SUDO_USERS: msg = DbManger().db_rmsudo(chat_id) else: msg = '<b>Nแดแด แด Sแดแด แด!</b>' else: if reply_message is None: msg = "<b>Gษชแด แด ID O๊ฐ Usแดส Oส Rแดแดสส Tแด Mแดssแดษขแด O๊ฐ Usแดส Wสแดแด Yแดแด Wแดษดแด Tแด Rแดแดแดแด แด Fสแดแด Sแดแด แด</b>" else: user_id = reply_message.from_user.id if user_id in SUDO_USERS: msg = DbManger().db_rmsudo(user_id) else: msg = '<b>Nแดแด แด Sแดแด แด!</b>' sendMessage(msg, context.bot, update)
def setThumb(update, context): user_id = update.message.from_user.id reply_to = update.message.reply_to_message if reply_to is not None and reply_to.photo: path = "Thumbnails/" if not ospath.isdir(path): mkdir(path) photo_msg = app.get_messages( update.message.chat.id, reply_to_message_ids=update.message.message_id) photo_dir = app.download_media(photo_msg, file_name=path) des_dir = ospath.join(path, str(user_id) + ".jpg") Image.open(photo_dir).convert("RGB").save(des_dir, "JPEG") osremove(photo_dir) if DB_URI is not None: DbManger().user_save_thumb(user_id, des_dir) msg = f"Custom thumbnail saved for <a href='tg://user?id={user_id}'>{update.message.from_user.full_name}</a>." sendMessage(msg, context.bot, update) else: sendMessage("Reply to a photo to save custom thumbnail.", context.bot, update)
def stats(update, context): currentTime = get_readable_time(time.time() - botStartTime) total, used, free = shutil.disk_usage(".") total = get_readable_file_size(total) used = get_readable_file_size(used) free = get_readable_file_size(free) sent = get_readable_file_size(psutil.net_io_counters().bytes_sent) recv = get_readable_file_size(psutil.net_io_counters().bytes_recv) cpuUsage = psutil.cpu_percent(interval=0.5) memory = psutil.virtual_memory().percent disk = psutil.disk_usage("/").percent stats = (f"<b>Bot Uptime:</b> {currentTime}\n" f"<b>Total disk space:</b> {total}\n" f"<b>Used:</b> {used} " f"<b>Free:</b> {free}\n\n" f"Data Usage\n<b>Upload:</b> {sent}\n" f"<b>Down:</b> {recv}\n\n" f"<b>CPU:</b> {cpuUsage}% " f"<b>RAM:</b> {memory}% " f"<b>Disk:</b> {disk}%") sendMessage(stats, context.bot, update)
def torser(update, context): user_id = update.message.from_user.id try: key = update.message.text.split(" ", maxsplit=1)[1] except IndexError: return sendMessage("Send a search key along with command", context.bot, update) if SEARCH_API_LINK is not None and SEARCH_PLUGINS is not None: buttons = button_build.ButtonMaker() buttons.sbutton('Api', f"torser {user_id} api") buttons.sbutton('Plugins', f"torser {user_id} plugin") buttons.sbutton("Cancel", f"torser {user_id} cancel") button = InlineKeyboardMarkup(buttons.build_menu(2)) sendMarkup('Choose tool to search:', context.bot, update, button) elif SEARCH_API_LINK is not None and SEARCH_PLUGINS is None: button = _api_buttons(user_id) sendMarkup('Choose site to search:', context.bot, update, button) elif SEARCH_API_LINK is None and SEARCH_PLUGINS is not None: button = _plugin_buttons(user_id) sendMarkup('Choose site to search:', context.bot, update, button) else: return sendMessage("No API link or search PLUGINS added for this function", context.bot, update)
def addSudo(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: user_id = int(message_[1]) if user_id not in SUDO_USERS: if DB_URI is not None: msg = DbManger().db_addsudo(user_id) else: with open('authorized_chats.txt', 'a') as file: file.write(f'{user_id}\n') AUTHORIZED_CHATS.add(user_id) with open('sudo_users.txt', 'a') as file: file.write(f'{user_id}\n') SUDO_USERS.add(user_id) msg = 'Promoted as Sudo' else: msg = 'Already Sudo' else: if reply_message is None: msg = "Give ID or Reply To message of whom you want to Promote" else: # Trying to authorize someone by replying user_id = reply_message.from_user.id if user_id not in SUDO_USERS: if DB_URI is not None: msg = DbManger().db_addsudo(user_id) else: with open('authorized_chats.txt', 'a') as file: file.write(f'{user_id}\n') AUTHORIZED_CHATS.add(user_id) with open('sudo_users.txt', 'a') as file: file.write(f'{user_id}\n') SUDO_USERS.add(user_id) msg = 'Promoted as Sudo' else: msg = 'Already Sudo' sendMessage(msg, context.bot, update)
def removeSudo(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: user_id = int(message_[1]) if user_id in SUDO_USERS: if DB_URI is not None: msg = DbManger().db_rmsudo(user_id) else: AUTHORIZED_CHATS.remove(user_id) SUDO_USERS.remove(user_id) msg = 'Demoted' else: msg = 'Not a Sudo' else: if reply_message is None: msg = "Give ID or Reply To message of whom you want to remove from Sudo" else: user_id = reply_message.from_user.id if user_id in SUDO_USERS: if DB_URI is not None: msg = DbManger().db_rmsudo(user_id) else: AUTHORIZED_CHATS.remove(user_id) SUDO_USERS.remove(user_id) msg = 'Demoted' else: msg = 'Not a Sudo' if DB_URI is None: with open('authorized_chats.txt', 'a') as file: file.truncate(0) for i in AUTHORIZED_CHATS: file.write(f'{i}\n') with open('sudo_users.txt', 'a') as file: file.truncate(0) for i in SUDO_USERS: file.write(f'{i}\n') sendMessage(msg, context.bot, update)
def addSudo(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: chat_id = int(message_[1]) if chat_id not in SUDO_USERS: msg = DbManger().db_addsudo(chat_id) else: msg = '<b>Aสสแดแดแด ส Sแดแด แด!</b>' else: if reply_message is None: msg = "<b>Gษชแด แด ID O๊ฐ Usแดส Oส Rแดแดสส Tแด Mแดssแดษขแด O๊ฐ Usแดส Wสแดแด Yแดแด Wแดษดแด Tแด Pสแดแดแดแดแด</b>" else: # Trying to authorize someone in specific user_id = reply_message.from_user.id if user_id not in SUDO_USERS: msg = DbManger().db_addsudo(user_id) else: msg = '<b>Aสสแดแดแด ส Sแดแด แด!</b>' sendMessage(msg, context.bot, update)
def addSudo(update, context): reply_message = None message_ = None reply_message = update.message.reply_to_message message_ = update.message.text.split(' ') if len(message_) == 2: chat_id = int(message_[1]) if chat_id not in SUDO_USERS: msg = DbManger().db_addsudo(chat_id) else: msg = '๐ฐ๐๐๐๐๐๐ข ๐๐๐๐' else: if reply_message is None: msg = "๐ถ๐๐๐ ๐ธ๐ณ ๐๐ ๐๐๐๐๐ข ๐๐ ๐๐๐๐๐๐๐ ๐๐ ๐ ๐๐๐ ๐ข๐๐ ๐ ๐๐๐ ๐๐ ๐ฟ๐๐๐๐๐๐" else: # Trying to authorize someone in specific user_id = reply_message.from_user.id if user_id not in SUDO_USERS: msg = DbManger().db_addsudo(user_id) else: msg = '๐ฐ๐๐๐๐๐๐ข ๐๐๐๐' sendMessage(msg, context.bot, update)
def unauthorize(bot, update): reply_message = update.message.reply_to_message if reply_message is None: # Trying to unauthorize a chat chat_id = update.effective_chat.id if chat_id in AUTHORIZED_CHATS: AUTHORIZED_CHATS.remove(chat_id) msg = 'Chat unauthorized' else: msg = 'Already unauthorized chat' else: # Trying to authorize someone in specific user_id = reply_message.from_user.id if user_id in AUTHORIZED_CHATS: AUTHORIZED_CHATS.remove(user_id) msg = 'Person unauthorized to use the bot!' else: msg = 'Person already unauthorized!' with open('authorized_chats.txt', 'a') as file: file.truncate(0) for i in AUTHORIZED_CHATS: file.write(f'{i}\n') sendMessage(msg, bot, update)