Answer the question
In order to leave comments, you need to log in
Python telegram bot - I wanted it to give out a greeting sticker when start was written, but how to fix the error?
import telebot
bot = telebot.TeleBot('1352920423:AAFZ1xL_UfOtfNoJXomQeuZCtsgFnXCky1c')
@bot.message_handler(commands=['start'])
def welcome(message):
sti = open('Python/sticker.webp')
bot.send_sticker(message .chat.id, sti)
bot.send_message(message.chat.id, "Welcome, {0.first_name}!\nI'm {1.first_name}, a bot designed to be a bunny.".format(message.from_user , bot.get_me()),
parse_mode="html")
@bot.message_handler(content_types=['text'])
def lalala(message):
bot.send_message(message.chat.id, message.text)
bot.polling (none_stop=True)
Answer the question
In order to leave comments, you need to log in
Either run the script from its folder, or learn to use full paths to files
import os
sticker_path = os.path.join(os.getcwd(), 'Python', 'sticker.webp')
sti = open(sticker_path)
You don't need to send the sticker file, but you need to send the file_id of the sticker. How to get this id? You can use the @idsticker_bot bot or display the message object on the console.
in JS:
bot.start((ctx) => {
ctx.reply('Привет');
ctx.replyWithSticker('CAACAgIAAxkBAAISrV9jK2iLT87OMPNYNR-6FEOWm8qrAAInAwACtXHaBg_03s-gxd3sGwQ');
});
sti = 'CAACAgIAAxkBAAISrV9jK2iLT87OMPNYNR-6FEOWm8qrAAInAwACtXHaBg_03s-gxd3sGwQ'
bot.send_sticker(message.chat.id, sti)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question