转发公共频道的每条新消息
我想编写一个带有程序的机器人,将公共频道的每一条新消息转发给我。
例如,频道“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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.