Example #1
0
async def echo():
    """Shows how to use waiter."""

    msg = "🔹 Now i will send you back all messages in raw format like @ShowJsonBot.\n\n" \
          "Hit /cancel to exit."

    kb = InlineKeyboard()
    kb.callback('Stop!', 'stop')

    SendMessage(context.chat.id, msg, reply_markup=kb.render()).webhook()

    while True:

        # here waiting next request
        # this is python's async generator
        yield next_all()

        if context.message.text == '/cancel':
            SendMessage(context.chat.id, "🔹 Ok! See you later!").webhook()
            return

        # print reminder every five updates
        if not context.update.update_id % 5:
            await SendMessage(
                context.chat.id,
                "🔹 I am in <code>echo</code> mode. Hit /cancel to exit."
            ).send()

        prepared = escape.html(
            json.dumps(context.update.raw, ensure_ascii=False, indent=1))
        SendMessage(context.chat.id,
                    f"<code>{prepared}</code>",
                    reply_to_message_id=context.message.message_id).webhook()
Example #2
0
async def get_send_as_file_ik(telegraph_id):
    T = data.current_T.get()
    kb = InlineKeyboard()

    kb.callback(T('send_as_file/use_this'), f'improve {telegraph_id}').row()
    kb.callback(T('send_as_file/use_file'), 'send_as_file_info').row()

    return kb
Example #3
0
async def get_process_document_ik(telegraph_id):
    T = data.current_T.get()
    kb = InlineKeyboard()

    text = T('process_kb/colorize')
    kb.callback(text, f'colorize {telegraph_id}').row()

    text = T('process_kb/improve')
    kb.callback(text, f'improve {telegraph_id}').row()

    return kb
Example #4
0
async def start_command():
    user = await get_user(context2.message.user.__dict__)

    kb = InlineKeyboard()
    kb.callback(jinja.get_template('lang/ru').render(), 'language ru')
    kb.callback(jinja.get_template('lang/en').render(), 'language en')
    kb.arrange_simple(2)

    await SendMessage(context2.message.user.user_id,
                      jinja.get_template('lang/text').render(),
                      reply_markup=kb.render()).send()
async def arranged_simple_inline_keyboard():
    """Shows how to arrange inline keyboard."""

    kb = InlineKeyboard()

    for i in range(30):
        kb.callback("%s" % i, 'arranged %s' % i)

    kb.callback("❌ Close", 'arranged close')

    kb.arrange_simple(5)

    await SendMessage(context.user.id,
                      '🔹 Select number.',
                      reply_markup=kb.render()).send()
Example #6
0
async def arranged_simple_inline_keyboard(ctx: Context):
    """Shows how to arrange inline keyboard."""

    kb = InlineKeyboard()

    for i in range(30):
        kb.callback("%s" % i, 'arranged %s' % i)

    kb.callback("❌ Close", 'arranged close')

    kb.arrange_simple(5)

    await ctx.bot.send_message(ctx.update.message.user.user_id,
                               '🔹 Select number.',
                               reply_markup=kb.render())
async def arranged_simple_inline_keyboard():
    """Shows how to arrange inline keyboard by scheme."""

    kb = InlineKeyboard()

    kb.callback("⏪ Prev", 'scheme prev')
    kb.callback("✅ Do!", 'scheme do')
    kb.callback("Next ⏩", 'scheme next')

    for i in range(60):
        kb.callback("%s" % i, 'scheme %s' % i)

    kb.callback("❌ Close", 'scheme close')

    kb.arrange_scheme(3, 6, 1)

    await SendMessage(context.user.id,
                      '🔹 Select number.',
                      reply_markup=kb.render()).send()
Example #8
0
def rotors_kb(estat_id):
    kb = InlineKeyboard()

    for r in ROTORS.keys():
        kb.callback(r, f'enigma-rotors {estat_id} rotor {r}')

    for r in sorted(REFLECTORS.keys()):
        kb.callback(r, f'enigma-rotors {estat_id} reflector {r}')

    kb.callback('3-rotors', f'enigma-rotors {estat_id} 3rotors none')
    kb.callback('4-rotors', f'enigma-rotors {estat_id} 4rotors none')
    kb.callback('NEXT ▶️', f'enigma-rotors {estat_id} done none')

    return kb.arrange_simple(5).render()
async def simple_inline_keyboard():
    """Shows how to create inline keyboard."""

    kb = InlineKeyboard()
    kb.callback("😃 Super", 'simple 1').row()
    kb.callback("🙃 Great", 'simple 2').row()
    kb.callback("🤨 Not bad", 'simple 3').row()
    kb.callback("😖 All bad", 'simple 4').row()
    kb.callback("❌ Close", 'simple close')

    await SendMessage(context.user.id,
                      '🔹 How are you filling?',
                      reply_markup=kb.render()).send()
Example #10
0
def enigma_kb(estat_id, cmd='enigma', pb=''):
    kb = InlineKeyboard()

    for c in LETTERS_QWERTY[:-2]:
        ch = c if c not in pb else '*'
        kb.callback(ch, f'{cmd} {estat_id} letter {c}')

    if cmd == 'enigma-plugboard':
        kb.callback('✖️ DEL', f'{cmd} {estat_id} del none')
    if cmd == 'enigma':
        kb.callback('⏪ SET', f'{cmd} {estat_id} set none')

    for c in LETTERS_QWERTY[-2:]:
        ch = c if c not in pb else '*'
        kb.callback(ch, f'{cmd} {estat_id} letter {c}')

    if cmd == 'enigma-display':
        kb.callback('RUN ▶️', f'{cmd} {estat_id} run none')
    elif cmd != 'enigma':
        kb.callback('NEXT ▶️', f'{cmd} {estat_id} done none')
    else:
        kb.callback('⬅️', f'{cmd} {estat_id} bksp none')

    return kb.arrange_simple(8).render()