@dusenkot
123123

Проблема с ботом на python?

import telebot #библиотеки
import random

from telebot import types

bot=telebot.TeleBot('') #токен
@bot.message_handler(commands=['start'])
def welcome(message):
	
#keyboard
	markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
	item1=types.KeyboardButton('Тернополь')
	item2=types.KeyboardButton('Киев')
	item3=types.KeyboardButton('Харьков')
	markup.add(item1,item2,item3)
	bot.send_message(message.chat,id,'Посмотри на клавиатуру и выбери свой город',reply_markup=markup)
@bot.message_handler(content_types=['text'])#Дейстивия бота
def pizda(message):
	if message.chat.type=='private':
		if message.text=='Тернополь':
			bot.send_message(message.chat.id,'dusenkot')
	if message.chat.type=='private3':
		if message.text=='Киев':
			bot.send_message(message.chat.id,'dusenkot')
	if message.chat.type=='private4':
		if message.text=='Харьков':
			bot.send_message(message.chat.id,'dusenkot')
			
#run
bot.polling(none_stop=True)


Вот код если эго запустить все работает,но как только написать боту /start бот крашиться
2020-02-03 19:54:50,507 (util.py:66 WorkerThread1) 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: chat not found"}\']',)
Traceback (most recent call last):
  File "C:\Users\Тарас\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 60, in run
    task(*args, **kwargs)
  File "bot3.py", line 16, in welcome
    bot.send_message(message.chat,id,'Посмотри на клавиатуру и выбери свой город',reply_markup=markup)
  File "C:\Users\Тарас\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 600, in send_message
    apihelper.send_message(self.token, chat_id, text, disable_web_page_preview, reply_to_message_id,
  File "C:\Users\Тарас\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 154, in send_message
    return _make_request(token, method_url, params=payload, method='post')
  File "C:\Users\Тарас\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 60, in _make_request
    return _check_result(method_name, result)['result']
  File "C:\Users\Тарас\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 79, 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: chat not found"}']
"
2020-02-03 19:54:50,510 (__init__.py:420 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: chat not found"}']"


Это код с командной строки
  • Вопрос задан
  • 2884 просмотра
Решения вопроса 1
hottabxp
@hottabxp Куратор тега Python
Сначала мы жили бедно, а потом нас обокрали..
bot.send_message(message.chat.id,'Посмотри на клавиатуру и выбери свой город',reply_markup=markup)

Между chat и id нужна точка вместо запятой.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы