转发公共频道的每条新消息

发布于 2025-01-11 13:10:43 字数 130 浏览 1 评论 0原文

我想编写一个带有程序的机器人,将公共频道的每一条新消息转发给我。

例如,频道“A”发布一条新消息(该消息的类型可以有所不同),然后我的机器人应该立即将此新消息转发给我。

如果您能评论此问题的任何代码示例,我将非常感激。

I want to write a bot with a program that forwards every single new message of a public channel to me.

For example, channel "A" posts a new message (this message can be varied on its types), and then my bot should immediately forward this new message to me.

I really appreciate it if you can comment any code sample for this issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

几味少女 2025-01-18 13:10:43

Pyrogram 的文档 有几个示例。您可以使用 Echobot 示例并对其进行调整以监视特定聊天,并改用绑定方法 .forward()

https://docs.pyrogram.org/start/examples/echobot


另请注意;机器人只能以管理员身份存在于频道中。您必须要求频道管理员将您的机器人添加为管理员,否则您必须使用用户机器人。除了在代码/配置中添加的机器人令牌之外,这两种情况下的代码本身都是相同的。

Pyrogram's Documentation has several examples. You can use the Echobot example and adapt it to watch for a specific chat and use the bound method .forward() instead.

https://docs.pyrogram.org/start/examples/echobot


On another note; Bots can only exist as Admin in a channel. You'd have to ask the admins of the channel to add your bot as an admin, or you'll have to use a userbot. The Code itself will be the same in both cases, with the exception of the added bot token in your code/config.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文