Python / Ошибки в библиотеке Telebot. Ошибка в телеботе
Знаю эту ошибку, у всех она проявляется по разному, но в моем случае, я даже не знаю куда деваться, и почему она происходит я не знаю. Я выложу мой код телебота, он легкий, маленький, но очень "лагучий"
import os
import sys
import time
from telebot import types
bot = telebot.TeleBot("Token")
os.chdir("C:\\Users\\SDUND\\Downloads\\Python Programer\\TeleBot - Spooky Monkey\\Spooky Stickers")
sticker_hello = open('hello.webp', 'rb')
sticker_shutdown = open('shutdown.webp', 'rb')
sticker_hack = open('hack.tgs', 'rb')
sticker_helper = open('helper.tgs', 'rb')
print("Folders and files: ", os.listdir())
def exitmode():
key = input(">> ")
if key == "zxcv":
print("[ Shutdown ]")
sys.exit()
else:
print("Error:0")
exitmode()
start = input(">> ")
if start == "/stop":
while start == "/stop":
break
else:
print("[ Startup ]")
@bot.message_handler(commands=['start'])
def start_message(message):
name = message.from_user.first_name
bot.send_sticker(message.chat.id, sticker_hello)
bot.send_message(message.chat.id, 'Привет, ' + name + '!')
try:
print("[", str(name), "]", message.text)
except:
print("[", name, "] enter the command")
@bot.message_handler(commands=['hacker'])
def hacker(message):
name = message.from_user.first_name
bot.send_sticker(message.chat.id, sticker_hack)
bot.send_message(message.chat.id, 'Подключение к базе данных. . .')
time.sleep(2)
bot.send_message(message.chat.id, 'Python:\nhttps://www.python.org/\nSpyder-IDE:\nhttps://www.spyder-ide.org/\nПримеры легких программ:\nhttps://fb.ru/article/408277/primer-programmyi-na-python-osobennosti-opisanie-i-rekomendatsii')
bot.send_message(message.chat.id, 'Используй во благо,', name)
try:
print("[", str(name), "]", message.text)
except:
print("[", name, "] enter the command")
@bot.message_handler(commands=['help'])
def helper(message):
name = message.from_user.first_name
keyboard = types.InlineKeyboardMarkup()
key_start = types.InlineKeyboardButton(text='/start', callback_data='helper_1')
keyboard.add(key_start)
key_help = types.InlineKeyboardButton(text='/help', callback_data='helper_2')
keyboard.add(key_help)
key_shutdown = types.InlineKeyboardButton(text='/shutdown', callback_data='helper_3')
keyboard.add(key_shutdown)
key_hack = types.InlineKeyboardButton(text='/hacker', callback_data='helper_4')
keyboard.add(key_hack)
key_text = types.InlineKeyboardButton(text='Текстовой ввод', callback_data='helper_5')
keyboard.add(key_text)
bot.send_message(message.from_user.id, text='Меню:', reply_markup=keyboard)
try:
print("[", str(name), "]", message.text)
except:
print("[", name, "] enter the command")
@bot.message_handler(commands=['shutdown'])
def shutdown_message(message):
name = message.from_user.first_name
bot.send_sticker(message.chat.id, sticker_shutdown)
bot.send_message(message.chat.id, 'Пора отключить сервер, веди пароль на сервере и мы попрощаемся!')
exitmode()
try:
print("[", str(name), "]", message.text)
except:
print("[", name, "] enter the command")
@bot.message_handler(content_types=['text'])
def send_text(message):
name = message.from_user.first_name
if message.text.lower() == 'привет':
bot.send_message(message.chat.id, 'Привет, ' + name + '!')
elif message.text.lower() == 'пока':
bot.send_message(message.chat.id, 'До встречи, ' + name + '.')
else:
bot.send_message(message.chat.id, message.text)
try:
print("[", str(name), "]", message.text)
except:
print("[", name, "] enter the command")
@bot.callback_query_handler(func=lambda call: True)
def callback_worker(call):
name = call.from_user.first_name
if call.data == 'helper_1':
answer = 'Нажмите на эту команду: /start'
bot.send_message(call.from_user.id, answer)
elif call.data == 'helper_2':
answer = 'Нажмите на эту команду: /help'
bot.send_message(call.from_user.id, answer)
elif call.data == 'helper_3':
answer = 'Нажмите на эту команду: /shutdown'
bot.send_message(call.from_user.id, answer)
elif call.data == 'helper_4':
answer = 'Нажмите на эту команду: /hacker'
bot.send_message(call.from_user.id, answer)
elif call.data == 'helper_5':
bot.send_sticker(call.from_user.id, sticker_helper)
bot.send_message(call.from_user.id, 'Я надеюсь, ты меня поймешь, ' + name)
bot.send_message(call.from_user.id, '/start\n/shutdown\n/help\n/hacker')
try:
print("[", str(name), "]", call.text)
except:
print("[", name, "] enter the command")
bot.polling(none_stop = True)
Ошибка:
2020-07-01 15:12:08,826 (util.py:68 WorkerThread2) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:\n[b\'{"ok":false,"error_code":400,"description":"Bad Request: file must be non-empty"}\']',)
Traceback (most recent call last):
File "C:\Users\SDUND\anaconda3\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "C:\Users\SDUND\Downloads\Python Programer\TeleBot - Spooky Monkey\Spooky Monkey\SpookyMonkeyBot.py", line 45, in start_message
bot.send_sticker(message.chat.id, sticker_hello)
File "C:\Users\SDUND\anaconda3\lib\site-packages\telebot\__init__.py", line 752, in send_sticker
disable_notification, timeout))
File "C:\Users\SDUND\anaconda3\lib\site-packages\telebot\apihelper.py", line 548, in send_data
return _make_request(token, method_url, params=payload, files=files, method='post')
File "C:\Users\SDUND\anaconda3\lib\site-packages\telebot\apihelper.py", line 65, in _make_request
return _check_result(method_name, result)['result']
File "C:\Users\SDUND\anaconda3\lib\site-packages\telebot\apihelper.py", line 84, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: file must be non-empty"}']
"
2020-07-01 15:12:08,828 (__init__.py:443 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: file must be non-empty"}']"
Она также проявляется в других местах кода, но все же я бы хотел узнать, что за червь мешает работе. Спасибо за помощь!