Answer the question
In order to leave comments, you need to log in
Telegram bot problem?
Hello!
I must say right away that I am only a beginner in python.
I created a simple telegram bot using botfather. I designed it and decided to test it. But after the / start command, the bot does not write anything. It just doesn’t work
. I have 2 files with code
1 file - bot.py:
import telebot
import config
from telebot import types
bot = telebot.TeleBot(config.TOKEN)
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("Link to our VK")
item2 = types.KeyboardButton("Link to our Instagram")
item3 = types.KeyboardButton ("Link to our YouTube")
item4 = types.KeyboardButton("Link to our Telegram")
markup.add(item1, item2, item3, item4)
bot.send_message(message.chat.id, "Welcome, {0.first_name}!\nI'm {1.first_name} , a bot that will give you links to social networks .".format(message.from_user, bot.get_me()),
parse_mode='html', reply_markup=markup)
@bot.message_handler(content_types=['text'])
def lalala(message):
if message.text = = 'Link to our VK':
bot.send_message(message.chat.id, ' https://vk.com ', reply_markup=markup)
elif message.text == 'Link to our Instagram':
bot.send_message(message .chat.id, ' https://www.instagram.com ', reply_markup=markup)
elif message.text == 'Link to our YouTube':
bot.send_message(message.chat.id, ' https://youtube.com ', reply_markup=markup)
elif message.text == 'Link to our Telegram':
bot.send_message(message.chat.id, ' https://web.telegram.org ', reply_markup=markup)
except Exception as e:
print(repr(e))
bot.polling(none_stop=True)
And second config file .py:
TOKEN = '1325171279:AAFj9udp55hLty0NUte1ubSwVnOOVM28OBk'
Answer the question
In order to leave comments, you need to log in
except is, try is not. It's like I
don't know who you're sending this message to.
bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}!\nЯ - {1.first_name}, бот который даст вам ссылки на соц-сети.".format(message.from_user, bot.get_me()),
parse_mode='html', reply_markup=markup)
@bot.message_handler(commands=['start'])
def start_message(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("Ссылка на наш Вк")
item2 = types.KeyboardButton("Ссылка на наш Инстаграмм")
item3 = types.KeyboardButton("Ссылка на наш Ютуб")
item4 = types.KeyboardButton("Ссылка на наш Телеграмм")
markup.add(item1, item2, item3, item4)
bot.send_message(message.chat.id, "Добро пожаловать, {}!\nЯ - {}, бот который даст вам ссылки на соц-сети.".format(message.from_user, bot.get_me()), reply_markup=markup)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question