async def inline(query: types.InlineQuery): results = [ types.InlineQueryResultArticle( id="1", title="Insane password", description= "2 prefixes, 2 suffixes, 3 words, separated by the same (random) symbol", input_message_content=types.InputTextMessageContent( message_text=f"<code>{generate_insane_pwd()}</code>"), thumb_url= "https://raw.githubusercontent.com/MasterGroosha/telegram-xkcd-password-generator/master/img/pwd_green.png", thumb_height=64, thumb_width=64, ), types.InlineQueryResultArticle( id="2", title="Very strong password", description="4 words, random uppercase, separated by numbers", input_message_content=types.InputTextMessageContent( message_text=f"<code>{generate_stronger_pwd()}</code>"), thumb_url= "https://raw.githubusercontent.com/MasterGroosha/telegram-xkcd-password-generator/master/img/pwd_green.png", thumb_height=64, thumb_width=64, ), types.InlineQueryResultArticle( id="3", title="Strong password", description="3 words, random uppercase, separated by numbers", input_message_content=types.InputTextMessageContent( message_text=f"<code>{generate_strong_pwd()}</code>"), thumb_url= "https://raw.githubusercontent.com/MasterGroosha/telegram-xkcd-password-generator/master/img/pwd_yellow.png", thumb_height=64, thumb_width=64, ), types.InlineQueryResultArticle( id="4", title="Normal password", description="3 words, second one is uppercase", input_message_content=types.InputTextMessageContent( message_text=f"<code>{generate_normal_pwd()}</code>"), thumb_url= "https://raw.githubusercontent.com/MasterGroosha/telegram-xkcd-password-generator/master/img/pwd_yellow.png", thumb_height=64, thumb_width=64, ), types.InlineQueryResultArticle( id="5", title="Weak password", description="2 words, no digits", input_message_content=types.InputTextMessageContent( message_text=f"<code>{generate_weak_pwd()}</code>"), thumb_url= "https://raw.githubusercontent.com/MasterGroosha/telegram-xkcd-password-generator/master/img/pwd_red.png", thumb_height=64, thumb_width=64, ) ] await query.answer(results=results, cache_time=1, is_personal=True)
async def default_handler(inline_query: types.InlineQuery): item1 = types.InlineQueryResultArticle( id="api-reference", title="Telegram Bot API Reference", input_message_content=types.InputTextMessageContent( '<a href="https://core.telegram.org/bots/api">Telegram Bot API Reference</a>', disable_web_page_preview=True), thumb_url=config.TG_LOGO_URL) item2 = types.InlineQueryResultArticle( id="aiogram-examples", title="Aiogram Examples", input_message_content=types.InputTextMessageContent( '<a href="https://github.com/aiogram/aiogram/tree/dev-2.x/examples">Aiogram Examples</a>', disable_web_page_preview=True), thumb_url=config.AIOGRAM_LOGO_URL) item3 = types.InlineQueryResultArticle( id="why-aiogram", title="Почему aiogram?", input_message_content=types.InputTextMessageContent( await get_advantages_article(), disable_web_page_preview=True)) await bot.answer_inline_query( inline_query.id, results=[item1, item2, item3], cache_time=config.QUERY_CACHE_TIME, switch_pm_text="Query should be >3 characters", switch_pm_parameter="must_click", )
async def inline_search_toloka(q: types.InlineQuery): results = await Toloka.search(q.query, limit=50) inline_results = [] if results: for n, result in enumerate(results): result: Toloka.TolokaSearchResult input_content = types.InputTextMessageContent( stringify_toloka_search_result(result)) inline_result = types.InlineQueryResultArticle( id=str(n), title=result.title, input_message_content=input_content, description= f'{result.size}, {result.seeders} S | {result.leechers} L | {result.complete} C' ) inline_results.append(inline_result) if n >= 50: break else: input_content = types.InputTextMessageContent( f'Nothing found for {q.query}') inline_result = types.InlineQueryResultArticle( id='1', title='Nothing found', input_message_content=input_content, description=f'Nothing found for {q.query}') inline_results.append(inline_result) try: await bot.answer_inline_query(q.id, inline_results) except: pass
async def processing_lectures(lessons): if not lessons: result=[ types.InlineQueryResultArticle( id="unknown", title="No Lecture found", input_message_content=types.InputTextMessageContent( message_text="Wait for lectures to be added" ), description="Wait for lectures to be added", thumb_url="https://bit.ly/3lbUCZy", ), ] else: result = [] for lesson in lessons: result.append( types.InlineQueryResultArticle( id=lesson['id'], title=lesson['name'], input_message_content=types.InputTextMessageContent( message_text=lesson['name'], ), thumb_url=lesson['image'], reply_markup=await get_lesson_keyboard(lesson['id']) ) ) return result
async def inline_handler(inline_query: types.InlineQuery): text = inline_query.query.lower() if not text or inline_query.from_user.id not in VIP and (await amt_donated(inline_query.from_user.id)) < 10: await inline_query.answer([ types.InlineQueryResultArticle( id=str(uuid4()), title="Start a classic game", description="/startclassic@on9wordchainbot", input_message_content=types.InputTextMessageContent("/startclassic@on9wordchainbot") ), types.InlineQueryResultArticle( id=str(uuid4()), title="Start a hard mode game", description="/starthard@on9wordchainbot", input_message_content=types.InputTextMessageContent("/starthard@on9wordchainbot") ), types.InlineQueryResultArticle( id=str(uuid4()), title="Start a chaos game", description="/startchaos@on9wordchainbot", input_message_content=types.InputTextMessageContent("/startchaos@on9wordchainbot") ), types.InlineQueryResultArticle( id=str(uuid4()), title="Start a chosen first letter game", description="/startcfl@on9wordchainbot", input_message_content=types.InputTextMessageContent("/startcfl@on9wordchainbot") ), types.InlineQueryResultArticle( id=str(uuid4()), title="Start a banned letters game", description="/startbl@on9wordchainbot", input_message_content=types.InputTextMessageContent("/startbl@on9wordchainbot") ), types.InlineQueryResultArticle( id=str(uuid4()), title="Start a required letter game", description="/startrl@on9wordchainbot", input_message_content=types.InputTextMessageContent("/startrl@on9wordchainbot") ), types.InlineQueryResultArticle( id=str(uuid4()), title="Start an elimination game", description="/startelim@on9wordchainbot", input_message_content=types.InputTextMessageContent("/startelim@on9wordchainbot") ) ], is_personal=not text) return if any(c not in ascii_lowercase for c in text): await inline_query.answer([types.InlineQueryResultArticle( id=str(uuid4()), title="A query may only consist of alphabets", description="Try a different query", input_message_content=types.InputTextMessageContent(r"¯\\_(ツ)\_/¯") )], is_personal=True) return res = [] for i in get_words_li()[text[0]]: if i.startswith(text): i = i.capitalize() res.append(types.InlineQueryResultArticle(id=str(uuid4()), title=i, input_message_content=types.InputTextMessageContent(i))) if len(res) == 50: break if not res: res.append(types.InlineQueryResultArticle( id=str(uuid4()), title="No results found", description="Try a different query", input_message_content=types.InputTextMessageContent(r"¯\\_(ツ)\_/¯") )) await inline_query.answer(res, is_personal=True)
async def inline(inline_query: types.InlineQuery): input_content = types.InputTextMessageContent(inline_query.query or 'echo') item1 = types.InlineQueryResultArticle(id='1', title='echo %s' % input_content['message_text'], input_message_content=input_content) item2 = types.InlineQueryResultArticle(id='2', title='beep %s' % input_content['message_text'], input_message_content=input_content) await bot.answer_inline_query(inline_query.id, results=[item1, item2], cache_time=1)
async def inline_send(inline_query: types.InlineQuery): print(inline_query.query) if len(inline_query.query) >= 3: offset = inline_query.offset if offset == "": offset = 0 files = await loop.create_task( db.find_file_by_name(inline_query.query, offset=int(offset) if offset != "" else 0)) if len(files) > 0: result = [] for n, file in enumerate(files): if n < 5: item = types.InlineQueryResultDocument( id=str(n), title=file['file_name'], document_url=file['file_id'], mime_type="application") result.append(item) if len(files) == 6: offset = int( offset ) + 5 #await bot.answer_inline_query(inline_query.id, results=result, cache_time=3, next_offset=str(int(offset)+5) if offset!="" else '0') await bot.answer_inline_query(inline_query.id, results=result, cache_time=1, next_offset=offset) else: await bot.answer_inline_query(inline_query.id, results=result, cache_time=1) else: input_content = types.InputTextMessageContent( _("Немогу найти такого файла 🙄")) item = types.InlineQueryResultArticle( id='1', title=_('Немогу найти такого файла 🙄'), input_message_content=input_content) await bot.answer_inline_query(inline_query.id, results=[item], cache_time=1) else: input_content = types.InputTextMessageContent( _("Введи первые 3 буквы для поиска файла")) item = types.InlineQueryResultArticle( id='1', title=_('Введи первые 3 буквы для поиска файла'), input_message_content=input_content) await bot.answer_inline_query(inline_query.id, results=[item], cache_time=86400)
async def inline_handler(query: types.InlineQuery): logging.info("зашли в inline_handler (для вывода кнопки Приласить друга)") """ user_links = [["KEY", "LINK"]] if len(user_links) == 0: switch_text = "У вас нет сохранённых ссылок. Добавить »»" \ if len(query.query) == 0 \ else "Не найдено ссылок по данному запросу. Добавить »»" return await query.answer( [], cache_time=60, is_personal=True, switch_pm_parameter="add", switch_pm_text=switch_text) """ bot_username = (await bot.get_me()).username id_referal = query.from_user.id bot_link = f"https://t.me/{bot_username}?start={id_referal}" article = types.InlineQueryResultArticle( id="1", title="Пригласить в игру", description=f"", url="https://t.me/party_hard_bot", hide_url=False, thumb_url=f"https://i.ytimg.com/vi/EMNKInfWanE/maxresdefault.jpg", input_message_content=types.InputTextMessageContent( message_text= f"Вас оиждают в игре <b>Что? Где? Когда?</b> перейдите по ссылке {bot_link}!", parse_mode="HTML")) await query.answer([article], cache_time=60, is_personal=True)
async def fetch_inline(inline_query: types.InlineQuery): text = inline_query.query if not text: return items = [] # add articles from TG Bot API Reference api_articles = await searcher.get_api_articles(text) # add articles from github examples examples = await searcher.get_aiogram_examples(text) results = api_articles + examples # 50 results max for article in results[:50]: result_id = hash(article['title']) input_content = types.InputTextMessageContent( f'{article["type"]}: <a href=\"{article["link"]}\">{article["title"]}</a>', disable_web_page_preview=True ) # if article['type'] == 'API Reference': # thumb_url = TG_LOGO_URL # else: # thumb_url = AIOGRAM_LOGO_URL item = types.InlineQueryResultArticle( id=result_id, title=article["title"], description=article["type"], input_message_content=input_content # thumb_url=thumb_url ) items.append(item) await bot.answer_inline_query(inline_query.id, results=items, cache_time=120)
async def some_query(query: types.InlineQuery): user = query.from_user.id if user not in config.ALLOWED_USERS: await query.answer( results=[], switch_pm_text='Бот недоступен, подключите бота', switch_pm_parameter="connect_user", cache_time=5 ) return products = await database.get_products(query.query) print(products) print(dir(products)) await query.answer( results=[ types.InlineQueryResultArticle( id="1", title="Название, которое отображается в инлайн режиме", input_message_content=types.InputTextMessageContent(message_text="Тут какой-то текст"), url = "https://ireland.apollo.olxcdn.com/v1/files/hx4jgwfeyj6v1-UA/image;s=1000x700", thumb_url="https://ireland.apollo.olxcdn.com/v1/files/hx4jgwfeyj6v1-UA/image;s=1000x700", description="Описание в инлайн режиме", ), types.InlineQueryResultVideo(id="4", video_url="https://pixabay.com/en/videos/download/video-10737_medium.mp4", caption="подпись к видео", title='Какое-то видео тайтл', description="описание видео", thumb_url='https://i.pinimg.com/originals/c1/48/20/c1482019aee334b33177e5744a495ac0.jpg', mime_type="video/mp4" ), types.InlineQueryResultPhoto(id="2", photo_url="https://ireland.apollo.olxcdn.com/v1/files/hx4jgwfeyj6v1-UA/image;s=1000x700", thumb_url='https://i.pinimg.com/originals/c1/48/20/c1482019aee334b33177e5744a495ac0.jpg', caption="asdasd") ] )
async def inline_query(query: types.InlineQuery): results = [] user_quizzes = quizzes_database.get(str(query.from_user.id)) if user_quizzes: for quiz in user_quizzes: keyboard = types.InlineKeyboardMarkup() start_quiz_button = types.InlineKeyboardButton( text="Отправить в группу", url=await deep_linking.get_startgroup_link(quiz.quiz_id)) keyboard.add(start_quiz_button) results.append( types.InlineQueryResultArticle( id=quiz.quiz_id, title=quiz.question, input_message_content=types. InputTextMessageContent( message_text= "Нажмите кнопку ниже, чтобы отправить викторину в группу." ), reply_markup=keyboard)) await query.answer(switch_pm_text="Создать викторину", switch_pm_parameter="_", results=results, cache_time=120, is_personal=True)
async def empty_query(query: types.InlineQuery): user = query.from_user.id check_user = db.select_user(user_id=user) if check_user is None: await query.answer( results=[], switch_pm_text="Бот недоступен. Подключить", switch_pm_parameter="connect_user", cache_time=5 ) return items = db.select_all_items_abc() res = [] for item in items: id = item[0] name = item[1] # photo_id = item[2] # description = item[3] price = item[4]/100 url = item[5] inline_text = f"Цена:\t{price}" text = f"<b>{name}</b>\n\n<b>Цена:</b> \t{price:,}" # res.append(types.InlineQueryResultCachedPhoto(id=id, photo_file_id=photo_id, caption=text, # parse_mode="HTML", reply_markup=show_keyboard(id))) res.append(types.InlineQueryResultArticle(id=id, title=name, input_message_content=types.InputTextMessageContent( message_text=text ), reply_markup=show_keyboard(id), description=inline_text, thumb_url=url)) await query.answer( results=res, cache_time=5 )
async def some_query(query: types.InlineQuery): user = query.from_user.id if user not in allowed_users: await query.answer(results=[], switch_pm_text="Bot not in use. Connect to bot", switch_pm_parameter="connect", cache_time=5) return await query.answer(results=[ types.InlineQueryResultArticle( id="1", title="Name in inline mode", input_message_content=types.InputTextMessageContent( message_text="Some text witch will send on click button"), url="https://www.youtube.com/", thumb_url= "https://i2.wp.com/itc.ua/wp-content/uploads/2020/04/facebook-instagram-youtube-logo" "-clipart-3.jpg?w=1200&quality=100&strip=all&ssl=1", description="Description in inline mode"), types.InlineQueryResultVideo( id="4", video_url="https://www.youtube.com/watch?v=hKjAHT4z-PY", caption="Scars", title="F211 Scars", description="Scars clip", mime_type="video/mp4", thumb_url= "https://i2.wp.com/itc.ua/wp-content/uploads/2020/04/facebook-instagram-youtube-logo" ) ])
async def query_with_age(query: types.InlineQuery): user, _ = User.get_or_create(user_id=query.from_user.id, defaults={"language": "en"}) # only the user object is used, as there is no forwarding in inline query clean = clean_message(query)["from"] date = time_format(unix_time=interpolation.func(int(clean["id"]))) clean["registered"] = date logger.info(f"{user.user_id} requested date for ID {int(clean['id'])} " f"via InlineQuery, received date {date}") escaped = escape_dict(clean) tree = REPLIES["message"][user.language] + tree_display(escaped) await query.answer( results=[ types.InlineQueryResultArticle( id="1", # id no matter, because we only have 1 article title=REPLIES["inline_handler_title"][user.language], input_message_content=types.InputTextMessageContent( tree, parse_mode="HTML"), description=REPLIES["inline_handler_content"][user.language], ) ], cache_time=300, is_personal=True, ) user.requests += 1 user.save()
async def artist_search_inline_handler(query): q = query.query.replace('.ar', '').strip() search_results = await deezer_api.search('artist', q) results = [] if not q: return await bot.answer_inline_query(inline_query_id=query.id, results=results, switch_pm_text='Search', switch_pm_parameter='0') if query.offset == 'done': await bot.answer_inline_query(inline_query_id=query.id, results=results) offset = int(query.offset) if query.offset.isdecimal() else 0 for result in search_results[offset:offset + 5]: results.append( types.InlineQueryResultArticle( id=result.link, title=result.name, thumb_url=result.picture_small, thumb_width=56, thumb_height=56, input_message_content=types.InputTextMessageContent( result.link))) if offset + 6 < len(search_results): next_offset = str(offset + 5) else: next_offset = 'done' await bot.answer_inline_query(inline_query_id=query.id, results=results, next_offset=next_offset)
def prepare_items(items): title = 'Суми - Гадяч' description_base = 'Дізнатись кількість вільних місць' ask_choose_bus = 'Оберіть час відправлення' result = [] for day, desc in items.items(): # markup markup = types.InlineKeyboardMarkup() for idx in range(len(DEPARTURE_TIME)): markup.insert( types.InlineKeyboardButton(DEPARTURE_TIME[idx], callback_data=bus_cb.new( wkday=desc['wkday'], date=desc['day'], time=str(idx)))) # message msg = '🚌 Звєздольт Суми -> Гадяч' + '\n' + '\n' msg += '📅 ' + desc['wkday'] + ', ' msg += desc['day'] + '\n' + '\n' msg += ask_choose_bus input_content = types.InputTextMessageContent(msg) item = types.InlineQueryResultArticle( id=desc['id'], title=title + ' [' + desc['title_info'] + '][' + desc['day'] + ']', input_message_content=input_content, reply_markup=markup, description=description_base, thumb_url=desc['thumb_url'], ) result.append(item) return result
async def show_inline_list_of_items(items, query): bot_url = "https://t.me/udemy_shopobot/" await query.answer( results=[ types.InlineQueryResultArticle( id=item.id, title=item.name, description=item.description, thumb_url=item.photo, url=bot_url + "?item=" + str(item.id), input_message_content=types.InputTextMessageContent( message_text=f"<b>{item.name}</b>\n" f"{item.description}\n" f"Цена: {item.price}\n", parse_mode="HTML", ), reply_markup=InlineKeyboardMarkup(inline_keyboard=[[ InlineKeyboardButton( text="Посмотреть", # switch_pm_text="Бот недоступен. Подключить бота", # switch_pm_parameter="item_id={item.id}", # switch_inline_query_current_chat=f"item_id={item.id}", url= f"tg://resolve?domain=udemy_shopobot&start=item_{item.id}" # url=f"https://t.me/udemy_shopobot/?start=item_{item.id}" ) ]])) for item in items ], cache_time=0, )
async def items_query(query: types.InlineQuery, state: FSMContext): starting_item = int(query.offset) if query.offset else 0 results = await db.get_items(query.query, starting_item) items_list = [] for item in results: id_for_admin = f'<b>id={item.item_id}\n</b>' \ if await state.get_state() and str(query.from_user.id) in ADMINS else '' items_list.append( types.InlineQueryResultArticle( id=item.item_id, title=item.name, description=f'{item.price}₽\n{item.description}', thumb_url=item.thumb_url, input_message_content=types.InputTextMessageContent( message_text=f'{hide_link(item.thumb_url)}{id_for_admin}' f'<b>Товар:</b> {item.name}\n' f'<b>Цена:</b> {item.price}₽\n' f'<b>Описание:</b>\n{item.description}\n\n' f'<i>Дата выставления товара: ' f'{item.create_date.strftime("%d-%m-%Y %H:%M")}</i>'), reply_markup=await show_item_button(item.item_id))) await query.answer(results=items_list, cache_time=60, next_offset=str(starting_item + 20))
async def fetch_inline(inline_query: types.InlineQuery): text = inline_query.query items = [] api_articles = await searcher.get_api_articles(text) examples = await searcher.get_aiogram_examples(text) results = api_articles + examples offset = int(inline_query.offset or 0) for article in results[offset:offset + config.MAX_INLINE_RESULTS]: result_id = article['title'] while len(article['title'].encode('utf-8')) > 64: result_id = result_id[:-1] input_content = types.InputTextMessageContent( f'{article["type"]}: <a href=\"{article["link"]}\">{article["title"]}</a>', disable_web_page_preview=True) item = types.InlineQueryResultArticle( id=result_id, title=article["title"], description=article["type"], input_message_content=input_content) items.append(item) next_offset = str(offset + config.MAX_INLINE_RESULTS) if len( items) == config.MAX_INLINE_RESULTS else "" await bot.answer_inline_query( inline_query.id, results=items, cache_time=config.QUERY_CACHE_TIME, next_offset=next_offset, )
async def send(inline_query): answer = types.InlineQueryResultArticle( id=inline_query.id, title=inline_query.query, input_message_content=types.InputTextMessageContent( message_text=(url + inline_query.query.replace(' ', '+')))) await bot.answer_inline_query(inline_query.id, [answer], cache_time=1)
async def inline_echo(inline_query: types.InlineQuery): input_content = types.InputTextMessageContent(inline_query.query or 'echo') item = types.InlineQueryResultArticle(id='1', title='echo', input_message_content=input_content) await bot.answer_inline_query(inline_query.id, results=[item], cache_time=1)
async def empty_query(query: types.InlineQuery): await query.answer(results=[ types.InlineQueryResultArticle( id="111", title="Input search query", input_message_content=types.InputTextMessageContent( message_text="Don't need click button")) ], cache_time=5)
async def empty_query(query: types.InlineQuery): await query.answer(results=[ types.InlineQueryResultArticle( id="unknown", title="Введите запрос!", input_message_content=types.InputTextMessageContent( message_text="Введи, а не жми")) ], cache_time=5)
async def handle_wrong_inline_link(inline_query: types.InlineQuery): result_id = hashlib.md5(inline_query.query.encode()).hexdigest() input_content = types.InputTextMessageContent( 'Link greater than 256 characters') title = _('Link greater than 256 characters') item = types.InlineQueryResultArticle(id=result_id, title=title, input_message_content=input_content) return await inline_query.answer(results=[item], cache_time=300)
async def inline_def(inline_query: types.InlineQuery): input_content = types.InputTextMessageContent("/g_def HUB") item1 = types.InlineQueryResultArticle(id='1', title='🛡 HUB', input_message_content=input_content) try: await bot.answer_inline_query(inline_query.id, results=[item1], cache_time=1) except Exception as e: print(e)
async def default_handler(inline_query: types.InlineQuery): item1 = types.InlineQueryResultArticle( id=1, title="Telegram Bot API Reference", input_message_content=types.InputTextMessageContent( '<a href="https://core.telegram.org/bots/api">Telegram Bot API Reference</a>', disable_web_page_preview=True ), thumb_url=TG_LOGO_URL ) item2 = types.InlineQueryResultArticle( id=2, title="Aiogram Documentation", input_message_content=types.InputTextMessageContent( '<a href="https://docs.aiogram.dev/en/latest/">Aiogram Documentation</a>', disable_web_page_preview=True ), thumb_url=AIOGRAM_LOGO_URL ) item3 = types.InlineQueryResultArticle( id=3, title="Aiogram Sources", input_message_content=types.InputTextMessageContent( '<a href="https://github.com/aiogram/aiogram/">Aiogram Sources</a>', disable_web_page_preview=True ), thumb_url=AIOGRAM_LOGO_URL ) item4 = types.InlineQueryResultArticle( id=4, title="Почему aiogram?", input_message_content=types.InputTextMessageContent( await get_advantages_article(), disable_web_page_preview=True ) ) await bot.answer_inline_query(inline_query.id, results=[item1, item2, item3, item4], cache_time=120)
async def show_msc(query: InlineQuery): city: str = query.query.title() results = [] for city_name in all_city_names: if city_name.lower().startswith(city.lower()): answer = await create_answer(city_name) results.append( types.InlineQueryResultArticle( id=f"{city_name}", thumb_url= "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/apple/96/hospital_1f3e5.png", title=f"🏥 РС-центры в городе: {city_name}", input_message_content=types.InputTextMessageContent( message_text=answer, parse_mode="HTML", disable_web_page_preview=True), reply_markup=inline_kb.bot_link())) if not results: results.append( types.InlineQueryResultArticle( id=f"{city}", thumb_url= "https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/Crystal_button_cancel.svg/150px-Crystal_button_cancel.svg.png", title=f"🚫 Подходящие РС-центры не найдены", input_message_content=types.InputTextMessageContent( message_text= "🏥 Открытая база медицинских центров, занимающихся вопросами Рассеянного склероза:\n" f"[База РС-Центров]({config.MS_CENTERS})\n\n" f"✅ Еще больше полезных функций вы сможете найти в приватном чате бота.\n\n" "⚠️Если вы обнаружили, что в базе не хватает какого-либо *специализированного* РС-центра," "*который ведет прием пациентов по ОМС*, отправьте пожалуйста адрес и название этой " f"организации в ЛС боту.", parse_mode="Markdown", disable_web_page_preview=True), reply_markup=inline_kb.bot_link())) await query.answer(results=results)
async def empty_query(query: types.InlineQuery): await query.answer( results=[ types.InlineQueryResultArticle( id="unknow", title="Введите какой-то запрос", input_message_content=types.InputTextMessageContent( message_text="Не обязательно жать при этом на кнопку" ) ) ], cache_time=5 )
async def show_msc_in_city(query: InlineQuery): city = query.query.title() answer = await create_answer(city) await query.answer(results=[ types.InlineQueryResultArticle( id="unknown", thumb_url= "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/apple/96/hospital_1f3e5.png", title=f"🏥 РС-центры в городе: {city}", input_message_content=types.InputMessageContent( message_text=answer, parse_mode="Markdown")) ], )
async def get_products(thing: str): """Building product's list""" res = [] if len(thing) == 0: print('get_products -> Quit') res.append(types.InlineQueryResultArticle(id = '0', title = 'Введите название товара, после имени бота...', input_message_content = types.InputTextMessageContent( message_text = 'Введите название товара:\n@название_бота ' 'телевизор'))) return res products = await pc.get_products(thing) # print('get_products -> products={}'.format(products)) for product in products: link = await photo_link(product.photo) res.append(types.InlineQueryResultArticle(id = str(product.id), title = product.name, input_message_content = types.InputTextMessageContent( message_text = f'ID={product.id}'), description = f"{product.description[:30]}.\nЦена - " f"{str(product.price)}", thumb_url = link ) ) # print('get_products -> res={}'.format(res)) return res