async def pmpermit_inline_query_handler(_, query: InlineQuery): results = [] owner = await userge.get_me() pm_inline_msg = await SAVED_SETTINGS.find_one({'_id': 'CUSTOM_INLINE_PM_MESSAGE'}) if pm_inline_msg: text = pm_inline_msg.get('data') else: text = f"Hello, welcome to **{owner.first_name}** Dm.\n\nWhat you want to do ?" buttons = [[ InlineKeyboardButton( "Contact Me", callback_data="pm_contact"), InlineKeyboardButton( "Spam here", callback_data="pm_spam")]] results.append( InlineQueryResultArticle( id=uuid4(), title="Pm Permit", input_message_content=InputTextMessageContent(text), description="Inline Pm Permit Handler", thumb_url="https://imgur.com/download/Inyeb1S", reply_markup=InlineKeyboardMarkup(buttons) ) ) await query.answer( results=results, cache_time=60 ) query.stop_propagation()
async def stop_user_from_doing_anything_inline(_, iq: InlineQuery): allowed_users = Common().allowed_users if allowed_users and iq.from_user: if iq.from_user.id not in allowed_users: iq.stop_propagation() else: iq.continue_propagation() else: if iq.from_user: iq.continue_propagation() else: iq.stop_propagation()
async def inline_fn(_, inline_query: InlineQuery): query = inline_query.query.split("ud ")[1].strip() try: riqa = await wpraip(query) switch_pm_text = f"Found {len(riqa)} results for {query}" except JSONDecodeError: riqa = [] if not riqa: switch_pm_text = f"Sorry, couldn't find any results for: {query}" await inline_query.answer(results=riqa[:49], cache_time=300, is_gallery=False, is_personal=False, next_offset="", switch_pm_text=switch_pm_text, switch_pm_parameter="ud") inline_query.stop_propagation()
async def inline_fn(_, inline_query: InlineQuery): movie_name = inline_query.query.split("imdb ")[1].strip() search_results = await _get( imdb.API_ONE_URL.format(theuserge=movie_name)) srch_results = json.loads(search_results.text) asroe = srch_results.get("d") oorse = [] for sraeo in asroe: title = sraeo.get("l", "") description = sraeo.get("q", "") stars = sraeo.get("s", "") imdb_url = f"https://imdb.com/title/{sraeo.get('id')}" year = sraeo.get("yr", "").rstrip('-') image_url = sraeo.get("i").get("imageUrl") message_text = f"<a href='{image_url}'>🎬</a>" message_text += f"<a href='{imdb_url}'>{title} {year}</a>" oorse.append( InlineQueryResultArticle( title=f" {title} {year}", input_message_content=InputTextMessageContent( message_text=message_text, parse_mode="html", disable_web_page_preview=False), url=imdb_url, description=f" {description} | {stars}", thumb_url=image_url, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="Get IMDB details", callback_data=f"imdb({sraeo.get('id')})") ]]))) resfo = srch_results.get("q") await inline_query.answer( results=oorse, cache_time=300, is_gallery=False, is_personal=False, next_offset="", switch_pm_text=f"Found {len(oorse)} results for {resfo}", switch_pm_parameter="imdb") inline_query.stop_propagation()
async def inline_answer(_, inline_query: InlineQuery): data = inline_query.query.split('-', maxsplit=1) _id = data[0].strip() msg = data[1].strip() if not (msg and msg.endswith(':')): inline_query.stop_propagation() try: user = await userge.get_users(_id.strip()) except Exception: # pylint: disable=broad-except inline_query.stop_propagation() return c_m_e = MEDIA_FID_S.get(msg[:-1]) if not c_m_e: PRVT_MSGS[inline_query.id] = (user.id, user.first_name, msg.strip(': ')) else: PRVT_MSGS[inline_query.id] = (user.id, user.first_name, c_m_e) prvte_msg = [[ InlineKeyboardButton("Show Message 🔐", callback_data=f"prvtmsg({inline_query.id})") ]] msg_c = f"🔒 A **private message** to {'@' + user.username}, " msg_c += "Only he/she can open it." results = [ InlineQueryResultArticle( id=uuid4(), title=f"A Private Msg to {user.first_name}", input_message_content=InputTextMessageContent(msg_c), description="Only he/she can open it", thumb_url="https://te.legra.ph/file/16133ab3297b3f73c8da5.png", reply_markup=InlineKeyboardMarkup(prvte_msg)) ] await inline_query.answer(results=results, cache_time=3)