def test_from_row(self):
        reply_keyboard_markup = ReplyKeyboardMarkup.from_row([
            KeyboardButton(text='button1'),
            KeyboardButton(text='button2')]).keyboard
        assert len(reply_keyboard_markup) == 1
        assert len(reply_keyboard_markup[0]) == 2

        reply_keyboard_markup = ReplyKeyboardMarkup.from_row(['button1', 'button2']).keyboard
        assert len(reply_keyboard_markup) == 1
        assert len(reply_keyboard_markup[0]) == 2
    def test_from_row(self):
        reply_keyboard_markup = ReplyKeyboardMarkup.from_row(
            [KeyboardButton(text="button1"),
             KeyboardButton(text="button2")]).keyboard
        assert len(reply_keyboard_markup) == 1
        assert len(reply_keyboard_markup[0]) == 2

        reply_keyboard_markup = ReplyKeyboardMarkup.from_row(
            ["button1", "button2"]).keyboard
        assert len(reply_keyboard_markup) == 1
        assert len(reply_keyboard_markup[0]) == 2
예제 #3
0
def taxi_geolocation(update: Update, context: CallbackContext):
    lang = context.user_data['lang']

    long = update.message.location.longitude
    lat = update.message.location.latitude

    context.user_data['long'] = update.message.location.longitude
    context.user_data['lat'] = update.message.location.latitude

    coords = f"{long},{lat}"
    address_str = get_address_from_coords(coords, lang)
    context.user_data['address'] = address_str
    text = BUYURTMA_TEXT[lang]['check'].format(address_str)
    markup = ReplyKeyboardMarkup.from_row(btn_taxi_check[lang], resize_keyboard=True)
    update.message.reply_html(text, reply_markup=markup)
    return CHECK
예제 #4
0
def welcome(update: Update, _: CallbackContext):
    telegram_id = update.effective_user.id

    if not Profile.objects.filter(telegram_id=telegram_id).exists():
        text = REG_TEXT['welcome']
        update.message.reply_html(text,
                                  reply_markup=ReplyKeyboardMarkup.from_row(
                                      btn_til, resize_keyboard=True))
        return TIL
    else:
        lang = Profile.objects.filter(
            telegram_id=telegram_id).values_list('language').first()[0]
        text = REG_TEXT[lang]['menu']
        update.message.reply_html(text,
                                  reply_markup=ReplyKeyboardMarkup(
                                      btn_menu[lang], True))
        return ConversationHandler.END
예제 #5
0
def start(update, context):
    chat_id = update.effective_chat.id
    if not chat_id in list(users.keys()):
        username = update.effective_chat.username
        welcome_text = "Приветствуем нового сюсюкена:" + username + emojize(
            ':green_heart:')
        for user in list(users.keys()):
            context.bot.send_message(chat_id=user, text=welcome_text)
        users[chat_id] = username
        VK.adduserstodb(chat_id, username)
        logger.info('Add new user:%s %s' % (chat_id, username))
    lastest[chat_id] = -1
    menu = ReplyKeyboardMarkup.from_row(buttons)
    wait_job = context.job_queue.run_repeating(newSavedUpdater,
                                               10,
                                               context=chat_id)
    Hello_message = """Привет! Я бот для сохраненок Макара. Бот будет присылать тебе новые сохраненки, а также
    ты можешь полистать их самостоятельно, используя кнопки."""
    context.bot.send_message(chat_id=chat_id,
                             text=Hello_message,
                             reply_markup=menu)
예제 #6
0
def get_reply_keyboard(buttons_list):
    keyboard = ReplyKeyboardMarkup.from_row(buttons_list)
    keyboard.one_time_keyboard = True
    keyboard.selective = True
    keyboard.resize_keyboard = True
    return keyboard

import os
import time

# pip install python-telegram-bot
from telegram import Update, ReplyKeyboardMarkup
from telegram.ext import Updater, MessageHandler, CommandHandler, Filters, CallbackContext
from telegram.ext.dispatcher import run_async

import config
from common import get_logger, log_func, reply_error


COMMANDS = ['say', 'echo', '123']
REPLY_KEYBOARD_MARKUP = ReplyKeyboardMarkup.from_row(COMMANDS, resize_keyboard=True)

log = get_logger(__file__)


@run_async
@log_func(log)
def on_start(update: Update, context: CallbackContext):
    update.message.reply_text(
        'Введите что-нибудь'
    )


@run_async
@log_func(log)
def on_request(update: Update, context: CallbackContext):