R
R
RamZevss2020-10-04 18:53:54
Python
RamZevss, 2020-10-04 18:53:54

Learning to make tg bots,Error FileNotFoundError: [Errno 2] No such file or directory: 'static/ky.jpg'?

import telebot
import config 

bot = telebot.TeleBot(config.token)

@bot.message_handler(commands=['start'])
def welcome(message):
  sti = open('static/ky.jpg', 'rb')
  bot.send_sticker(message.chat.id, sti)

  bot.send_message(message.chat.id, "Ку бро, {0.first_name}!\nЯ - <b> твой крол! ".format(message.from_user, bot.get_me()),
    parse_mode='html')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zexer, 2020-10-04
@zexer

Use the full path to the file, or make sure you use the correct relative path if the file exists.
Create the file if it doesn't exist.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question