我对电报机器人完全陌生。我想bot.send_message()
在以下代码中执行 a (如代码中所述),但不能这样做。请帮忙。
!pip install python-telegram-bot --upgrade
import telegram
bot = telegram.Bot(token='**************')
bot.send_message(chat_id='******', text="I'm sorry Dave I'm afraid I can't do that.")
它错误为:
1 bot.send_message('mardepbot',"I'm sorry Dave I'm afraid I can't do that.")
/usr/local/lib/python3.6/dist-packages/telegram/bot.py in decorator(self, *args, **kwargs)
63 def decorator(self, *args, **kwargs):
64 logger.debug('Entering: %s', func.__name__)
---> 65 result = func(self, *args, **kwargs)
66 logger.debug(result)
67 logger.debug('Exiting: %s', func.__name__)
/usr/local/lib/python3.6/dist-packages/telegram/bot.py in decorator(self, *args, **kwargs)
88 data['reply_markup'] = reply_markup
89
---> 90 result = self._request.post(url, data, timeout=kwargs.get('timeout'))
91
92 if result is True:
/usr/local/lib/python3.6/dist-packages/telegram/utils/request.py in post(self, url, data, timeout)
307 result = self._request_wrapper('POST', url,
308 body=json.dumps(data).encode('utf-8'),
--> 309 headers={'Content-Type': 'application/json'})
310
311 return self._parse(result)
/usr/local/lib/python3.6/dist-packages/telegram/utils/request.py in _request_wrapper(self, *args, **kwargs)
221 raise Unauthorized(message)
222 elif resp.status == 400:
--> 223 raise BadRequest(message)
224 elif resp.status == 404:
225 raise InvalidToken()
BadRequest: Chat not found