Как ускорить телеграм бота,т.е отправку фото
import telebot
import config
import pyunsplash
bot = telebot.TeleBot(config.token)
unsplash = pyunsplash.PyUnsplash(api_key=config.unsplash_id)
def image(tema):
photo = unsplash.photos(type_='random', count = 1, query = tema)
for i in photo.entries:
return i.link_download
@bot.message_handler(commands=['nature'])
def nature_arts(message):
bot.send_photo(message.chat.id, image('nature'))
@bot.message_handler(commands=['animals'])
def animals_arts(message):
bot.send_photo(message.chat.id, image('animals'))
if __name__ == '__main__':
bot.polling(none_stop=True)
Это код,бот по команде скидывает фотки,но долго,иногда быстро,но в основном долго. Функция image() работает быстро,1 сек,но в чем тогда проблема?