场景:我正在编写一个机器人,将几条选定的消息从私人频道传送到个人(我有他/她的I)或另一组我有它的id。
状态:
以下是前向函数的代码
def forwardMsg(self, update: Update, context: CallbackContext):
context.bot.forwardMessage(chat_id=update.effective_chat.id,
from_chat_id=-15XXXXXX, message_id=4463)
以下是我的主要代码
forwardMsg_handler = CommandHandler('forwardMsg', forwardMsg)
dispatcher.add_handler(forwardMsg_handler)
所有其他命令都在工作。
我在Pycharm控制台中得到以下错误
telegram.error.BadRequest: Chat not found
我到处都找过了,肯定有用,但没有用。为什么?
2022-01-11 19:24:05,822 - apscheduler.scheduler - INFO - Scheduler started
2022-01-11 19:52:32,661 - telegram.ext.dispatcher - ERROR - No error handlers are
registered, logging exception.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-
packages\telegram\ext\dispatcher.py", line 555, in process_update
handler.handle_update(update, self, check, context)
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-
packages\telegram\ext\handler.py", line 198, in handle_update
return self.callback(update, context)
File "C:\Users\a\PycharmProjects\telegramBot\commands\bot_commands.py", line 70, in
forwardMsg
context.bot.forwardMessage(chat_id=update.effective_chat.id, from_chat_id=-154*****,
message_id=4463)
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\telegram\bot.py",
line 130, in decorator
result = func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\telegram\bot.py",
line 641, in forward_message
protect_content=protect_content,
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-
packages\telegram\ext\extbot.py", line 209, in _message
protect_content=protect_content,
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\telegram\bot.py",
line 336, in _message
result = self._post(endpoint, data, timeout=timeout, api_kwargs=api_kwargs)
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\telegram\bot.py",
line 296, in _post
f'{self.base_url}/{endpoint}', data=data, timeout=effective_timeout
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-
packages\telegram\utils\request.py", line 366, in post
**urlopen_kwargs,
File "C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-
packages\telegram\utils\request.py", line 279, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Chat not found
在电报-bot问题这里中也提出了问题。
发布于 2022-01-12 06:49:07
正如已经回答的在这个GitHub线程上一样,您应该在通道ID从-100开始时再次检查通道ID。
请等待一段合理的时间,然后在不同的地方问同样的问题,并且始终在两个线程上表明您已经在其他地方问过这个问题。
发布于 2022-01-12 17:06:26
基于CallmeStag输入,我无法在
因此,解决方案是-100 +通道ID,从复制后链接作为from_chat_id的整数
https://stackoverflow.com/questions/70675180
复制相似问题