def test_answer_inline_query_default_parse_mode(self, monkeypatch, default_bot): def test(_, url, data, *args, **kwargs): return data == {'cache_time': 300, 'results': [{'title': 'test_result', 'id': '123', 'type': 'document', 'document_url': 'https://raw.githubusercontent.com/' 'python-telegram-bot/logos/master/logo/png/' 'ptb-logo_240.png', 'mime_type': 'image/png', 'caption': 'ptb_logo', 'parse_mode': 'Markdown'}], 'next_offset': '42', 'switch_pm_parameter': 'start_pm', 'inline_query_id': 1234, 'is_personal': True, 'switch_pm_text': 'switch pm'} monkeypatch.setattr('telegram.utils.request.Request.post', test) results = [InlineQueryResultDocument( id='123', document_url='https://raw.githubusercontent.com/python-telegram-bot/logos/master/' 'logo/png/ptb-logo_240.png', title='test_result', mime_type='image/png', caption='ptb_logo', )] assert default_bot.answer_inline_query(1234, results=results, cache_time=300, is_personal=True, next_offset='42', switch_pm_text='switch pm', switch_pm_parameter='start_pm')
def pluginfile(update: Update, context: CoreContext): query: InlineQuery = update.inline_query url: str = query.query # https://elearning.ut.ac.id/webservice/pluginfile.php/12345/mod_resource/content/0/File.pdf urls = url.split("/") resource_id = urls[5] resource_title = unquote(urls[-1]).title() resource_url = url + "?token=" + context.moodle.token results = list() if url.endswith(".pdf"): result = InlineQueryResultDocument( id=resource_id, document_url=resource_url, title=resource_title, mime_type="application/pdf", description="File elearning.", ) results.append(result) elif url.endswith(".zip"): result = InlineQueryResultDocument( id=resource_id, document_url=resource_url, title=resource_title, mime_type="application/zip", description="File elearning.", ) results.append(result) else: result = InlineQueryResultArticle( id=resource_id, title=resource_title, input_message_content=InputTextMessageContent( format_html.href(resource_title, resource_url), disable_web_page_preview=False, ), description="File elearning.", ) results.append(result) query.answer( results, cache_time=600, is_personal=True, switch_pm_text="Bantuan", switch_pm_parameter="inline-help", ) return -1
def test_equality(self): a = InlineQueryResultDocument(self.id_, self.document_url, self.title, self.mime_type) b = InlineQueryResultDocument(self.id_, self.document_url, self.title, self.mime_type) c = InlineQueryResultDocument(self.id_, '', self.title, self.mime_type) d = InlineQueryResultDocument('', self.document_url, self.title, self.mime_type) e = InlineQueryResultVoice(self.id_, '', '') assert a == b assert hash(a) == hash(b) assert a is not b assert a == c assert hash(a) == hash(c) assert a != d assert hash(a) != hash(d) assert a != e assert hash(a) != hash(e)
def send_inline(update, context): '''This function handles sending polls through inline queries''' user = update.effective_user.id try: polls = user_polls[user] except KeyError as e: return # FIXME eventually this should display all polls if no query is given if update.inline_query['query'] != 'all': try: poll = polls[int(update.inline_query['query'])] context.bot.answer_inline_query(update.inline_query.id, [ InlineQueryResultDocument( 1, "https://t.me/" + str(update.inline_query.id), poll.question, 'application/pdf', input_message_content=InputTextMessageContent( poll.generate_text_poll()), reply_markup=poll.generate_markdown_poll()) ], cache_time=0) except KeyError: pass except ValueError: pass else: poll_list = list(polls.values()) poll_list.remove(polls['current']) if len(poll_list) > 0: context.bot.answer_inline_query(update.inline_query.id, [ InlineQueryResultDocument( 1, "https://t.me/" + str(update.inline_query.id), poll.question, 'application/pdf', input_message_content=InputTextMessageContent( poll.generate_text_poll()), reply_markup=poll.generate_markdown_poll()) for poll in poll_list ], cache_time=0)
def result_document(self) -> InlineQueryResultDocument: return InlineQueryResultDocument( id=uuid4(), title=self.title, description=f"Dokumen, {self.topic}", document_url=self.url, mime_type="application/pdf", input_message_content=InputTextMessageContent( self.text, disable_web_page_preview=False), reply_markup=self.reply_markup, )
def inline_query_result_document(): return InlineQueryResultDocument(TestInlineQueryResultDocument.id, TestInlineQueryResultDocument.document_url, TestInlineQueryResultDocument.title, TestInlineQueryResultDocument.mime_type, caption=TestInlineQueryResultDocument.caption, description=TestInlineQueryResultDocument.description, thumb_url=TestInlineQueryResultDocument.thumb_url, thumb_width=TestInlineQueryResultDocument.thumb_width, thumb_height=TestInlineQueryResultDocument.thumb_height, input_message_content=TestInlineQueryResultDocument.input_message_content, reply_markup=TestInlineQueryResultDocument.reply_markup)
def inlinequery(update, context): query = update.inline_query.query inline = [[ InlineKeyboardButton("Our Group", url="https://t.me/ParaboyMirror"), InlineKeyboardButton("Report Bug", url="https://t.me/topglobal_epep") ]] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Click here", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption= "Downloaded via @XSubtitleRobot\n\nUse @UnzipTGBot for unzipping this zip file \nor download the file and unzip manually" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [[ InlineKeyboardButton("Our Group", url="https://t.me/AI_BOT_HELP"), InlineKeyboardButton("Our Channel", url="https://t.me/AI_bot_projects") ]] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption= "©️ @subtitle_search_byAI_bot\n\nUse @UnzipTGBot for unzipping this zip file or download the file and unzip manually" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [ [ InlineKeyboardButton("Our Group", url="https://telegram.dog/SDFBots") ] ] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption="©️ @SDFBots" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [ [ InlineKeyboardButton("⚙ Channel ⚙", url="https://telegram.me/VKPROJECTS"), InlineKeyboardButton("⚙ Group ⚙", url="https://telegram.me/VKP_BOTS") ] ] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption="©️ @VKSubtitleBot" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [[ InlineKeyboardButton("Support Group", url="https://t.me/linux_repo"), InlineKeyboardButton("Telegram Bots Updates Channel", url="https://t.me/Discovery_Updates") ]] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption= "©️ @GetSubtitles_bot\n\nUse @UnzipTGBot for unzipping this zip file or download the file and unzip manually" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [ [ InlineKeyboardButton("𝗢𝗨𝗥 𝗚𝗥𝗢𝗨𝗣", url="https://telegram.dog/LeechZone"), InlineKeyboardButton("𝗢𝗨𝗥 𝗖𝗛𝗔𝗡𝗡𝗘𝗟", url="https://t.me/joinchat/AAAAAE-44AkxSyqIMj1tdQ") ] ] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption="©️ @AllSubtitleBot\n\nUse @UnzipTGBot for unzipping this zip file or download the file and unzip manually" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [[ InlineKeyboardButton("Our Group", url="https://telegram.dog/Kanadarockersgroup"), InlineKeyboardButton("Our Channel", url="https://telegram.dog/NithinMovies") ]] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption= "©️ @SubtitleTGBot\n\nUse this bot to find subtitle , if you found it helpful share with your friends" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [[ InlineKeyboardButton("Our Group", url="https://telegram.dog/MasterTrick2"), InlineKeyboardButton("Our Channel", url="https://youtube.com/mastertrick1") ]] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption= "⭐️ Download the subtitle file and unzip manually or Use @UnzipTGBot for unzipping this zip file ✌\n\n©Author : @BotolBaba\n©Copyright : @SubWorldBot\n©Sub From : @iSubtitles" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [[ InlineKeyboardButton( "Our Group", url="https://telegram.dog/discussion_movies_box_official"), InlineKeyboardButton("Our Channel", url="https://telegram.dog/movies_box_official") ]] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption= "©️ @GetSubtitles_bot\n\nUse @UnzipTGBot for unzipping this zip file or download the file and unzip manually" ) ] update.inline_query.answer(results)
def inlinequery(update, context): query = update.inline_query.query inline = [[ InlineKeyboardButton( "👥 Our Group", url="https://telegram.dog/joinchat/MFPEc0YRiJqBFvYUtPgNVQ"), InlineKeyboardButton("⚡ Our Channel", url="https://telegram.dog/TSNM_CHNLS") ]] results = [ InlineQueryResultDocument( id=uuid4(), document_url=query, title="🔘 Get the File", mime_type="application/zip", reply_markup=InlineKeyboardMarkup(inline), caption= "©️ @TSNM_CHNLS \n\nUse Any Unzip bot for unzipping this zip file or download the file and unzip manually" ) ] update.inline_query.answer(results)