Answer the question
In order to leave comments, you need to log in
No errors but Telegram bot Python not working how to solve?
Hello, the problem is this: I wrote a python code for a telegram bot, After I activated it. There are no errors, then I registered the / start command, Zero reaction. Please tell me how can I fix this?
The code itself:
import telebot
from telebot import types
import random
TOKEN = 'I won't burn the token)))'
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['starts'])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
item1 - types.KeyboardButton('0️⃣ Random Number')
item2 - types.KeyboardButton(' Currency Rates')
item3 - types.KeyboardButton(' Information')
item4 - types.KeyboardButton('⁉️ Other ')
markup.add(item1, item2, item3, item4)
bot.send_message(message.chat.id, 'Hi, {0.frist_name}'.format(message.from_user), reply_markup = markup)
@bot.message_handler(content_types= ['text'])
def bot_message(message):
if message.chat.type == 'private':
if message.text == '0️⃣ Random number':
bot.send_message(message.chat.id, + str(Random .randint(0, 1000)))
elif message.text == 'Currency Rates':
markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
item1 - types.KeyboardButton('USD Dollar Rate')
item2 - types.KeyboardButton('EU Euro exchange rate')
back - types.KeyboardButton('⬅️ Back')
markup.add(item1, item2, back)
bot.send_message(message.chat.id, ' Exchange Rates', reply_markup = markup)
elif message.text == ' Information':
markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
item1 - types.KeyboardButton(' About Bot')
item2 - types.KeyboardButton(' What's in the box?')
back - types.KeyboardButton('⬅️ Back')
markup.add(item1, item2, back)
bot.send_message(message.chat.id, ' Information', reply_markup = markup)
elif message.text == '⁉️ Other':
markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
item1 - types.KeyboardButton(' Settings')
item2 - types.KeyboardButton('♥️ Subscription')
item3 - types.KeyboardButton(' Stickers')
back - types.KeyboardButton('⬅️ Back')
markup.add(item1, item2, item3, back)
bot.send_message(message.chat.id, '⁉️ Other', reply_markup = markup)
elif message.text == '⬅️ Back':
markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
item1 - types.KeyboardButton('0️⃣ Random Number')
item2 - types.KeyboardButton(' Currency Rates')
item3 - types.KeyboardButton(' Information')
item4 - types. KeyboardButton('⁉️ Other')
markup.add(item1, item2, item3, item4)
bot.send_message(message.chat.id, '⬅️ Back', reply_markup = markup)
elif message.text == 'Stickers':
stick = open('AnimatedSticker.tgs','rb')
bot.send_sticker(message.chat.id, stick)
stick = open('AnimatedSticker2.tgs', 'rb')
bot.send_sticker(message.chat.id, stick)
bot.polling(none_stop=True)
Answer the question
In order to leave comments, you need to log in
About the absence of errors - this is clearly not the case. More than mistakes.
1. frist_name
- wrong. first_name
2. Why is there a subtraction sign when creating buttons, and not an assignment sign?
3.
bot.send_message(message.chat.id,+ str(Random.randint(0, 1000)))
wrong call, why is there a plus and you need to access the library as random.
/starts
, you are sending/start
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question