def about(query: str, update: Update, context: CallbackContext) -> None: """Handle the inline query.""" query = update.inline_query.query user_id = update.effective_user.id user = context.bot.get_chat(user_id) sql.update_user(user.id, user.username) about_text = f'\x1f Kei (@{context.bot.username})\x1f Maintained by [ZERO](t.me/Anomaliii)\x1f Built with ❤️ using python-telegram-bot v{__version__}\x1f Running on Python {python_version()}\x1f ' results: list = [] kb = InlineKeyboardMarkup([ [ InlineKeyboardButton(text="Support", url='https://t.me/zerounions'), InlineKeyboardButton(text="Channel", url='https://t.me/KeiUpdates'), ], [ InlineKeyboardButton( text="GitHub", url="https://www.github.com/Ryomen-Sukuna/Kei", ), ], ]) results.append( InlineQueryResultArticle(id=str(uuid4()), title=f"About Kei (@{context.bot.username})", input_message_content=InputTextMessageContent( about_text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True), reply_markup=kb)) update.inline_query.answer(results)
def log_user(bot, update): sql.update_user(update.effective_message.from_user.id, update.effective_message.from_user.username, update.effective_chat.id, update.effective_chat.title) if update.effective_message.forward_from: sql.update_user(update.effective_message.forward_from.id, update.effective_message.forward_from.username)
def post(): '''Update a user inside the db. Use at your own risk!''' key = request.args.get('api_key') if not key: abort(HTTPStatus.UNAUTHORIZED, "Unauthorized") return user_id = sql.verify_key(key) if user_id is None: abort(HTTPStatus.UNAUTHORIZED, "Invalid Key") isowner = user_id is OWNER_ID iscowoner = user_id is CO_OWNER_ID isudo = user_id in SUDO_USERS isadmin = isowner or iscowoner or isudo if not isadmin: abort(HTTPStatus.FORBIDDEN, "User is not bot admin.") else: data = request.get_json() try: tochange = int(data["user_id"]) except KeyError: abort(HTTPStatus.BAD_REQUEST, "Bad Request") try: chat_id = str(data["chat_id"]) except KeyError: chat_id = None pass try: username = str(data["username"]) except KeyError: username = None pass update_user(tochange, username, chat_id)
def about(query: str, update: Update, context: CallbackContext) -> None: """Handle the inline query.""" query = update.inline_query.query user_id = update.effective_user.id user = context.bot.get_chat(user_id) sql.update_user(user.id, user.username) about_text = f""" Yuii (@{context.bot.username}) Maintained by [Rshero](t.me/rshero) Built with ❤️ using python-telegram-bot v{str(__version__)} Running on Python {python_version()} """ results: list = [] kb = InlineKeyboardMarkup( [ [ InlineKeyboardButton( text="Support", url=f"https://t.me/yuiichansupport", ) ] ] ) results.append( InlineQueryResultArticle( id=str(uuid4()), title=f"About Yuii (@{context.bot.username})", input_message_content=InputTextMessageContent( about_text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True ), reply_markup=kb, ) ) update.inline_query.answer(results)
def about(query: str, update: Update, context: CallbackContext) -> None: """Handle the inline query.""" query = update.inline_query.query user_id = update.effective_user.id user = context.bot.get_chat(user_id) sql.update_user(user.id, user.username) about_text = f""" Kigyo (@{context.bot.username}) Maintained by [Dank-del](t.me/dank_as_fuck) Built with ❤️ using python-telegram-bot v{str(__version__)} Running on Python {python_version()} """ results: list = [] kb = InlineKeyboardMarkup( [ [ InlineKeyboardButton( text="Support", url=f"https://t.me/YorktownEagleUnion", ), InlineKeyboardButton( text="Channel", url=f"https://t.me/KigyoUpdates", ), ], [ InlineKeyboardButton( text="GitLab", url=f"https://www.gitlab.com/Dank-del/EnterpriseALRobot", ), InlineKeyboardButton( text="GitHub", url="https://www.github.com/Dank-del/EnterpriseALRobot", ), ], ]) results.append( InlineQueryResultArticle ( id=str(uuid4()), title=f"About Kigyo (@{context.bot.username})", input_message_content=InputTextMessageContent(about_text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True), reply_markup=kb ) ) update.inline_query.answer(results)
def about(query: str, update: Update, context: CallbackContext) -> None: """Handle the inline query.""" query = update.inline_query.query user_id = update.effective_user.id user = context.bot.get_chat(user_id) sql.update_user(user.id, user.username) about_text = f""" Tedeza (@{context.bot.username}) Maintained by [Vrushankz](t.me/Vrushankz) Built with ❤️ using python-telegram-bot v{str(__version__)} Running on Python {python_version()} """ results: list = [] kb = InlineKeyboardMarkup([ [ InlineKeyboardButton( text="Support", url=f"https://t.me/TedezaSupportChat", ), InlineKeyboardButton( text="Channel", url=f"https://t.me/Tedeza_News", ), ], [ InlineKeyboardButton( text="My Love", url=f"https://t.me/Vrushankz", ), InlineKeyboardButton( text="GitHub", url="https://www.github.com/Aruoto/TedezaRoBot", ), ], ]) results.append( InlineQueryResultArticle( id=str(uuid4()), title=f"About Tedeza (@{context.bot.username})", input_message_content=InputTextMessageContent( about_text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True), reply_markup=kb)) update.inline_query.answer(results)
def log_user(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] sql.update_user(msg.from_user.id, msg.from_user.username, chat.id, chat.title) if msg.reply_to_message: sql.update_user(msg.reply_to_message.from_user.id, msg.reply_to_message.from_user.username, chat.id, chat.title) if msg.forward_from: sql.update_user(msg.forward_from.id, msg.forward_from.username)
def log_user(update: Update, context: CallbackContext): chat = update.effective_chat msg = update.effective_message sql.update_user(msg.from_user.id, msg.from_user.username, chat.id, chat.title) if msg.reply_to_message: sql.update_user(msg.reply_to_message.from_user.id, msg.reply_to_message.from_user.username, chat.id, chat.title) if msg.forward_from: sql.update_user(msg.forward_from.id, msg.forward_from.username)
def log_user(update: Update, context: CallbackContext): bot = context.bot chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] sql.update_user(msg.from_user.id, msg.from_user.username, chat.id, chat.title) if msg.reply_to_message: sql.update_user(msg.reply_to_message.from_user.id, msg.reply_to_message.from_user.username, chat.id, chat.title) if msg.forward_from: sql.update_user(msg.forward_from.id, msg.forward_from.username)
def log_user(bot: Bot, update: Update): chat = update.effective_chat msg = update.effective_message sql.update_user(msg.from_user.id, msg.from_user.username, chat.id, chat.title) if msg.reply_to_message: sql.update_user( msg.reply_to_message.from_user.id, msg.reply_to_message.from_user.username, chat.id, chat.title, ) if msg.forward_from: sql.update_user(msg.forward_from.id, msg.forward_from.username)
def inlineinfo(query: str, update: Update, context: CallbackContext) -> None: """Handle the inline query.""" bot = context.bot query = update.inline_query.query log.info(query) user_id = update.effective_user.id try: search = query.split(" ", 1)[1] except IndexError: search = user_id try: user = bot.get_chat(int(search)) except (BadRequest, ValueError): user = bot.get_chat(user_id) chat = update.effective_chat sql.update_user(user.id, user.username) text = (f"<b>Information:</b>\n" f"• ID: <code>{user.id}</code>\n" f"• First Name: {html.escape(user.first_name)}") if user.last_name: text += f"\n• Last Name: {html.escape(user.last_name)}" if user.username: text += f"\n• Username: @{html.escape(user.username)}" text += f"\n• Permanent user link: {mention_html(user.id, 'link')}" nation_level_present = False if user.id == OWNER_ID: text += f"\n\nThis person is my owner" nation_level_present = True elif user.id in DEV_USERS: text += f"\n\nThis Person is a part of Eagle Union" nation_level_present = True elif user.id in SUDO_USERS: text += f"\n\nThe Nation level of this person is Royal" nation_level_present = True elif user.id in SUPPORT_USERS: text += f"\n\nThe Nation level of this person is Sakura" nation_level_present = True elif user.id in SARDEGNA_USERS: text += f"\n\nThe Nation level of this person is Sardegna" nation_level_present = True elif user.id in WHITELIST_USERS: text += f"\n\nThe Nation level of this person is Neptunia" nation_level_present = True if nation_level_present: text += ' [<a href="https://t.me/{}?start=nations">?</a>]'.format( bot.username) try: spamwtc = sw.get_ban(int(user.id)) if spamwtc: text += "<b>\n\n• SpamWatched:\n</b> Yes" text += f"\n• Reason: <pre>{spamwtc.reason}</pre>" text += "\n• Appeal at @SpamWatchSupport" else: text += "<b>\n\n• SpamWatched:</b> No" except: pass # don't crash if api is down somehow... num_chats = sql.get_user_num_chats(user.id) text += f"\n• <b>Chat count</b>: <code>{num_chats}</code>" kb = InlineKeyboardMarkup([ [ InlineKeyboardButton( text="Report Error", url=f"https://t.me/YorktownEagleUnion", ), InlineKeyboardButton( text="Search again", switch_inline_query_current_chat=".info ", ), ], ]) results = [ InlineQueryResultArticle( id=str(uuid4()), title=f"User info of {html.escape(user.first_name)}", input_message_content=InputTextMessageContent( text, parse_mode=ParseMode.HTML, disable_web_page_preview=True), reply_markup=kb), ] update.inline_query.answer(results, cache_time=5)
def inlineinfo(query: str, update: Update, context: CallbackContext) -> None: """Handle the inline query.""" bot = context.bot query = update.inline_query.query log.info(query) user_id = update.effective_user.id try: search = query.split(" ", 1)[1] except IndexError: search = user_id try: user = bot.get_chat(int(search)) except (BadRequest, ValueError): user = bot.get_chat(user_id) chat = update.effective_chat sql.update_user(user.id, user.username) text = (f"<b>Information:</b>\n" f"• ID: <code>{user.id}</code>\n" f"• First Name: {html.escape(user.first_name)}") if user.last_name: text += f"\n• Last Name: {html.escape(user.last_name)}" if user.username: text += f"\n• Username: @{html.escape(user.username)}" text += f"\n• Permanent user link: {mention_html(user.id, 'link')}" nation_level_present = False if user.id == OWNER_ID: text += f"\n\nThis person is my owner" nation_level_present = True elif user.id in DEV_USERS: text += f"\n\nThis Person is a part of Eagle Union" nation_level_present = True elif user.id in SUDO_USERS: text += f"\n\nThe Nation level of this person is Royal" nation_level_present = True elif user.id in SUPPORT_USERS: text += f"\n\nThe Nation level of this person is Sakura" nation_level_present = True elif user.id in SARDEGNA_USERS: text += f"\n\nThe Nation level of this person is Sardegna" nation_level_present = True elif user.id in WHITELIST_USERS: text += f"\n\nThe Nation level of this person is Neptunia" nation_level_present = True if nation_level_present: text += ' [<a href="https://t.me/{}?start=nations">?</a>]'.format( bot.username) try: spamwtc = sw.get_ban(int(user.id)) if spamwtc: text += "<b>\n\n• SpamWatched:\n</b> Yes" text += f"\n• Reason: <pre>{spamwtc.reason}</pre>" text += "\n• Appeal at @SpamWatchSupport" else: text += "<b>\n\n• SpamWatched:</b> No" except: pass # don't crash if api is down somehow... apst = requests.get( f'https://api.intellivoid.net/spamprotection/v1/lookup?query={context.bot.username}' ) api_status = apst.status_code if (api_status == 200): try: status = client.raw_output(int(user.id)) # ptid = status["results"]["private_telegram_id"] op = status["results"]["attributes"]["is_operator"] ag = status["results"]["attributes"]["is_agent"] wl = status["results"]["attributes"]["is_whitelisted"] ps = status["results"]["attributes"]["is_potential_spammer"] sp = status["results"]["spam_prediction"]["spam_prediction"] hamp = status["results"]["spam_prediction"]["ham_prediction"] blc = status["results"]["attributes"]["is_blacklisted"] if blc: blres = status["results"]["attributes"]["blacklist_reason"] else: blres = None text += "\n\n<b>SpamProtection:</b>" # text += f"<b>\n• Private Telegram ID:</b> <code>{ptid}</code>\n" text += f"<b>\n• Operator:</b> <code>{op}</code>\n" text += f"<b>• Agent:</b> <code>{ag}</code>\n" text += f"<b>• Whitelisted:</b> <code>{wl}</code>\n" text += f"<b>• Spam/Ham Prediction:</b> <code>{round((sp/hamp*100), 3)}%</code>\n" text += f"<b>• Potential Spammer:</b> <code>{ps}</code>\n" text += f"<b>• Blacklisted:</b> <code>{blc}</code>\n" text += f"<b>• Blacklist Reason:</b> <code>{blres}</code>\n" except HostDownError: text += "\n\n<b>SpamProtection:</b>" text += "\nCan't connect to Intellivoid SpamProtection API\n" else: text += "\n\n<b>SpamProtection:</b>" text += f"\n<code>API RETURNED: {api_status}</code>\n" num_chats = sql.get_user_num_chats(user.id) text += f"\n• Chat count: <code>{num_chats}</code>" kb = InlineKeyboardMarkup([ [ InlineKeyboardButton( text="Report Error", url=f"https://t.me/YorktownEagleUnion", ), InlineKeyboardButton( text="Search again", switch_inline_query_current_chat=".info ", ), ], ]) results = [ InlineQueryResultArticle( id=str(uuid4()), title=f"User info of {html.escape(user.first_name)}", input_message_content=InputTextMessageContent( text, parse_mode=ParseMode.HTML, disable_web_page_preview=True), reply_markup=kb), ] update.inline_query.answer(results, cache_time=5)
def inlineinfo(query: str, update: Update, context: CallbackContext) -> None: """Handle the inline query.""" bot = context.bot query = update.inline_query.query log.info(query) user_id = update.effective_user.id try: search = query.split(" ", 1)[1] except IndexError: search = user_id try: user = bot.get_chat(int(search)) except (BadRequest, ValueError): user = bot.get_chat(user_id) chat = update.effective_chat sql.update_user(user.id, user.username) text = (f"<b>General:</b>\n" f"ID: <code>{user.id}</code>\n" f"First Name: {html.escape(user.first_name)}") if user.last_name: text += f"\nLast Name: {html.escape(user.last_name)}" if user.username: text += f"\nUsername: @{html.escape(user.username)}" text += f"\nPermanent user link: {mention_html(user.id, 'link')}" try: spamwtc = sw.get_ban(int(user.id)) if spamwtc: text += "<b>\n\nSpamWatch:\n</b>" text += "<b>This person is banned in Spamwatch!</b>" text += f"\nReason: <pre>{spamwtc.reason}</pre>" text += "\nAppeal at @SpamWatchSupport" else: text += "<b>\n\nSpamWatch:</b>\n Not banned" except: pass # don't crash if api is down somehow... try: status = client.raw_output(int(user.id)) ptid = status["results"]["private_telegram_id"] op = status["results"]["attributes"]["is_operator"] ag = status["results"]["attributes"]["is_agent"] wl = status["results"]["attributes"]["is_whitelisted"] ps = status["results"]["attributes"]["is_potential_spammer"] sp = status["results"]["spam_prediction"]["spam_prediction"] hamp = status["results"]["spam_prediction"]["ham_prediction"] blc = status["results"]["attributes"]["is_blacklisted"] if blc: blres = status["results"]["attributes"]["blacklist_reason"] else: blres = None text += "\n\n<b>SpamProtection:</b>" text += f"<b>\nPrivate Telegram ID:</b> <code>{ptid}</code>\n" text += f"<b>Operator:</b> <code>{op}</code>\n" text += f"<b>Agent:</b> <code>{ag}</code>\n" text += f"<b>Whitelisted:</b> <code>{wl}</code>\n" text += f"<b>Spam Prediction:</b> <code>{sp}</code>\n" text += f"<b>Ham Prediction:</b> <code>{hamp}</code>\n" text += f"<b>Potential Spammer:</b> <code>{ps}</code>\n" text += f"<b>Blacklisted:</b> <code>{blc}</code>\n" text += f"<b>Blacklist Reason:</b> <code>{blres}</code>\n" except HostDownError: text += "\n\n<b>SpamProtection:</b>" text += "\nCan't connect to Intellivoid SpamProtection API\n" nation_level_present = False num_chats = sql.get_user_num_chats(user.id) text += f"\nChat count: <code>{num_chats}</code>" if user.id == OWNER_ID: text += f"\nThis person is my owner" nation_level_present = True elif user.id in DEV_USERS: text += f"\nThis Person is a part of Eagle Union" nation_level_present = True elif user.id in SUDO_USERS: text += f"\nThe Nation level of this person is Royal" nation_level_present = True elif user.id in SUPPORT_USERS: text += f"\nThe Nation level of this person is Sakura" nation_level_present = True elif user.id in SARDEGNA_USERS: text += f"\nThe Nation level of this person is Sardegna" nation_level_present = True elif user.id in WHITELIST_USERS: text += f"\nThe Nation level of this person is Neptunia" nation_level_present = True if nation_level_present: text += ' [<a href="https://t.me/{}?start=nations">?</a>]'.format( bot.username) results = [ InlineQueryResultArticle( id=str(uuid4()), title=f"User info of {html.escape(user.first_name)}", input_message_content=InputTextMessageContent( text, parse_mode=ParseMode.HTML, disable_web_page_preview=True), ), ] update.inline_query.answer(results, cache_time=5)