Beispiel #1
0
def query_text(query):
    print(query)  # здесь лежит инфа о запросе
    kb = types.InlineKeyboardMarkup()
    # Добавляем колбэк-кнопку с содержимым "test"
    kb.add(
        types.InlineKeyboardButton(text="Нажми меня",
                                   callback_data="test",
                                   url="https://ya.ru"))
    results = []
    single_msg = types.InlineQueryResultCachedSticker(
        id=1,
        sticker_file_id=
        'CAACAgIAAxkBAAEBE0RgYyKvsRyRvQFLX0lso3v8n3Ap3gACPQADJHFiGmptpaX1U366HgQ',
        reply_markup=kb,
        input_message_content=types.InputTextMessageContent(
            message_text="Я тоже тебя люблю"))
    single_msg1 = types.InlineQueryResultCachedSticker(
        id=2,
        sticker_file_id=
        'CAACAgIAAxkBAAEBE05gYy7DOILjJKL1NkqxRzgx6oIaHQACtwIAAm0w5w-aSTnJZzzxAx4E',
        reply_markup=kb,
        input_message_content=types.InputTextMessageContent(
            message_text="Я скучаю"))
    single_msg2 = types.InlineQueryResultCachedSticker(
        id=3,
        sticker_file_id=
        'CAACAgIAAxkBAAEBE0tgYy6rI_eTFD2tp4LiftvQS-HXRAACjRIAAujW4hIjixrmy5Za0R4E',
        reply_markup=kb,
        input_message_content=types.InputTextMessageContent(
            message_text="Дождь"))
    results.append(single_msg)
    results.append(single_msg1)
    results.append(single_msg2)
    bot.answer_inline_query(query.id, results)
def provide_query_kappa(query):
    try:
        kappa_128 = types.InlineQueryResultCachedSticker(
            id='1', sticker_file_id='CAADAgADmwADAm8gSeu5xOY0kZaQAg')
        kappa_192 = types.InlineQueryResultCachedSticker(
            id='2', sticker_file_id='CAADAgADnAADAm8gSUlfehpJdSSnAg')
        kappa_256 = types.InlineQueryResultCachedSticker(
            id='3', sticker_file_id='CAADAgADmgADAm8gSVEl3iquPsLtAg')
        bot.answer_inline_query(query.id, [kappa_128, kappa_192, kappa_256],
                                cache_time=3600)
    except Exception as e:
        print(e)
Beispiel #3
0
def inline_query(q):
    XO(q.id, new=True)
    pl = TGUser(q.from_user)
    ul = pl.lang
    query = q.query.lower()
    s = 0
    for i in list_of_sizes:
        if str(i) in query:
            s = i
            query = query.replace(str(i), '')
            break
    if 'r' in query:
        s = next(random_list_size)
        query = query.replace('r', '')
    button = callback_buttons(tuple(
        (f'{i}', f'start{i:02}')
        for i in list_of_sizes) + ((ul.random, 'start00'), ),
                              width=3)
    if next(random_list) or not s:
        button.add(
            types.InlineKeyboardButton(
                'Підтримати проект', url='https://send.monobank.ua/zEuxNoaWc'))
    res = (types.InlineQueryResultCachedSticker(
        f'{n}{s:02}{q.id}',
        'CAADAgADKQAD-8YTE7geSMCRsyDEAg' * (1 - n) +
        'CAADAgADKAAD-8YTE4byaCljfP--Ag' * n,
        reply_markup=button,
        input_message_content=types.InputTextMessageContent(ul.startN))
           for sign, n in [['o', 0], ['x', 1]]
           if (sign not in query) or not query)
    return bot.answer_inline_query(q.id, res)
Beispiel #4
0
def inline_empty_query(inline_query):
    rnd_stickers = get_random_stickers()
    stickers = [
        tbtypes.InlineQueryResultCachedSticker(i, s)
        for i, s in enumerate(rnd_stickers)
    ]
    list_of_stickers_showed_to_user[inline_query.from_user.id] = rnd_stickers
    try:
        bot.answer_inline_query(inline_query.id, stickers, cache_time=1)
    except apihelper.ApiException:
        log_errors(traceback.format_exc())
Beispiel #5
0
def query_inline(inline_query):
    try:
        filename = 'resultado' + current_thread().name

        latex2img(inline_query.query, filename, 'webp')
        m = 0
        with open(filename + '.webp', 'rb') as equation:
            m = bot.send_sticker(chat_id, equation)
        os.remove(filename + '.webp')
        results = [
            types.InlineQueryResultCachedSticker('1', m.sticker.file_id)
        ]
        bot.answer_inline_query(inline_query.id, results, cache_time=1.5)
    except Exception:
        print(Exception)
Beispiel #6
0
def what(inline_query):
    try:
        result = collection.find(
            {"title": {
                "$regex": u"" + inline_query.query.lower()
            }})
        answers = []
        i = 0
        for item in result:
            answers.append(
                types.InlineQueryResultCachedSticker(
                    str(i), sticker_file_id=item["file_id"]))
            i += 1
        bot.answer_inline_query(inline_query.id, answers)
    except Exception as e:
        print(e)
