Exemple #1
0
def echo_message(m):
    user = get_chat_info(m)
    bot.send_chat_action(user.cid, "typing")
    text = unidecode.unidecode(m.text)
    if text.lower() == "hola":
        reply = get_greeting(m.chat.first_name)
        bot.reply_to(m, reply)
        send_voice(reply)
    else:
        if text.lower() == "di":
            msg = bot.reply_to(m, "¿Qué quieres que diga en el altavoz?")
            bot.register_next_step_handler(msg, say_something)
        else:
            if text.lower() == "ayuda":
                command_help(m)
Exemple #2
0
def say_something(m):
    try:
        user = get_chat_info(m)
        response = m.text
        if user.is_verified:
            text = "Reproduciendo"
            print(user.cid, text)
            send_message(cid=user.cid, text=text, play=False)
            send_voice(response)
        else:
            text = "Tú usuario no puede realizar está acción"
            send_message(cid=user.cid, text=text)
    except Exception as e:
        print(e)
        bot.reply_to(m, "Algo salio mal")
Exemple #3
0
def set_current_market_option(m):
    try:
        cid = m.chat.id
        bot.send_chat_action(cid, "typing")
        user = user_data[cid]
        if user.platform == 'Bitso':
            user.market = bitso_order_books[m.text]
        else:
            if user.platform == 'Binance':
                user.market = binance_order_books[m.text]['symbol']
                user.crypto = binance_order_books[m.text]['crypto']
                user.pair = binance_order_books[m.text]['pair']
        update_market(cid, user.crypto, user.pair, user.market, m.text, user.platform)
        send_message(cid, "Valor actualizado a " + m.text, close_markup=True)
    except Exception as e:
        print(e)
        bot.reply_to(m, "Algo salio mal al obtener los valores")
Exemple #4
0
def set_exchange(m):
    markup = ReplyKeyboardMarkup(row_width=2)
    markup.add(KeyboardButton("Bitso"), KeyboardButton("Binance"))
    msg = bot.reply_to(
        m,
        "¿Elige una opción?",
        reply_markup=markup,
    )
    bot.register_next_step_handler(msg, set_market)
Exemple #5
0
def set_market(m):
    cid = m.chat.id
    exchange = m.text
    user = User()
    user.platform = exchange
    user_data[cid] = user
    markup = ReplyKeyboardMarkup(row_width=2)
    if exchange == 'Bitso':
        for book in bitso_order_books:
            markup.add(KeyboardButton(book))
    else:
        if exchange == 'Binance':
            for book in binance_order_books:
                markup.add(KeyboardButton(book))
        else:
            send_message(cid, "Valor invalido")
    msg = bot.reply_to(
        m,
        "¿Cuál es el libro con el que quieres operar?",
        reply_markup=markup,
    )
    bot.register_next_step_handler(msg, set_current_market_option)