from bot.helper.telegram_helper.message_utils import sendMessage, sendMarkup, editMessage from bot.helper.telegram_helper.filters import CustomFilters from bot.helper.telegram_helper.bot_commands import BotCommands @run_async 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('π« No Result Found π«', reply, button) except IndexError: sendMessage('π Submit the search keywords along with the command π', context.bot, update) list_handler = CommandHandler(BotCommands.ListCommand, list_drive, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) dispatcher.add_handler(list_handler)
from bot.helper.mirror_utils.upload_utils import gdriveTools from bot.helper.ext_utils.bot_utils import is_gdrive_link def deletefile(update, context): args = update.message.text.split(" ", maxsplit=1) reply_to = update.message.reply_to_message if len(args) > 1: link = args[1] elif reply_to is not None: link = reply_to.text else: link = '' if is_gdrive_link(link): LOGGER.info(link) drive = gdriveTools.GoogleDriveHelper() msg = drive.deletefile(link) else: msg = 'Send Gdrive link along with command or by replying to the link by command' reply_message = sendMessage(msg, context.bot, update) Thread(target=auto_delete_message, args=(context.bot, update.message, reply_message)).start() delete_handler = CommandHandler(command=BotCommands.DeleteCommand, callback=deletefile, filters=CustomFilters.owner_filter | CustomFilters.sudo_user, run_async=True) dispatcher.add_handler(delete_handler)
__help__ = """ β’ `/flood`*:* Get the current flood control setting *Admins only:* β’ `/setflood <int/'no'/'off'>`*:* enables or disables flood control *Example:* `/setflood 10` This will mute users if they send more than 10 messages in a row, bots are ignored. """ FLOOD_BAN_HANDLER = MessageHandler( Filters.all & ~Filters.status_update & Filters.group, check_flood) FLOOD_QUERY_HANDLER = CallbackQueryHandler(flood_button, pattern=r"unmute_flooder") SET_FLOOD_HANDLER = CommandHandler("setflood", set_flood, pass_args=True, filters=Filters.group) FLOOD_HANDLER = CommandHandler("flood", flood, filters=Filters.group) dispatcher.add_handler(FLOOD_BAN_HANDLER, FLOOD_GROUP) dispatcher.add_handler(FLOOD_QUERY_HANDLER) dispatcher.add_handler(SET_FLOOD_HANDLER) dispatcher.add_handler(FLOOD_HANDLER) __mod_name__ = "AntiFlood" __handlers__ = [(FLOOD_BAN_HANDLER, FLOOD_GROUP), SET_FLOOD_HANDLER, FLOOD_HANDLER] dispatcher.add_handler(FLOOD_HANDLER)
f"?function=CURRENCY_EXCHANGE_RATE" f"&from_currency={orig_cur}" f"&to_currency={new_cur}" f"&apikey={CASH_API_KEY}") response = requests.get(request_url).json() try: current_rate = float(response['Realtime Currency Exchange Rate']['5. Exchange Rate']) except KeyError: update.effective_message.reply_text(f"Currency Not Supported.") return new_cur_amount = round(orig_cur_amount * current_rate, 5) update.effective_message.reply_text(f"{orig_cur_amount} {orig_cur} = {new_cur_amount} {new_cur}") else: update.effective_message.reply_text(__help__) __help__ = """ β’ `/cash`*:* currency converter *Example syntax:* `/cash 1 USD INR` *Outout:* `1.0 USD = 75.505 INR` """ CONVERTER_HANDLER = CommandHandler('cash', convert) dispatcher.add_handler(CONVERTER_HANDLER) __mod_name__ = "Currency Converter" __command_list__ = ["cash"] __handlers__ = [CONVERTER_HANDLER]
def main(): LOGGER.info("Bot Started!") clone_handler = CommandHandler('copy', cloneNode) start_handler = CommandHandler('start', start) help_handler = CommandHandler('hellp', helper) log_handler = CommandHandler('logs', sendLogs) sas_handler = CommandHandler('config', dl_sas) helpp_handler = CommandHandler('help', helpp) dispatcher.add_handler(helpp_handler) dispatcher.add_handler(sas_handler) dispatcher.add_handler(log_handler) dispatcher.add_handler(start_handler) dispatcher.add_handler(clone_handler) dispatcher.add_handler(help_handler) updater.start_polling()
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if os.path.isfile(".restartmsg"): with open(".restartmsg") as f: chat_id, msg_id = map(int, f) bot.edit_message_text("Restarted successfully!", chat_id, msg_id) os.remove(".restartmsg") start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter, run_async=True) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter, run_async=True) dispatcher.add_handler(start_handler) dispatcher.add_handler(ping_handler) dispatcher.add_handler(restart_handler) dispatcher.add_handler(help_handler) dispatcher.add_handler(stats_handler) dispatcher.add_handler(log_handler) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
result = cas.banchecker(user.id) text += str(result) for mod in USER_INFO: if mod.__mod_name__ == "Users": continue try: mod_info = mod.__user_info__(user.id) except TypeError: mod_info = mod.__user_info__(user.id, chat.id) if mod_info: text += "\n" + mod_info try: profile = bot.get_user_profile_photos(user.id).photos[0][-1] bot.sendChatAction(chat.id, "upload_photo") bot.send_photo(chat.id, photo=profile, caption=(text), parse_mode=ParseMode.HTML, disable_web_page_preview=True) except IndexError: update.effective_message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True) INFO_HANDLER = DisableAbleCommandHandler(["info", "whois"], info, pass_args=True) dispatcher.add_handler(INFO_HANDLER)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("Restarted Successfully!") LOGGER.info('Restarted Successfully!') remove('restart.pickle') start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter) owner_handler = CommandHandler(BotCommands.OwnerCommand, owner, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) authlist_handler = CommandHandler(BotCommands.AuthListCommand, chat_list, filters=CustomFilters.owner_filter) dispatcher.add_handler(start_handler) dispatcher.add_handler(ping_handler) dispatcher.add_handler(restart_handler) dispatcher.add_handler(help_handler) dispatcher.add_handler(stats_handler) dispatcher.add_handler(log_handler) dispatcher.add_handler(owner_handler) dispatcher.add_handler(authlist_handler) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
except IndexError: update.effective_message.reply_text( "Reply to messages or write messages from other languages ββfor translating into the intended language\n\n" "Example: `/tr en ml` to translate from English to Malayalam\n" "Or use: `/tr ml` for automatic detection and translating it into Malayalam.\n" "See [List of Language Codes](t.me/OnePunchSupport/12823) for a list of language codes.", parse_mode="markdown", disable_web_page_preview=True) except ValueError: update.effective_message.reply_text( "The intended language is not found!") else: return __help__ = """ -> `/tr` (language code) Translates Languages to a desired Language code. """ TRANSLATE_HANDLER = CommandHandler(BotCommands.TotranslateCommand, totranslate, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) dispatcher.add_handler(TRANSLATE_HANDLER) __mod_name__ = "Translate" __command_list__ = ["tr"] __handlers__ = [TRANSLATE_HANDLER]
query.message.edit_text("Closed.\nTo open again, type /connect") else: connect_chat(bot, update, []) __help__ = """ β’ /connect: connect a chat (Can be done in a group by /connect or /connect <chat id> in PM) β’ /connection: list connected chats β’ /disconnect: disconnect from a chat β’ /helpconnect: list available commands that can be done remotely *Admin only:* β’ /allowconnect <yes/no>: allow a user to connect to a chat """ CONNECT_CHAT_HANDLER = CommandHandler("connect", connect_chat, pass_args=True) CONNECTION_CHAT_HANDLER = CommandHandler("connection", connection_chat) DISCONNECT_CHAT_HANDLER = CommandHandler("disconnect", disconnect_chat) ALLOW_CONNECTIONS_HANDLER = CommandHandler("allowconnect", allow_connections, pass_args=True) HELP_CONNECT_CHAT_HANDLER = CommandHandler("helpconnect", help_connect_chat) CONNECT_BTN_HANDLER = CallbackQueryHandler(connect_button, pattern=r"connect") dispatcher.add_handler(CONNECT_CHAT_HANDLER) dispatcher.add_handler(CONNECTION_CHAT_HANDLER) dispatcher.add_handler(DISCONNECT_CHAT_HANDLER) dispatcher.add_handler(ALLOW_CONNECTIONS_HANDLER) dispatcher.add_handler(HELP_CONNECT_CHAT_HANDLER) dispatcher.add_handler(CONNECT_BTN_HANDLER) __mod_name__ = "Connectionπ§©" __handlers__ = [CONNECT_CHAT_HANDLER, CONNECTION_CHAT_HANDLER, DISCONNECT_CHAT_HANDLER, ALLOW_CONNECTIONS_HANDLER, HELP_CONNECT_CHAT_HANDLER, CONNECT_BTN_HANDLER]
torrent_handlers = [ TorrentSearch(command, value['source'], value['result_str']) for command, value in torrents_dict.items() ] def searchhelp(update, context): help_string = ''' <b>Torrent Search</b> β’ /nyaasi <i>[search query]</i> β’ /sukebei <i>[search query]</i> β’ /1337x <i>[search query]</i> β’ /piratebay <i>[search query]</i> β’ /tgx <i>[search query]</i> β’ /yts <i>[search query]</i> β’ /eztv <i>[search query]</i> β’ /torlock <i>[search query]</i> β’ /rarbg <i>[search query]</i> β’ /ts <i>[search query]</i> ''' sendMessage(help_string, context.bot, update) SEARCHHELP_HANDLER = CommandHandler( BotCommands.TsHelpCommand, searchhelp, filters=(CustomFilters.authorized_chat | CustomFilters.authorized_user) & CustomFilters.mirror_owner_filter, run_async=True) dispatcher.add_handler(SEARCHHELP_HANDLER)
def main(): fs_utils.start_cleanup() # Check if the bot is restarting if path.exists('restart.pickle'): with open('restart.pickle', 'rb') as status: restart_message = pickle.load(status) restart_message.edit_text("ππππππππππ ππππππππππππ’.βοΈ") LOGGER.info('Restarted Successfully!') remove('restart.pickle') bot.set_my_commands(botcmds) start_handler = CommandHandler(BotCommands.StartCommand, start, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter | CustomFilters.sudo_user) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter | CustomFilters.sudo_user) repo_handler = CommandHandler(BotCommands.RepoCommand, repo, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) dispatcher.add_handler(start_handler) dispatcher.add_handler(ping_handler) dispatcher.add_handler(restart_handler) dispatcher.add_handler(help_handler) dispatcher.add_handler(stats_handler) dispatcher.add_handler(log_handler) dispatcher.add_handler(repo_handler) updater.start_polling() LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
apps.get("quota_used") * 100 / quota) break else: AppQuotaUsed = 0 AppPercent = 0 AppHours = math.floor(AppQuotaUsed / 60) AppMinutes = math.floor(AppQuotaUsed % 60) sendMessage( f"<b>Dyno Usage for</b> <code>{app.name}</code>:\n" f"β’ <code>{AppHours}</code> <b>Hours and</b> <code>{AppMinutes}</code> <b>Minutes - {AppPercent}%</b>\n\n" "<b>Dyno Remaining this month:</b>\n" f"β’ <code>{hours}</code> <b>Hours and</b> <code>{minutes}</code> <b>Minutes - {quota_percent}%</b>\n\n" "<b>Estimated Dyno Expired:</b>\n" f"β’ <code>{day}</code> <b>Days</b>", context.bot, update, ) return True dyno_usage_handler = CommandHandler( command=BotCommands.UsageCommand, callback=dyno_usage, filters=CustomFilters.owner_filter | CustomFilters.sudo_user, run_async=True, ) dispatcher.add_handler(dyno_usage_handler)
from beholder import start_handler, validate_handler from bot import dispatcher, updater dispatcher.add_handler(start_handler) dispatcher.add_handler(validate_handler) updater.start_polling()
from bot.helper.telegram_helper.filters import CustomFilters from bot.helper.telegram_helper.bot_commands import BotCommands from bot.helper.ext_utils.bot_utils import new_thread from bot import dispatcher @new_thread def cloneNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] msg = sendMessage(f"<b>Cloning :</b> <code>{link}</code>", context.bot, update) gd = GoogleDriveHelper() result, button = gd.clone(link) deleteMessage(context.bot, msg) if button == "": sendMessage(result, context.bot, update) else: sendMarkup(result, context.bot, update, button) else: sendMessage("Provide G-Drive Shareable Link to Clone.", context.bot, update) clone_handler = CommandHandler(BotCommands.CloneCommand, cloneNode, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user) dispatcher.add_handler(clone_handler)
def mirror(update, context): _mirror(context.bot, update) def tar_mirror(update, context): _mirror(context.bot, update, True) def unzip_mirror(update, context): _mirror(context.bot, update, extract=True) mirror_handler = CommandHandler(BotCommands.MirrorCommand, mirror, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) tar_mirror_handler = CommandHandler(BotCommands.TarMirrorCommand, tar_mirror, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) unzip_mirror_handler = CommandHandler(BotCommands.UnzipMirrorCommand, unzip_mirror, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) dispatcher.add_handler(mirror_handler) dispatcher.add_handler(tar_mirror_handler) dispatcher.add_handler(unzip_mirror_handler)
def main(): fs_utils.start_cleanup() if IS_VPS: asyncio.get_event_loop().run_until_complete(start_server_async(SERVER_PORT)) # Check if the bot is restarting if os.path.isfile(".restartmsg"): with open(".restartmsg") as f: chat_id, msg_id = map(int, f) bot.edit_message_text("Restarted successfully!", chat_id, msg_id) os.remove(".restartmsg") bot.set_my_commands(botcmds) start_handler = CommandHandler(BotCommands.StartCommand, start, run_async=True) ping_handler = CommandHandler(BotCommands.PingCommand, ping, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) restart_handler = CommandHandler(BotCommands.RestartCommand, restart, filters=CustomFilters.owner_filter | CustomFilters.sudo_user, run_async=True) help_handler = CommandHandler(BotCommands.HelpCommand, bot_help, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) stats_handler = CommandHandler(BotCommands.StatsCommand, stats, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user, run_async=True) log_handler = CommandHandler(BotCommands.LogCommand, log, filters=CustomFilters.owner_filter | CustomFilters.sudo_user, run_async=True) dispatcher.add_handler(start_handler) dispatcher.add_handler(ping_handler) dispatcher.add_handler(restart_handler) dispatcher.add_handler(help_handler) dispatcher.add_handler(stats_handler) dispatcher.add_handler(log_handler) updater.start_polling(drop_pending_updates=IGNORE_PENDING_REQUESTS) LOGGER.info("Bot Started!") signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
# encoding: utf-8 import bot from bot import CommandHandler, updater, dispatcher, start start_handler = CommandHandler('start', start) dispatcher.add_handler(start_handler) updater.start_polling()
] image = json.get("bannerImage", False) msg += f"_{json.get('description', None)}_" if image: try: update.effective_message.reply_photo(photo = image, caption = msg, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) except: msg += f" [γ½οΈ]({image})" update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) else: update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) @run_async def weebhelp(update, context): help_string = ''' β’ `/al` : Search Anime β’ `/chr` : Search Anime Character β’ `/mng` : Search Manga ''' update.effective_message.reply_photo("https://telegra.ph/file/2326855aa5ba1d2520e47.jpg", help_string, parse_mode=ParseMode.MARKDOWN) ANIME_HANDLER = CommandHandler("al", anime) CHARACTER_HANDLER = CommandHandler("chr", character) MANGA_HANDLER = CommandHandler("mng", manga) WEEBHELP_HANDLER = CommandHandler("weebhelp", weebhelp) dispatcher.add_handler(ANIME_HANDLER) dispatcher.add_handler(CHARACTER_HANDLER) dispatcher.add_handler(MANGA_HANDLER) dispatcher.add_handler(WEEBHELP_HANDLER)