Beispiel #7
0
def inline_query(inline_query):
    #print(f'Req: {inline_query.query}')
    log_inline_query(inline_query.from_user.id, inline_query.query)
    stickers_list = get_stickers_by_word(inline_query.query.lower())
    stickers_list2 = get_stickers_by_word(inline_query.query.lower(),
                                          fuzzy=False)
    if len(stickers_list2):
        if stickers_list2[-1] in stickers_list:
            stickers_list.remove(stickers_list2[-1])
        stickers_list.insert(min(len(stickers_list), 3), stickers_list2[-1])
    stickers = []
    for i, s in enumerate(stickers_list[:50]):
        stickers.append(tbtypes.InlineQueryResultCachedSticker(i, s))
    list_of_stickers_showed_to_user[
        inline_query.from_user.id] = stickers_list[:50]
    #print(f'Res: {stickers}')
    try:
        bot.answer_inline_query(inline_query.id, stickers, cache_time=5)
    except apihelper.ApiException:
        log_errors(traceback.format_exc())
Beispiel #8
0
def naga(query):
    try:
        nagaeedam = query.query
        R.incrby("nagaeedam:inline:used", 1)
        text = urllib.urlencode({
            u'txtclr': u'000000',
            u'txt': nagaeedam + u" نـگاییـدم",
            u'txtfit': u'max',
            u'txtsize': u'200',
            u'txtfont': u'PT Serif,Bold'
        })
        text2 = text.replace(u"+", u"%20")
        link = u"http://copierteam.imgix.net/e642-t.png?{}".format(text2)
        urllib.urlretrieve(link, "naga.png")
        filee = open("naga.png", "rb")
        mess = bot.send_sticker(-179123621, filee)
        sticker = mess.sticker.file_id
        markup2 = types.InlineKeyboardMarkup()
        markup2.add(
            types.InlineKeyboardButton(u"برو به حالت اینلاین",
                                       switch_inline_query=""))
        markup2.add(
            types.InlineKeyboardButton(
                u"!منو استارت کن",
                url=u"https://telegram.me/Nagaeedam_bot?start=new"))
        r = types.InlineQueryResultCachedSticker('1', sticker)
        r1 = types.InlineQueryResultArticle(
            '2',
            u'منو به دوستات معرفی کن',
            types.InputTextMessageContent(
                u"برا تو هم پیش اومده یه وقتی یکی تو یه گروهی یا جای دیگه یکی یه چیزی میگه و میخوای بگی نگاییدم و دوس داشته باشی یه جور خاص بش بگی مثلا رل نگاییدم😁 \n من برات این کارو میکنم😅\nاول  توی باکس ارسال پیام بنویس \n@nagaeedamro_bot \nبعد جلوش یه فاصله بزار و مثلا بنویس \nIn Rell \nبعد بالای باکس چتت یه شکلک میاد ، روش بزن ، هرجا هستی یه استیکر میفرسته که پایینش نوشته : In Rell نگاییدم ( هرچی جای In Rell بزاری همونو مینویسه )\nیا اینکه رو دکمه اولیه که پایین این متنه کلیک کن و یه چت انتخاب کن و بنویس چی رو نگاییدی 😂\nبرو حال کن به رفیقات هم معرفیم کن D:"
            ),
            reply_markup=markup2)
        if R.sismember("nagaeedam:members", query.from_user.id):
            bot.answer_inline_query(query.id, [r, r1])
        elif not R.sismember("nagaeedam:members", query.from_user.id):
            bot.answer_inline_query(query.id, [r, r1],
                                    switch_pm_text="!منو استارت کن",
                                    switch_pm_parameter="/start")
    except Exception as e:
        print(e)
Beispiel #9
0
def inline(msg):
    try:
        if len(msg.query) == 0:
            r2 = types.InlineQueryResultArticle(
                '1', 'آموزش',
                types.InputTextMessageContent('''
آموزش استفاده از ربات :

برای استفاده از این ربات شما باید در هر چتی که میخواهید استیکر را ارسال کنید یوزرنیم ربات را نوشته و سپس کلمه مورد نظر را درج کنید...
به مثال زیر توجه کنید :

@BokoneshBot علیرضا

در مثال بالا ربات اسم ؛ علیرضا ؛ را استیکر کرده و به شما ارسال میکند

توجه کنید که فقط میتوانید فارسی تایپ کنید ...

کانال : @PG_TM
نوشته شده توسط : @AnonyDev

'''))
            bot.answer_inline_query(msg.id, [r2])
        else:
            qu = msg.query
            urllib.urlopen("http://pgtm.ir/api/naga.php?name={}".format(qu))
            urllib.urlretrieve("http://pgtm.ir/api/pic.png",
                               str(msg.from_user.id) + ".png")
            filee = open(str(msg.from_user.id) + ".png", "rb")
            lin = bot.send_sticker(-1001092549101, filee)
            sticker = lin.sticker.file_id
            r = types.InlineQueryResultCachedSticker('1', sticker)
            r2 = types.InlineQueryResultArticle(
                '2', 'درباره ما',
                types.InputTextMessageContent(
                    'نوشته شده توسط : @AnonyDev\n\nدرکانال ما عضو شوید : @PG_TM'
                ))
            bot.answer_inline_query(msg.id, [r, r2])

    except Exception as e:
        print e