def answer(client, inline_query): inline_query.answer(results=[ InlineQueryResultArticle( id=uuid4(), title="Installation", input_message_content=InputTextMessageContent( "Here's how to install **Pyrogram**"), url="https://docs.pyrogram.ml/start/Installation", description="How to install Pyrogram", thumb_url="https://i.imgur.com/JyxrStE.png", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( "Open website", url="https://docs.pyrogram.ml/start/Installation") ]])), InlineQueryResultArticle( id=uuid4(), title="Usage", input_message_content=InputTextMessageContent( "Here's how to use **Pyrogram**"), url="https://docs.pyrogram.ml/start/Usage", description="How to use Pyrogram", thumb_url="https://i.imgur.com/JyxrStE.png", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( "Open website", url="https://docs.pyrogram.ml/start/Usage") ]])) ], cache_time=1)
def inelene(client, i_q): kelime = i_q.query if len(kelime) == 0: client.answer_inline_query( i_q.id, results=[ InlineQueryResultArticle( "Lütfen Kelime Giriniz", InputTextMessageContent("Lütfen kelime giriniz"), thumb_url="https://i.imgur.com/2kVCU8Z.jpeg", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="İnline Moda Geç", switch_inline_query_current_chat="") ]])) ]) else: fonk = tdk_fonk(kelime) if fonk[0] == False: client.answer_inline_query( i_q.id, results=[ InlineQueryResultArticle( fonk[1], InputTextMessageContent("Kelime Bulunamadı."), thumb_url="https://i.imgur.com/2kVCU8Z.jpeg", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="İnline Moda Geç", switch_inline_query_current_chat="") ]])) ]) elif fonk[0]: client.answer_inline_query( i_q.id, results=[ InlineQueryResultArticle( kelime, InputTextMessageContent(fonk[1]), description=fonk[2][0], thumb_url="https://i.imgur.com/2kVCU8Z.jpeg", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="İnline Moda Geç", switch_inline_query_current_chat="") ]])) ])
def veg(user_id: int = 0, price: int = 0): if price: text = InputTextMessageContent('/acnh veg {price}'.format(price=price)) short = '更新大頭菜價格' else: text = InputTextMessageContent( '請先空格後再輸入正確的價格。\n例:`@NintendoFCode_bot acnh veg 153`') short = '請先空格後再輸入正確的價格。' money_icon = configure.get('ACNH', 'money') result = [ InlineQueryResultArticle(input_message_content=text, title=short, thumb_url=money_icon) ] return result
def myacnh(user: users): pics = 'https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/237/rightwards-arrow-with-hook_21aa.png' result = list() # 文字拼拼 text = '#動物森友 #AnimalCrossing\n' \ '島名:<code>{island}</code>\n' \ '特產:#{fruit}\n'.format( island=escape(user.acnh.name), fruit=user.acnh.fruit ) if user.acnh.veg: text += '大頭菜價格:<code>{price}</code> 鈴錢\n'.format( price=user.acnh.veg[-1].price) if not user.privacy: text += '好友代碼:<code>{fcode}</code>'.format(fcode=user.fcode) else: text += '因為[隱私設定]({url})因此不顯示好友代碼。'.format( url='t.me/NintendoFCode_bot?start=privacy') text = InputTextMessageContent(text, disable_web_page_preview=True) result.append( InlineQueryResultArticle(input_message_content=text, title='分享我的動物森友會資訊', thumb_url='{pics}'.format(pics=pics), reply_markup=keyboard.bindacnh(visble=True))) return result
def generatereply(query: list) -> List[InlineQueryResultArticle]: """ Generate the response to the inline query. Returns: - list[InlineQueryResultArticle] """ anslist = [] # List of inlinequeryanswer if query[0] == 'group': # Search for groups if the firstword of query is 'group' for i in listgrps(query[1]): _ = tagsingroup(i) tags = _[1] desc = _[0] # Acquire info of the group length = grouplength(i) text = "\n".join(tags) anslist.append( InlineQueryResultArticle( # Add a result to anslist title=f'Tag Group {i} {length} tags', description=desc, input_message_content=InputTextMessageContent( message_text=f'Tags:\n{text}'))) else: pattern = query[0] argv = query[1:] if len(query) > 0 else [] for i in listtags(pattern): # Acquire tag info cmd = getsnippet(i) command = replace_keyword(cmd[0], argv) desc = cmd[1] credit = cmd[2] anslist.append( InlineQueryResultArticle( title=i, description=desc, input_message_content=InputTextMessageContent( message_text=cmd_format_template.format( i, get_user_name(credit), desc, command)))) if len(anslist) == 0: anslist.append( InlineQueryResultArticle( title=f'No result of {query}', input_message_content=InputTextMessageContent( f'No results found: {query}'))) return anslist
async def inline_query_handler(client, query): string = query.query.lower() answers = [] if query.from_user.id != Owner: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Sorry, this bot only for {}".format(OwnerName), switch_pm_parameter="createown" ) return if string == "": await client.answer_inline_query(query.id, results=answers, switch_pm_text="Need help? Click here", switch_pm_parameter="help" ) return if string.split()[0] == "#note": q = string.split(None, 1) notetag = q[1] noteval = notes_db.get_selfnote(query.from_user.id, notetag) if not noteval: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Note not found!", switch_pm_parameter="help" ) return note, button = parse_button(noteval.get('value')) button = build_keyboard(button) answers.append(InlineQueryResultArticle( id=uuid4(), title="Note #{}".format(notetag), input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) try: await client.answer_inline_query(query.id, results=answers, cache_time=5, ) except errors.exceptions.bad_request_400.MessageEmpty: exc_type, exc_obj, exc_tb = sys.exc_info() log_errors = traceback.format_exception(etype=exc_type, value=exc_obj, tb=exc_tb) button = InlineKeyboardMarkup([[InlineKeyboardButton("🐞 Report bugs", callback_data="report_errors")]]) text = "An error has accured!\n\n```{}```\n".format("".join(log_errors)) await setbot.send_message(Owner, text, reply_markup=button) return await client.answer_inline_query(query.id, results=answers, switch_pm_text="Need help? Click here", switch_pm_parameter="help" )
def bindgame(): base_url = configure.get('statics', 'base_url') result = list() for game in gamelist(): text = InputTextMessageContent( '/bindgame {short}'.format(short=game.short)) keyboard = InlineQueryResultArticle( input_message_content=text, title=game.name, thumb_url='{base_url}{pics}'.format(base_url=base_url, pics=game.pics)) result.append(keyboard) return result
def __new__(cls, item): return InlineQueryResultArticle( title=f"{item.__class__.__name__}", description=f"Filter - {item.__class__.__name__}", input_message_content=InputTextMessageContent( f"{Emoji.CONTROL_KNOBS} **Pyrogram Docs**\n\n" f"[{item.__class__.__name__}]({cls.DOCS.format(item.__class__.__name__.lower())}) - Filter", disable_web_page_preview=True, ), thumb_url=cls.THUMB, )
async def inline_answer(_, inline_query: InlineQuery): results = [ InlineQueryResultArticle( id=uuid4(), title="Repo", input_message_content=InputTextMessageContent( "**Here's how to setup Userge** 😎" ), url="https://github.com/UsergeTeam/Userge", description="Setup Your Own", thumb_url="https://imgur.com/download/Inyeb1S", reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton( "🧰 Userge Repo", url="https://github.com/UsergeTeam/Userge"), InlineKeyboardButton( "🖥 Deploy Userge", url=("https://heroku.com/deploy?template=" "https://github.com/UsergeTeam/Userge/tree/master")) ] ] ) ) ] if inline_query.from_user and inline_query.from_user.id == Config.OWNER_ID: results.append( InlineQueryResultArticle( id=uuid4(), title="Main Menu", input_message_content=InputTextMessageContent( "🖥 **Userge Main Menu** 🖥" ), url="https://github.com/UsergeTeam/Userge", description="Userge Main Menu", thumb_url="https://imgur.com/download/Inyeb1S", reply_markup=InlineKeyboardMarkup(main_menu_buttons()) ) ) await inline_query.answer(results=results, cache_time=1)
def __new__(cls, item): a, b = item.__qualname__.split(".") return InlineQueryResultArticle( title=f"{item.__qualname__}", description=f'Bound Method "{b}" of {a}', input_message_content=InputTextMessageContent( f"{Emoji.LEDGER} **Pyrogram Docs**\n\n" f"[{item.__qualname__}]({cls.DOCS.format(a, b)}) - Bound Method", disable_web_page_preview=True, ), thumb_url=cls.THUMB, )
def __new__(cls, item): short, full = Result.get_description(item) return InlineQueryResultArticle( title=f"{item.__name__}", description="Type - " + short, input_message_content=InputTextMessageContent( f"{Emoji.GREEN_BOOK} **Pyrogram Docs**\n\n" f"[{item.__name__}]({cls.DOCS.format(item.__name__)}) - Type\n\n" f"`{full}`", disable_web_page_preview=True, ), thumb_url=cls.THUMB, )
def __new__(cls, item): short, full = Result.get_description(item) return InlineQueryResultArticle( id=uuid4(), title=f"{item.__name__}", description="Decorator - " + short, input_message_content=InputTextMessageContent( f"{Emoji.ARTIST_PALETTE} **Pyrogram Docs**\n\n" f"[{item.__name__}]({cls.DOCS.format(item.__name__)}) - Decorator\n\n" f"`{full}`\n", disable_web_page_preview=True, ), thumb_url=cls.THUMB, )
def __new__(cls, item): constructor_id = hex(item[1].ID) return InlineQueryResultArticle( id=uuid4(), title=f"{item[0]}", description=f"Raw Type - {constructor_id}\nSchema: Layer {layer}", input_message_content=InputTextMessageContent( f"{Emoji.ORANGE_BOOK} **Pyrogram Docs**\n\n" f"[{item[0]}]({cls.DOCS.format('/'.join(item[0].split('.')))}) - Raw Type\n\n" f"`ID`: **{constructor_id}**\n" f"`Schema`: **Layer {layer}**", disable_web_page_preview=True, ), thumb_url=cls.THUMB, )
async def translate_inline(_client: Client, query: InlineQuery): query_text = query.query language = await detect(query_text) native_language = get_native_language(query.from_user.id) if not native_language: return await query.answer( results=[], switch_pm_text="No selected language, press here.", switch_pm_parameter="cl") translate_result = await translate(language, native_language, query_text) await query.answer(results=[ InlineQueryResultArticle(title=f'Translated to {language}', description=translate_result[0], input_message_content=InputTextMessageContent( translate_result[0])) ])
def answer_inline_query(_, i: InlineQuery): faqs = _search_title(i) if not faqs: i.answer(results=[], switch_pm_text='❌ nothing to show! ❌', switch_pm_parameter='start') else: i.answer(results=[ InlineQueryResultArticle( title=title, input_message_content=InputTextMessageContent( message_text=f"[{title}]({url})", disable_web_page_preview=False), thumb_url='https://imgur.com/BXXK3Nj.png') for title, url in faqs ], cache_time=10)
def __new__(cls, item): constructor_id = hex(item[1].ID) path = cls.DOCS.format( Result.snek(item[0]).replace("_", "-").replace(".-", "/")) return InlineQueryResultArticle( title=f"{item[0]}", description= f"Raw Type - {constructor_id}\nSchema: Layer {layer}", input_message_content=InputTextMessageContent( f"{Emoji.ORANGE_BOOK} **Pyrogram Docs**\n\n" f"[{item[0]}]({path}) - Raw Type\n\n" f"`ID`: **{constructor_id}**\n" f"`Schema`: **Layer {layer}**", disable_web_page_preview=True, ), thumb_url=cls.THUMB, )
def bindacnh(callback_query: CallbackQuery): data = callback_query.query.split() hint = len(data) result = list() if hint <= 3: long, short = get_hint(hint) else: island = data[2] fruit = data[3] if fruit not in ['梨子', '櫻桃', '蘋果', '桃子', '橘子']: short = '水果種類有誤,請檢查下狸!' long = short + '\n每個人島上的水果特產種類應該是 「梨子、櫻桃、蘋果、桃子、橘子」 其中一種喔!' else: long = '/bindgame acnh -n {name} -f {fruit}'.format(name=island, fruit=fruit) short = '輸入好的話就點我吧狸!' text = InputTextMessageContent(long) keyboard = InlineQueryResultArticle(input_message_content=text, title=short) result.append(keyboard) return result
f"**__List__**\n" f"`@pyrogrambot !m` – Methods\n" f"`@pyrogrambot !t` – Types\n" f"`@pyrogrambot !f` – Filters\n" f"`@pyrogrambot !b` – Bound Methods\n" f"`@pyrogrambot !d` – Decorators\n" f"`@pyrogrambot !rm` – Raw Methods\n" f"`@pyrogrambot !rt` – Raw Types\n\n") DEFAULT_RESULTS = [ InlineQueryResultArticle( title="About Pyrogram", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram**\n\n" f"Pyrogram is an elegant, easy-to-use Telegram client library and framework written from the ground up in " f"Python and C. It enables you to easily create custom apps using both user and bot identities (bot API " f"alternative) via the MTProto API.", disable_web_page_preview=True, ), reply_markup=InlineKeyboardMarkup( [[ InlineKeyboardButton(f"{Emoji.BUSTS_IN_SILHOUETTE} Community", url="https://t.me/pyrogram") ], [ InlineKeyboardButton(f"{Emoji.CARD_INDEX_DIVIDERS} GitHub", url="https://github.com/pyrogram"), InlineKeyboardButton(f"{Emoji.OPEN_BOOK} Docs", url="https://docs.pyrogram.org") ]]), description=
async def inline_query_handler(client, query): string = query.query.lower() answers = [] if query.from_user.id != Owner: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Sorry, this bot only for {}".format(OwnerName), switch_pm_parameter="createown") return if string == "": await client.answer_inline_query( query.id, results=answers, switch_pm_text="Need help? Click here", switch_pm_parameter="help_inline") return # Notes if string.split()[0] == "#note": if not DB_AVAIABLE: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Your database isn't avaiable!", switch_pm_parameter="help_inline") return if len(string.split()) == 1: allnotes = notes_db.get_all_selfnotes_inline(query.from_user.id) if not allnotes: await client.answer_inline_query( query.id, results=answers, switch_pm_text="You dont have any notes!", switch_pm_parameter="help_inline") return if len(list(allnotes)) >= 30: rng = 30 else: rng = len(list(allnotes)) for x in range(rng): note = allnotes[list(allnotes)[x]] noteval = note["value"] notetype = note["type"] # notefile = note["file"] if notetype != Types.TEXT: continue note, button = parse_button(noteval) button = build_keyboard(button) answers.append( InlineQueryResultArticle( title="Note #{}".format(list(allnotes)[x]), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, switch_pm_text="Yourself notes", switch_pm_parameter="help_inline") return q = string.split(None, 1) notetag = q[1] noteval = notes_db.get_selfnote(query.from_user.id, notetag) if not noteval: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Note not found!", switch_pm_parameter="help_inline") return note, button = parse_button(noteval.get('value')) button = build_keyboard(button) answers.append( InlineQueryResultArticle( title="Note #{}".format(notetag), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) try: await client.answer_inline_query( query.id, results=answers, cache_time=5, ) except errors.exceptions.bad_request_400.MessageEmpty: exc_type, exc_obj, exc_tb = sys.exc_info() log_errors = traceback.format_exception(etype=exc_type, value=exc_obj, tb=exc_tb) button = InlineKeyboardMarkup([[ InlineKeyboardButton("🐞 Report bugs", callback_data="report_errors") ]]) text = "An error has accured!\n\n```{}```\n".format( "".join(log_errors)) await setbot.send_message(Owner, text, reply_markup=button) return # Stylish converter elif string.split()[0] == "#stylish": if len(string.split()) == 1: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Insert any text to convert it!", switch_pm_parameter="help_inline") return text = string.split(None, 1)[1] upside = upsidedown_text_inline(text) answers.append( InlineQueryResultArticle( title=upside, description="Upside-down Text", input_message_content=InputTextMessageContent(upside))) over = text_style_generator(text, CHAR_OVER) answers.append( InlineQueryResultArticle( title=over, description="Overline Text", input_message_content=InputTextMessageContent(over))) under = text_style_generator(text, CHAR_UNDER) answers.append( InlineQueryResultArticle( title=under, description="Underline Text", input_message_content=InputTextMessageContent(under))) strike = text_style_generator(text, CHAR_STRIKE) answers.append( InlineQueryResultArticle( title=strike, description="Strike Text", input_message_content=InputTextMessageContent(strike))) points = text_style_generator(text, CHAR_POINTS) answers.append( InlineQueryResultArticle( title=points, description="Points Text", input_message_content=InputTextMessageContent(points))) smallcaps_conv = formatting_text_inline(text, smallcaps) answers.append( InlineQueryResultArticle( title=smallcaps_conv, description="Smallcaps Text", input_message_content=InputTextMessageContent(smallcaps_conv))) super_script = formatting_text_inline(text, superscript) answers.append( InlineQueryResultArticle( title=super_script, description="Superscript Text", input_message_content=InputTextMessageContent(super_script))) sub_script = formatting_text_inline(text, subscript) answers.append( InlineQueryResultArticle( title=sub_script, description="Subscript Text", input_message_content=InputTextMessageContent(sub_script))) wide_text = formatting_text_inline(text, wide) answers.append( InlineQueryResultArticle( title=wide_text, description="Wide Text", input_message_content=InputTextMessageContent(wide_text))) bubbles_text = formatting_text_inline(text, bubbles) answers.append( InlineQueryResultArticle( title=bubbles_text, description="Bubbles Text", input_message_content=InputTextMessageContent(bubbles_text))) bubblesblack_text = formatting_text_inline(text, bubblesblack) answers.append( InlineQueryResultArticle( title=bubblesblack_text, description="Bubbles Black Text", input_message_content=InputTextMessageContent( bubblesblack_text))) smoth_text = formatting_text_inline(text, smothtext) answers.append( InlineQueryResultArticle( title=smoth_text, description="Smoth Text", input_message_content=InputTextMessageContent(smoth_text))) await client.answer_inline_query( query.id, results=answers, switch_pm_text="Converted to stylish text", switch_pm_parameter="help_inline") return await client.answer_inline_query(query.id, results=answers, switch_pm_text="Need help? Click here", switch_pm_parameter="help_inline")
async def inline(bot: Assistant, query: InlineQuery): string = query.query.lower() if string == "": await query.answer( results=docs.DEFAULT_RESULTS, cache_time=CACHE_TIME, switch_pm_text= f"{Emoji.MAGNIFYING_GLASS_TILTED_RIGHT} Type to search Pyrogram Docs", switch_pm_parameter="start", ) return results = [] offset = int(query.offset or 0) switch_pm_text = f"{Emoji.OPEN_BOOK} Pyrogram Docs" if string == "!m": switch_pm_text = f"{Emoji.CLOSED_BOOK} Pyrogram Methods ({len(docs.METHODS)})" if offset == 0: results.append( InlineQueryResultArticle( id=uuid4(), title="Methods", description="Pyrogram Methods online documentation page", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram Methods**\n\n" f"`This page contains all available high-level Methods existing in Pyrogram v{VERSION}.`" ), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( f"{Emoji.OPEN_BOOK} Online docs", url="https://docs.pyrogram.org/api/methods") ]]), thumb_url=FIRE_THUMB, )) for i in docs.METHODS[offset:offset + NEXT_OFFSET]: results.append(i[1]) elif string == "!t": switch_pm_text = f"{Emoji.GREEN_BOOK} Pyrogram Types ({len(docs.TYPES)})" if offset == 0: results.append( InlineQueryResultArticle( id=uuid4(), title="Types", description="Pyrogram Types online documentation page", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram Types**\n\n" f"`This page contains all available high-level Types existing in Pyrogram v{VERSION}.`" ), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( f"{Emoji.OPEN_BOOK} Online docs", url="https://docs.pyrogram.org/api/types") ]]), thumb_url=FIRE_THUMB, )) for i in docs.TYPES[offset:offset + NEXT_OFFSET]: results.append(i[1]) elif string == "!b": switch_pm_text = f"{Emoji.CLOSED_BOOK} Pyrogram Bound Methods ({len(docs.BOUND_METHODS)})" if offset == 0: results.append( InlineQueryResultArticle( id=uuid4(), title="Types", description= "Pyrogram Bound Methods online documentation page", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram Bound Methods**\n\n" f"`This page contains all available bound methods existing in Pyrogram v{VERSION}.`" ), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( f"{Emoji.OPEN_BOOK} Online docs", url="https://docs.pyrogram.org/api/bound-methods") ]]), thumb_url=FIRE_THUMB, )) for i in docs.BOUND_METHODS[offset:offset + NEXT_OFFSET]: results.append(i[1]) elif string == "!d": switch_pm_text = f"{Emoji.CLOSED_BOOK} Pyrogram Decorators ({len(docs.DECORATORS)})" if offset == 0: results.append( InlineQueryResultArticle( id=uuid4(), title="Decorators", description="Pyrogram Decorators online documentation page", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram Decorators**\n\n" f"`This page contains all available decorators existing in Pyrogram v{VERSION}.`" ), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( f"{Emoji.OPEN_BOOK} Online docs", url="https://docs.pyrogram.org/api/decorators") ]]), thumb_url=FIRE_THUMB, )) for i in docs.DECORATORS[offset:offset + NEXT_OFFSET]: results.append(i[1]) elif string == "!f": switch_pm_text = f"{Emoji.CONTROL_KNOBS} Pyrogram Filters ({len(docs.FILTERS)})" if offset == 0: results.append( InlineQueryResultArticle( id=uuid4(), title="Filters", description="Pyrogram Filters online documentation page", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram Filters**\n\n" f"`This page contains all library-defined Filters available in Pyrogram v{VERSION}.`" ), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( f"{Emoji.OPEN_BOOK} Online docs", url="https://docs.pyrogram.org/api/filters") ]]), thumb_url=FIRE_THUMB, )) for i in docs.FILTERS[offset:offset + NEXT_OFFSET]: results.append(i[1]) elif string == "!rm": switch_pm_text = f"{Emoji.BLUE_BOOK} Raw Methods ({len(docs.RAW_METHODS)})" if offset == 0: results.append( InlineQueryResultArticle( id=uuid4(), title="Raw Methods", description= "Pyrogram Raw Methods online documentation page", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram Raw Methods**\n\n" f"`This page contains all available Raw Methods existing in the Telegram Schema, Layer `" f"`{docs.layer}.`"), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( f"{Emoji.OPEN_BOOK} Online docs", url="https://docs.pyrogram.org/telegram/functions" ), InlineKeyboardButton( f"{Emoji.SCROLL} TL Schema", url= "https://github.com/pyrogram/pyrogram/blob/develop/compiler/api/source/main_api.tl" ), ]]), thumb_url=FIRE_THUMB, )) for i in docs.RAW_METHODS[offset:offset + NEXT_OFFSET]: results.append(i[1]) elif string == "!rt": switch_pm_text = f"{Emoji.ORANGE_BOOK} Raw Types ({len(docs.RAW_TYPES)})" if offset == 0: results.append( InlineQueryResultArticle( id=uuid4(), title="Raw Types", description="Pyrogram Raw Types online documentation page", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram Raw Types**\n\n" f"`This page contains all available Raw Types existing in the Telegram Schema, Layer {docs.layer}.`" ), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( f"{Emoji.OPEN_BOOK} Online docs", url="https://docs.pyrogram.org/telegram/types"), InlineKeyboardButton( f"{Emoji.SCROLL} TL Schema", url= "https://github.com/pyrogram/pyrogram/blob/develop/compiler/api/source/main_api.tl", ), ]]), thumb_url=FIRE_THUMB, )) for i in docs.RAW_TYPES[offset:offset + NEXT_OFFSET]: results.append(i[1]) if results: await query.answer( results=results, cache_time=CACHE_TIME, switch_pm_text=switch_pm_text, switch_pm_parameter="start", next_offset=str(offset + NEXT_OFFSET), ) else: if offset: await query.answer( results=[], cache_time=CACHE_TIME, switch_pm_text=switch_pm_text, switch_pm_parameter="start", next_offset="", ) if string.startswith("!r"): string = " ".join(string.split(" ")[1:]) if string == "": await query.answer( results=[], cache_time=CACHE_TIME, switch_pm_text= f"{Emoji.MAGNIFYING_GLASS_TILTED_RIGHT} Type to search Raw Docs", switch_pm_parameter="start", ) for i in docs.RAW_METHODS: if string in i[0].lower(): results.append(i[1]) for i in docs.RAW_TYPES: if string in i[0].lower(): results.append(i[1]) else: for i in docs.METHODS: if string in i[0].lower(): results.append(i[1]) for i in docs.TYPES: if string in i[0].lower(): results.append(i[1]) for i in docs.BOUND_METHODS: if string in i[0].lower(): results.append(i[1]) for i in docs.DECORATORS: if string in i[0].lower(): results.append(i[1]) for i in docs.FILTERS: if string in i[0].lower(): results.append(i[1]) if results: count = len(results) switch_pm_text = f"{Emoji.OPEN_BOOK} {count} Result{'s' if count > 1 else ''} for \"{string}\"" await query.answer(results=results[:50], cache_time=CACHE_TIME, switch_pm_text=switch_pm_text, switch_pm_parameter="start") else: await query.answer( results=[], cache_time=CACHE_TIME, switch_pm_text=f'{Emoji.CROSS_MARK} No results for "{string}"', switch_pm_parameter="okay", )
async def inline_query_handler(client, query): string = query.query.lower() answers = [] if query.from_user.id not in AdminSettings: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Sorry, this bot only for {}".format(OwnerName), switch_pm_parameter="createown") return if string == "": await client.answer_inline_query( query.id, results=answers, switch_pm_text="Need help? Click here", switch_pm_parameter="help_inline") return # Notes if string.split()[0] == "note": if not DB_AVAILABLE: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Your database isn't avaiable!", switch_pm_parameter="help_inline") return if len(string.split()) == 1: allnotes = notes_db.get_all_selfnotes_inline(query.from_user.id) if not allnotes: await client.answer_inline_query( query.id, results=answers, switch_pm_text="You dont have any notes!", switch_pm_parameter="help_inline") return if len(list(allnotes)) >= 30: rng = 30 else: rng = len(list(allnotes)) for x in range(rng): note = allnotes[list(allnotes)[x]] noteval = note["value"] notetype = note["type"] # notefile = note["file"] if notetype != Types.TEXT: continue note, button = parse_button(noteval) button = build_keyboard(button) answers.append( InlineQueryResultArticle( title="Note #{}".format(list(allnotes)[x]), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, switch_pm_text="Yourself notes", switch_pm_parameter="help_inline") return q = string.split(None, 1) notetag = q[1] noteval = notes_db.get_selfnote(query.from_user.id, notetag) if not noteval: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Note not found!", switch_pm_parameter="help_inline") return note, button = parse_button(noteval.get('value')) button = build_keyboard(button) answers.append( InlineQueryResultArticle( title="Note #{}".format(notetag), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) try: await client.answer_inline_query(query.id, results=answers, cache_time=5) except errors.exceptions.bad_request_400.MessageEmpty: exc_type, exc_obj, exc_tb = sys.exc_info() log_errors = traceback.format_exception(etype=exc_type, value=exc_obj, tb=exc_tb) button = InlineKeyboardMarkup([[ InlineKeyboardButton("🐞 Report bugs", callback_data="report_errors") ]]) text = "An error has accured!\n\n```{}```\n".format( "".join(log_errors)) await setbot.send_message(Owner, text, reply_markup=button) return # Stylish converter elif string.split()[0] == "stylish": if len(string.split()) == 1: await client.answer_inline_query( query.id, results=answers, switch_pm_text="Insert any text to convert it!", switch_pm_parameter="help_inline") return text = string.split(None, 1)[1] upside = upsidedown_text_inline(text) answers.append( InlineQueryResultArticle( title=upside, description="Upside-down Text", input_message_content=InputTextMessageContent(upside))) over = text_style_generator(text, CHAR_OVER) answers.append( InlineQueryResultArticle( title=over, description="Overline Text", input_message_content=InputTextMessageContent(over))) under = text_style_generator(text, CHAR_UNDER) answers.append( InlineQueryResultArticle( title=under, description="Underline Text", input_message_content=InputTextMessageContent(under))) strike = text_style_generator(text, CHAR_STRIKE) answers.append( InlineQueryResultArticle( title=strike, description="Strike Text", input_message_content=InputTextMessageContent(strike))) points = text_style_generator(text, CHAR_POINTS) answers.append( InlineQueryResultArticle( title=points, description="Points Text", input_message_content=InputTextMessageContent(points))) smallcaps_conv = formatting_text_inline(text, smallcaps) answers.append( InlineQueryResultArticle( title=smallcaps_conv, description="Smallcaps Text", input_message_content=InputTextMessageContent(smallcaps_conv))) super_script = formatting_text_inline(text, superscript) answers.append( InlineQueryResultArticle( title=super_script, description="Superscript Text", input_message_content=InputTextMessageContent(super_script))) sub_script = formatting_text_inline(text, subscript) answers.append( InlineQueryResultArticle( title=sub_script, description="Subscript Text", input_message_content=InputTextMessageContent(sub_script))) wide_text = formatting_text_inline(text, wide) answers.append( InlineQueryResultArticle( title=wide_text, description="Wide Text", input_message_content=InputTextMessageContent(wide_text))) bubbles_text = formatting_text_inline(text, bubbles) answers.append( InlineQueryResultArticle( title=bubbles_text, description="Bubbles Text", input_message_content=InputTextMessageContent(bubbles_text))) bubblesblack_text = formatting_text_inline(text, bubblesblack) answers.append( InlineQueryResultArticle( title=bubblesblack_text, description="Bubbles Black Text", input_message_content=InputTextMessageContent( bubblesblack_text))) smoth_text = formatting_text_inline(text, smothtext) answers.append( InlineQueryResultArticle( title=smoth_text, description="Smoth Text", input_message_content=InputTextMessageContent(smoth_text))) graffiti_text = formatting_text_inline(text, graffiti) answers.append( InlineQueryResultArticle( title=graffiti_text, description="Graffiti Text", input_message_content=InputTextMessageContent(graffiti_text))) graffitib_text = formatting_text_inline(text, graffitib) answers.append( InlineQueryResultArticle( title=graffitib_text, description="Graffiti Bold Text", input_message_content=InputTextMessageContent(graffitib_text))) handwriting_text = formatting_text_inline(text, handwriting) answers.append( InlineQueryResultArticle( title=handwriting_text, description="Handwriting Text", input_message_content=InputTextMessageContent( handwriting_text))) handwritingb_text = formatting_text_inline(text, handwritingb) answers.append( InlineQueryResultArticle( title=handwritingb_text, description="Handwriting Bold Text", input_message_content=InputTextMessageContent( handwritingb_text))) await client.answer_inline_query( query.id, results=answers, switch_pm_text="Converted to stylish text", switch_pm_parameter="help_inline") # PM_PERMIT elif string.split()[0] == "engine_pm": button = [[ InlineKeyboardButton("Ask for Money", callback_data="engine_pm_block"), InlineKeyboardButton("Contact me", callback_data="engine_pm_nope") ], [ InlineKeyboardButton("Report", callback_data="engine_pm_report"), InlineKeyboardButton("Passing by", callback_data="engine_pm_none") ]] random.shuffle(button) answers.append( InlineQueryResultArticle( title="Engine pm", description="Filter pm", input_message_content=InputTextMessageContent( welc_txt, parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "speedtest": buttons = [[ InlineKeyboardButton("Image", callback_data="speedtest_image"), InlineKeyboardButton("Text", callback_data="speedtest_text") ]] answers.append( InlineQueryResultArticle( title="Speed Test", description="test your speed", input_message_content=InputTextMessageContent( "Select SpeedTest Mode", parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "alive": repo = git.Repo(os.getcwd()) master = repo.head.reference commit_id = master.commit.hexsha commit_link = f"[{commit_id[:7]}](https://github.com/pokurt/Nana-Remix/commit/{commit_id})" try: me = await app.get_me() except ConnectionError: me = None text = f"**[Nana-Remix](https://github.com/pokurt/Nana-Remix) Running on {commit_link}:**\n" if not me: text += f" - **Bot**: `stopped (v{USERBOT_VERSION})`\n" else: text += f" - **Bot**: `alive (v{USERBOT_VERSION})`\n" text += f" - **Pyrogram**: `{__version__}`\n" text += f" - **Python**: `{python_version()}`\n" text += f" - **Database**: `{DB_AVAILABLE}`\n" buttons = [[ InlineKeyboardButton("stats", callback_data="alive_message") ]] answers.append( InlineQueryResultArticle( title="Alive", description="Nana Userbot", input_message_content=InputTextMessageContent( text, parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) elif string.split()[0] == "anime": search = string.split(None, 1)[1] variables = {'search': search} json = requests.post(url, json={ 'query': anime_query, 'variables': variables }).json()['data'].get('Media', None) if json: msg = f"**{json['title']['romaji']}** (`{json['title']['native']}`)\n**Type**: {json['format']}\n**Status**: {json['status']}\n**Episodes**: {json.get('episodes', 'N/A')}\n**Duration**: {json.get('duration', 'N/A')} Per Ep.\n**Score**: {json['averageScore']}\n**Genres**: `" for x in json['genres']: msg += f"{x}, " msg = msg[:-2] + '`\n' msg += "**Studios**: `" for x in json['studios']['nodes']: msg += f"{x['name']}, " msg = msg[:-2] + '`\n' info = json.get('siteUrl') trailer = json.get('trailer', None) if trailer: trailer_id = trailer.get('id', None) site = trailer.get('site', None) if site == "youtube": trailer = 'https://youtu.be/' + trailer_id description = json.get('description', 'N/A').replace('<i>', '').replace( '</i>', '').replace('<br>', '') msg += shorten(description, info) image = json.get('bannerImage', None) if trailer: buttons = [[ InlineKeyboardButton("More Info", url=info), InlineKeyboardButton("Trailer 🎬", url=trailer) ]] else: buttons = [[InlineKeyboardButton("More Info", url=info)]] if image: answers.append( InlineQueryResultPhoto( caption=msg, photo_url=image, parse_mode="markdown", title=f"{json['title']['romaji']}", description=f"{json['format']}", reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) else: answers.append( InlineQueryResultArticle( title=f"{json['title']['romaji']}", description=f"{json['averageScore']}", input_message_content=InputTextMessageContent( msg, parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0) return
async def inline_query_handler(client, query): string = query.query.lower() answers = [] if query.from_user.id != Owner: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Sorry, this bot only for {}".format(OwnerName), switch_pm_parameter="createown" ) return if string == "": await client.answer_inline_query(query.id, results=answers, switch_pm_text="Need help? Click here", switch_pm_parameter="help_inline" ) return # Notes if string.split()[0] == "note": if not DB_AVAILABLE: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Your database isn't avaiable!", switch_pm_parameter="help_inline" ) return if len(string.split()) == 1: allnotes = notes_db.get_all_selfnotes_inline(query.from_user.id) if not allnotes: await client.answer_inline_query(query.id, results=answers, switch_pm_text="You dont have any notes!", switch_pm_parameter="help_inline" ) return if len(list(allnotes)) >= 30: rng = 30 else: rng = len(list(allnotes)) for x in range(rng): note = allnotes[list(allnotes)[x]] noteval = note["value"] notetype = note["type"] # notefile = note["file"] if notetype != Types.TEXT: continue note, button = parse_button(noteval) button = build_keyboard(button) answers.append(InlineQueryResultArticle( title="Note #{}".format(list(allnotes)[x]), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, switch_pm_text="Yourself notes", switch_pm_parameter="help_inline" ) return q = string.split(None, 1) notetag = q[1] noteval = notes_db.get_selfnote(query.from_user.id, notetag) if not noteval: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Note not found!", switch_pm_parameter="help_inline" ) return note, button = parse_button(noteval.get('value')) button = build_keyboard(button) answers.append(InlineQueryResultArticle( title="Note #{}".format(notetag), description=note, input_message_content=InputTextMessageContent(note), reply_markup=InlineKeyboardMarkup(button))) try: await client.answer_inline_query(query.id, results=answers, cache_time=5 ) except errors.exceptions.bad_request_400.MessageEmpty: exc_type, exc_obj, exc_tb = sys.exc_info() log_errors = traceback.format_exception(etype=exc_type, value=exc_obj, tb=exc_tb) button = InlineKeyboardMarkup([[InlineKeyboardButton("🐞 Report bugs", callback_data="report_errors")]]) text = "An error has accured!\n\n```{}```\n".format("".join(log_errors)) await setbot.send_message(Owner, text, reply_markup=button) return # Stylish converter elif string.split()[0] == "stylish": if len(string.split()) == 1: await client.answer_inline_query(query.id, results=answers, switch_pm_text="Insert any text to convert it!", switch_pm_parameter="help_inline" ) return text = string.split(None, 1)[1] upside = upsidedown_text_inline(text) answers.append(InlineQueryResultArticle( title=upside, description="Upside-down Text", input_message_content=InputTextMessageContent(upside))) over = text_style_generator(text, CHAR_OVER) answers.append(InlineQueryResultArticle( title=over, description="Overline Text", input_message_content=InputTextMessageContent(over))) under = text_style_generator(text, CHAR_UNDER) answers.append(InlineQueryResultArticle( title=under, description="Underline Text", input_message_content=InputTextMessageContent(under))) strike = text_style_generator(text, CHAR_STRIKE) answers.append(InlineQueryResultArticle( title=strike, description="Strike Text", input_message_content=InputTextMessageContent(strike))) points = text_style_generator(text, CHAR_POINTS) answers.append(InlineQueryResultArticle( title=points, description="Points Text", input_message_content=InputTextMessageContent(points))) smallcaps_conv = formatting_text_inline(text, smallcaps) answers.append(InlineQueryResultArticle( title=smallcaps_conv, description="Smallcaps Text", input_message_content=InputTextMessageContent(smallcaps_conv))) super_script = formatting_text_inline(text, superscript) answers.append(InlineQueryResultArticle( title=super_script, description="Superscript Text", input_message_content=InputTextMessageContent(super_script))) sub_script = formatting_text_inline(text, subscript) answers.append(InlineQueryResultArticle( title=sub_script, description="Subscript Text", input_message_content=InputTextMessageContent(sub_script))) wide_text = formatting_text_inline(text, wide) answers.append(InlineQueryResultArticle( title=wide_text, description="Wide Text", input_message_content=InputTextMessageContent(wide_text))) bubbles_text = formatting_text_inline(text, bubbles) answers.append(InlineQueryResultArticle( title=bubbles_text, description="Bubbles Text", input_message_content=InputTextMessageContent(bubbles_text))) bubblesblack_text = formatting_text_inline(text, bubblesblack) answers.append(InlineQueryResultArticle( title=bubblesblack_text, description="Bubbles Black Text", input_message_content=InputTextMessageContent(bubblesblack_text))) smoth_text = formatting_text_inline(text, smothtext) answers.append(InlineQueryResultArticle( title=smoth_text, description="Smoth Text", input_message_content=InputTextMessageContent(smoth_text))) graffiti_text = formatting_text_inline(text, graffiti) answers.append(InlineQueryResultArticle( title=graffiti_text, description="Graffiti Text", input_message_content=InputTextMessageContent(graffiti_text))) graffitib_text = formatting_text_inline(text, graffitib) answers.append(InlineQueryResultArticle( title=graffitib_text, description="Graffiti Bold Text", input_message_content=InputTextMessageContent(graffitib_text))) handwriting_text = formatting_text_inline(text, handwriting) answers.append(InlineQueryResultArticle( title=handwriting_text, description="Handwriting Text", input_message_content=InputTextMessageContent(handwriting_text))) handwritingb_text = formatting_text_inline(text, handwritingb) answers.append(InlineQueryResultArticle( title=handwritingb_text, description="Handwriting Bold Text", input_message_content=InputTextMessageContent(handwritingb_text))) await client.answer_inline_query(query.id, results=answers, switch_pm_text="Converted to stylish text", switch_pm_parameter="help_inline" ) # PM_PERMIT elif string.split()[0] == "engine_pm": button = [[InlineKeyboardButton("Ask for Money", callback_data="engine_pm_block"), InlineKeyboardButton("Contact me", callback_data="engine_pm_nope")], [InlineKeyboardButton("Report", callback_data="engine_pm_report"), InlineKeyboardButton("Passing by", callback_data="engine_pm_none")]] random.shuffle(button) answers.append(InlineQueryResultArticle( id=uuid4(), title="Engine pm", description="Filter pm", input_message_content=InputTextMessageContent(welc_txt, parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(button))) await client.answer_inline_query(query.id, results=answers, cache_time=0 ) elif string.split()[0] == "speedtest": buttons = [[InlineKeyboardButton("Image", callback_data="speedtest_image"), InlineKeyboardButton("Text", callback_data="speedtest_text")]] answers.append(InlineQueryResultArticle( id=uuid4(), title="Speed Test", description="test your speed", input_message_content=InputTextMessageContent("Select SpeedTest Mode", parse_mode="markdown"), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0 ) elif string.split()[0] == "alive": repo = git.Repo(os.getcwd()) master = repo.head.reference commit_id = master.commit.hexsha commit_link = f"[{commit_id[:7]}](https://github.com/pokurt/Nana-Remix/commit/{commit_id})" try: me = await app.get_me() except ConnectionError: me = None text = f"**[Nana-Remix](https://github.com/pokurt/Nana-Remix) Running on {commit_link}:**\n" if not me: text += f" - **Bot**: `stopped (v{USERBOT_VERSION})`\n" else: text += f" - **Bot**: `alive (v{USERBOT_VERSION})`\n" text += f" - **Pyrogram**: `{__version__}`\n" text += f" - **Python**: `{python_version()}`\n" text += f" - **Database**: `{DB_AVAILABLE}`\n" buttons = [[InlineKeyboardButton("stats", callback_data="alive_message")]] answers.append(InlineQueryResultArticle( id=uuid4(), title="Alive", description="Nana Userbot", input_message_content=InputTextMessageContent(text, parse_mode="markdown", disable_web_page_preview=True), reply_markup=InlineKeyboardMarkup(buttons))) await client.answer_inline_query(query.id, results=answers, cache_time=0 ) return
def help_inline_keyboard_list(*args, **kwargs) -> list: """ An inline list including necessary features. Will be shown after requesting "How To" or "Help" button in "Home" and "Help" menus. Current items: 1. How to advertise? 2. How to search for and download an audio track 3. How to register my own audio track? 4. How to add my channel to Telegram audio search engin 5. Contact us 6. About us This feature acts like a blog for a website. To add blogs we recommend using telegra.ph website which is related to Telegram itself :param args: :param kwargs: :return: Generated inline list of blogs """ results = [] results.append(InlineQueryResultArticle( title="*. <b>Soran Ghadri</b>", description="To see author's <b>github</b> and social media, click here", thumb_url="https://telegra.ph/file/6e6831bdd89011688bddb.jpg", input_message_content=InputTextMessageContent(f"Everything you need to know before promoting your business: \n" f"<a href='https://github.com/soran-ghadri/'>" f"<b>Telegram audio search engin Advertising</b></a>", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="1. How to advertise?", description="If you need advertising, click here", thumb_url="https://telegra.ph/file/6e6831bdd89011688bddb.jpg", input_message_content=InputTextMessageContent(f"Everything you need to know before promoting your business: \n" f"<a href='https://github.com/soran-ghadri/tase_search_engine'>" f"<b>Telegram audio search engin Advertising</b></a>", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="2. How to search for and download an audio track", description="You can easily send your audio file and get indexed by Telegram audio search engin bot", thumb_url="https://telegra.ph/file/36fc0478a793bd6db8c4e.jpg", input_message_content=InputTextMessageContent(f"Read searching tutorial on this page: \n" f"<a href='https://github.com/soran-ghadri/tase_search_engine'>" f"<b>Optimal search</b></a>", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="3. How to register my own audio track?", description="You can simply send your audio file and have it indexed by Telegram audio search engin", thumb_url="https://telegra.ph/file/36fc0478a793bd6db8c4e.jpg", input_message_content=InputTextMessageContent(f"Here is a complete guide on " f"<a href='https://github.com/soran-ghadri/tase_search_engine'>" f"<b>how to add my audio track</b></a> (music, podcast, etc.)" f" to be shown in the results", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="4. How to add my channel to Telegram audio search engin", description="if you feel your channel has not been indexed", thumb_url="https://pbs.twimg.com/profile_images/1306684220232945665/5i_q4pCx_400x400.jpg", input_message_content=InputTextMessageContent(f"Here is a complete guide on " f"<a href='https://github.com/soran-ghadri/tase_search_engine'>" f"<b>how to add my channel</b></a> to be shown by Telegram audio search engin", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="5. Contact us", description="If you need to contact Telegram audio search engin admins then hit this item", thumb_url="https://pbs.twimg.com/profile_images/1306684220232945665/5i_q4pCx_400x400.jpg", input_message_content=InputTextMessageContent(f"you can be in touch with us through @[Admin username]\n" f"For further information please read " f"<a href='https://github.com/soran-ghadri/tase_search_engine'>Contact Telegram audio search engin</a>", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="6. About us", description="If you like to find out more about us, click on this link", thumb_url="https://pbs.twimg.com/profile_images/1306684220232945665/5i_q4pCx_400x400.jpg", input_message_content=InputTextMessageContent( f"<b>Read more about us on the following page:\n<a href='https://github.com/soran-ghadri/tase_search_engine'>About Telegram audio search engin</a></b>", parse_mode="HTML") )) return results
def playlist_keyboard(*args, **kwargs): """ The necessary buttons for playlists :param args: 1. playlists, 2. audio_file, 3. add_new_pl_header, 4. function :param kwargs: :return: Generated keyboard """ playlists = args[0] audio_file = args[1] add_new_pl_header = args[2] func = args[3] inp_message_content = "" if func == "addpl": inp_message_content = f"/addnewpl {audio_file['_id']}" elif func == "playlists": add_new_pl_header = False elif func == "history": add_new_pl_header = False hidden_character = " " results = [] list_length = len((list(enumerate(playlists)))) if func == "history": for index, _audio_file in reversed(list(enumerate(playlists))): print("audio_file", _audio_file) file_id = _audio_file["_id"] inp_message_content = f"/dl_{file_id}" _title = str(_audio_file["_source"]["title"]).replace("@", "") _title_line = "<b>نام:</b> " + str(_title) + "\n" _performer = str(_audio_file["_source"]["performer"]).replace("@", "") _performer_line = "<b>اجرا کننده:</b> " + str(_performer) + "\n" _filename = str(_audio_file["_source"]["file_name"]).replace("@", "") _filename_line = "<b>نام فایل:</b> " + str(_filename) + "\n" if not len(_title) < 2: audio_title = _title description = _filename elif not len(_performer) < 2: audio_title = _performer description = _filename else: audio_title = _filename description = "" audio_title = hidden_character + audio_title description = hidden_character + description results.append(InlineQueryResultArticle( title=str(list_length - index) + '. ' + audio_title, description=description, thumb_url="https://telegra.ph/file/cd08f00005cb527e6bcdb.jpg", input_message_content=InputTextMessageContent(inp_message_content, parse_mode="HTML"), )) else: description = "پلیلیست جدید" if add_new_pl_header: results.append(InlineQueryResultArticle( title="اضافه کردن به پلیلیست جدید", description="یک پلیلیست جدید ایجاد شده و فایل به آن اضافه میشود", thumb_url="https://telegra.ph/file/cd08f00005cb527e6bcdb.jpg", input_message_content=InputTextMessageContent(inp_message_content, parse_mode="HTML"), )) for index, playlist in reversed(list(enumerate(playlists))): pl_id = playlist["_id"] if func == "addpl": inp_message_content = f"/addtoexistpl {pl_id} {audio_file['_id']}" elif func == "playlists": inp_message_content = f"/showplaylist {pl_id}" results.append(InlineQueryResultArticle( title=str(list_length - index) + '. ' + playlist["_source"]["title"], description=playlist["_source"]["description"], thumb_url="https://telegra.ph/file/cd08f00005cb527e6bcdb.jpg", input_message_content=InputTextMessageContent(inp_message_content, parse_mode="HTML"), )) return results
def help_inline_keyboard_list(*args, **kwargs) -> list: """ An inline list including necessary features. Will be shown after requesting "How To" or "Help" button in "Home" and "Help" menus. Current items: 1. How to advertise? 2. How to search for and download an audio track 3. How to register my own audio track? 4. How to add my channel to Telegram audio search engine 5. Contact us 6. About us This feature acts like a blog for a website. To add blogs we recommend using telegra.ph website which is related to Telegram itself :param args: :param kwargs: :return: Generated inline list of blogs """ results = [] results.append(InlineQueryResultArticle( title="*. سوران قادری", description="کدهای برنامه و پروفایل برنامهنویس", thumb_url="https://telegra.ph/file/6e6831bdd89011688bddb.jpg", input_message_content=InputTextMessageContent(f"‏" f"برای دیدن کدها روی گیتهاب, اینچا کلیک کنید:\n" f"<a href='https://github.com/soran-ghadri/'><b>" f"گیتهاب" f"</b></a>", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="۱. نحوه تبلیغات در کروموزیک", description="اگه میخوای تبلیغات کنی این گزینه رو بزن", thumb_url="https://telegra.ph/file/6e6831bdd89011688bddb.jpg", input_message_content=InputTextMessageContent(f"‏" f"هرآنچه رو قبل از تبلیغات باید بدونی:\n" f"<a href='https://github.com/soran-ghadri/TASE'><b>" f"تبلیغات کروموزیک" f"</b></a>", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="۲. نحوه جستجو و دانلود موزیک و فایلهای صوتی", description="به آسانی میتونید فایلهای دلخواهت رو در چند میلیثانیه پیدا و دانلود کنی", thumb_url="https://telegra.ph/file/36fc0478a793bd6db8c4e.jpg", input_message_content=InputTextMessageContent(f"‏" f"آموزش جستجوی موزیک رو در این متلب بخونید: \n" f"<a href='https://github.com/soran-ghadri/TASE'><b>‏" f"جستجوی بهینه" f"</b></a>", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="۳. ثبت موزیک و فایلهای صوتی خودم در کروموزیک", description="برای آگاهی از نحوه ثبت موزیک و فایلهای صوتی این گزینه رو انتخاب کنید", thumb_url="https://telegra.ph/file/36fc0478a793bd6db8c4e.jpg", input_message_content=InputTextMessageContent(f"‏" f"در این مقاله راهنمای کامل " f"<a href='https://github.com/soran-ghadri/TASE'>" f"<b>چگونه موزیک و فایل صوتی خودم رو در کروموزیک ثبت کنم</b></a> " f"(موزیک, پادکست, کتاب صوتی و ...)," f" بخوان", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="۴. ثبت کانال خودم در کروموزیک", description="اگه میخوای فایلهای صوتی کانالت در کروموزیک ثبت شه این گزینه رو انتخاب کن", thumb_url="https://telegra.ph/file/36fc0478a793bd6db8c4e.jpg", input_message_content=InputTextMessageContent(f"‏" f"انیجا میتونی یک راهنمایی کامل در بارهی" f"<a href='https://github.com/soran-ghadri/TASE'>" f"<b>" f"ثبت کانال" f"</b></a>" f" خودم در کروموزیک بخوانی\n" f"<b>‏{_check_mark_button} " f"توجه: نام کانال شما همراه فایل صوتی نمایش داده میشود " f"</b>\n", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="۵. تماس با ما", description="برای تماس با تیم ما اینجا کلین کنید", thumb_url="https://telegra.ph/file/cd08f00005cb527e6bcdb.jpg", input_message_content=InputTextMessageContent(f"می توانید با از طریق آیدی " f"@[your admin username]\n" f"در ارتباط با" f"\n" f"برای اطلاعات بیشتر روی لینک زیر کلیک کنید" f"<a href='https://github.com/soran-ghadri/TASE'>" f"تماس با ما" f"</a>", parse_mode="HTML"))) results.append(InlineQueryResultArticle( title="۶. درباره ما", description="درباره تیم ما بیشتر بدانید", thumb_url="https://telegra.ph/file/17ea2995a5146d4c32e7b.jpg", input_message_content=InputTextMessageContent(f"<b>‏" f"در اینجا لینکهای ارتباطی با بخش پشتیبانی و همنیطور بیشتر دربارهی ما بخوانید" f"</b>\n‏<a href='https://github.com/soran-ghadri/'>" f"دربارهی تیم ما" f"</a>", parse_mode="HTML"))) return results
from errors import * from redisclient import Redis from texts import * freemem_command = """free | awk 'FNR == 2 {print ($7/1048576)"GB / "($2/1048576)"GB" }'""" loadavg_command = 'cat /proc/loadavg | cut -d" " -f1-3' uptime_command = 'cat /proc/uptime | cut -d" " -f1' Tags = List[str] Snippet = List[str] Formated = str empty_inline_query = [ InlineQueryResultArticle(title="Please enter a query text", description="Type any word to search tags", input_message_content=InputTextMessageContent( "Empty query string, I have nothing to do.")) ] TAGS_GBL = 'tags:global' DESC_GBL = 'descriptions:global' CMDS_GBL = 'commands:global' CRDT_GBL = 'credits:global' CREATEDBY = 'createdby:{}' TAGGRPS_GBL = 'taggroups:global' TAGGRP_GBL = 'taggroup:global' TOGRPS_GBL = 'togroups:global' def tagexists(tag: str) -> bool: return Redis.sismember(TAGS_GBL, tag)
f"`@pyrogrambot !m` – Methods\n" f"`@pyrogrambot !t` – Types\n" f"`@pyrogrambot !f` – Filters\n" f"`@pyrogrambot !b` – Bound Methods\n" f"`@pyrogrambot !rm` – Raw Methods\n" f"`@pyrogrambot !rt` – Raw Types\n\n" ) DEFAULT_RESULTS = [ InlineQueryResultArticle( id=uuid4(), title="About Pyrogram", input_message_content=InputTextMessageContent( f"{Emoji.FIRE} **Pyrogram**\n\n" f"Pyrogram is an elegant, easy-to-use Telegram client library and framework written from the ground up in " f"Python and C. It enables you to easily create custom apps using both user and bot identities (bot API " f"alternative) via the MTProto API.", disable_web_page_preview=True, ), reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton(f"{Emoji.BUSTS_IN_SILHOUETTE} Community", url="https://t.me/pyrogram") ], [ InlineKeyboardButton(f"{Emoji.CARD_INDEX_DIVIDERS} GitHub", url="https://github.com/pyrogram"), InlineKeyboardButton(f"{Emoji.OPEN_BOOK} Docs", url="https://docs.pyrogram.org") ] ] ), description="Pyrogram is an elegant, easy-to-use Telegram client library and framework.",
def playlist_keyboard(*args: list, **kwargs: object) -> list[object]: """ The necessary buttons for playlists :param args: 1. playlists, 2. audio_file, 3. add_new_pl_header, 4. function :param kwargs: :return: Generated keyboard """ playlists = args[0] audio_file = args[1] add_new_pl_header = args[2] func = args[3] inp_message_content = "" if func == "addpl": inp_message_content = f"/addnewpl {audio_file['_id']}" print("inp_message_content: ", inp_message_content) elif func == "playlists": add_new_pl_header = False # inp_message_content = f"/showplaylist" elif func == "history": add_new_pl_header = False hidden_character = " " results = [] list_length = len((list(enumerate(playlists)))) if func == "history": for index, _audio_file in reversed(list(enumerate(playlists))): file_id = _audio_file["_id"] inp_message_content = f"/dl_{file_id}" _title = str(_audio_file["_source"]["title"]).replace("@", "") _title_line = "<b>Title:</b> " + str(_title) + "\n" _performer = str(_audio_file["_source"]["performer"]).replace("@", "") _performer_line = "<b>Performer:</b> " + str(_performer) + "\n" _filename = str(_audio_file["_source"]["file_name"]).replace("@", "") _filename_line = "<b>File name:</b> " + str(_filename) + "\n" if not _title == None: audio_title = _title description = _filename elif not _performer == None: audio_title = _performer description = _filename else: audio_title = _filename description = "" description = hidden_character + description results.append(InlineQueryResultArticle( title=hidden_character + str(list_length - index) + '. ' + audio_title, description=description, thumb_url="https://telegra.ph/file/cd08f00005cb527e6bcdb.jpg", input_message_content=InputTextMessageContent(inp_message_content, parse_mode="HTML"), )) else: description = "New Playlist" if add_new_pl_header: results.append(InlineQueryResultArticle( title="Add to a new playlist", description="A new playlist will be created and the file will be added to it", thumb_url="https://telegra.ph/file/cd08f00005cb527e6bcdb.jpg", input_message_content=InputTextMessageContent(inp_message_content, parse_mode="HTML"), )) for index, playlist in reversed(list(enumerate(playlists))): pl_id = playlist["_id"] if func == "addpl": inp_message_content = f"/addtoexistpl {pl_id} {audio_file['_id']}" elif func == "playlists": inp_message_content = f"/showplaylist {pl_id}" results.append(InlineQueryResultArticle( title=hidden_character + str(list_length - index) + '. ' + playlist["_source"]["title"], description=hidden_character + playlist["_source"]["description"], thumb_url="https://telegra.ph/file/cd08f00005cb527e6bcdb.jpg", input_message_content=InputTextMessageContent(inp_message_content, parse_mode="HTML"), )) return results