我有一个来自群聊的id,但是当我试图在那里发送消息时,我得到这个错误:
Traceback (most recent call last):
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogramdispatcherdispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogramdispatcherdispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogramdispatcherhandler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogramdispatcherdispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogramdispatcherhandler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "D:githubrepositoriespython-botbot5.py", line 77, in cmd_create_dem
await bot.send_poll(chat_id=id,
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogrambotbot.py", line 1532, in send_poll
result = await self.request(api.Methods.SEND_POLL, payload)
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogrambotbase.py", line 231, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogrambotapi.py", line 140, in make_request
return check_result(method, response.content_type, response.status, await response.text())
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogrambotapi.py", line 115, in check_result
exceptions.BadRequest.detect(description)
File "D:githubrepositoriespython-botvenvlibsite-packagesaiogramutilsexceptions.py", line 140, in detect
raise err(cls.text or description)
aiogram.utils.exceptions.ChatNotFound: Chat not found
如果我尝试发送到任何其他组,那么一切都可以正常工作。为什么呢?
代码:
@dp.message_handler(commands=['opros'])
async def prikol(message: types.Message):
id = {-numbers}
await bot.send_message(id, 'ok')
我把id改成了{numbers}
我的id有14个字符,包括减号,而其他组有大约10个字符。这会影响到什么吗?
如果id没有-100(例如:1234561),则需要添加"-100"(例如:-1001234561)
我有两个建议:
- 请确保您的bot必须是该组的管理员才能发送消息。
- 重复检查组id。