import telebot
import config
from telebot import types
import decimal
bot = telebot.TeleBot(config.TOKEN)
@bot.message_handler(commands=['start'])
def welcome(message):
sti = open('static/numbot.webp', 'rb')
bot.send_sticker(message.chat.id, sti)
bot.send_message(message.chat.id, "Hello, my commands are here below.\nIf you want more information, write /info\n\n{0.first_name}, where do we begin? ".format(message.from_user, bot.get_me()),
parse_mode='html')
@bot.message_handler(content_types=['text'])
def inlinekeyboard(message):
if message.chat.type == 'private':
if message.text == '⚖️Сalculate':
markup = types.InlineKeyboardMarkup(row_width=3)
item1 = types.InlineKeyboardButton("USD", callback_data='usd')
item2 = types.InlineKeyboardButton("RUB", callback_data='rub')
item3 = types.InlineKeyboardButton("UAH", callback_data='uah')
markup.add(item1, item2, item3)
bot.send_message(message.chat.id, 'Select the currency for the calculation ⤵️', reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
try:
if call.message:
if call.data == 'usd':
bot.send_message(call.message.chat.id, "$ Enter the amount of num ⤵️")
bot.delete_message(call.message.chat.id, call.message.message_id)
bot.register_next_step_handler(call.message.chat.id, caclulate_usd)
except Exception as e:
print(repr(e))
def caclulate_usd(message):
num_usd = message.text
bot.send_message(call.message.chat.id, 'Ваше запрос \"' + message.text +
'\" получен. Можете вернуться в главное меню ⤵', reply_markup=keyboard)
bot.polling(none_stop=True)
bot.register_next_step_handler(call.message.chat.id, caclulate_usd)
bot.register_next_step_handler(call.message, caclulate_usd)
.......
bot.register_next_step_handler(call.message, caclulate_usd, call)
.......
def caclulate_usd(message, call):
num_usd = message.text
bot.send_message(call.message.chat.id, 'Ваше запрос \"' + message.text +
'\" получен. Можете вернуться в главное меню ⤵', reply_markup=keyboard)