首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我的电报用户not可以私下转发消息,但不能在超级组中转发。

我的电报用户not可以私下转发消息,但不能在超级组中转发。
EN

Stack Overflow用户
提问于 2022-03-16 16:22:05
回答 1查看 843关注 0票数 0

我在电报中写了一个与用户机器人有关的小项目。当我试图将消息从超级组转发到另一个用户时遇到了问题,但是当我尝试从常规聊天中转发消息时,一切都是成功的。I found a similar question, but unfortunately bots are used there, not userbots.

Lib:热图

版本: 1.4.8

我的代码:

代码语言:javascript
运行
复制
@app.on_message(filters.group & filters.text)
async def formessage(client, message):
    text = message.text.lower()

    # other code

    await message.forward(botdata["id"])

我也尝试使用函数:app.forward_messages(botdata["id"], message.chat.id, message.message_id),但是唉,我得到了同样的错误

当超级组中有一条新消息时所收到的错误:

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "C:\Users\nyansterowo\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\methods\advanced\resolve_peer.py", line 121, in resolve_peer
    return await self.storage.get_peer_by_id(peer_id)
  File "C:\Users\nyansterowo\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\storage\sqlite_storage.py", line 147, in get_peer_by_id
    raise KeyError(f"ID not found: {peer_id}")
KeyError: 'ID not found: 5279709634'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\nyansterowo\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\dispatcher.py", line 222, in handler_worker
    await handler.callback(self.client, *args)
  File "C:\Users\nyansterowo\Desktop\tg\src\UserBot.py", line 43, in formessage
    await message.forward(botdata["id"])
  File "C:\Users\nyansterowo\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\types\messages_and_media\message.py", line 2924, in forward
    return await self._client.forward_messages(
  File "C:\Users\nyansterowo\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\methods\messages\forward_messages.py", line 83, in forward_messages
    to_peer=await self.resolve_peer(chat_id),
  File "C:\Users\nyansterowo\AppData\Local\Programs\Python\Python310\lib\site-packages\pyrogram\methods\advanced\resolve_peer.py", line 123, in resolve_peer
    raise PeerIdInvalid
pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it

让我再次提醒你,我写的是自拍,而不是机器人。我可以轻松地通过电报客户端将消息从组转发给某人,但我无法通过代码完成。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-16 16:28:33

首先,你得到的错误是明确的。您的userbot会话尚未满足该组,无法根据其ID识别它。您必须首先从该实体接收任何类型的更新。

参见常见问题条目:https://docs.pyrogram.org/faq/peer-id-invalid-error

其次,您要转发的组在其组设置中可能有转发限制。因为您可以通过官方客户端进行转发,所以情况可能不是这样。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71500708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档