我有一个私有(private) channel 的邀请链接,我想将此 channel 的帖子转发(或传递)给我。我想要的伪代码如下所示。
def get_channel(bot, update):
message=update.channel_post.text
print(message)
updater = Updater(my_token)
channel_handler = MessageHandler(Filters.text, get_channel,
channel_post_updates=True, invite_link='http://t.me/aa23faba22939bf')
updater.dispatcher.add_handler(channel_handler)
当我的机器人位于我创建的 channel 中时,这很有效(invite_link 是出于我的目的而添加的。我不知道应该在哪里输入 inform_link)。但我想要的是我的机器人转发来自“不”包含我的机器人的 channel 的帖子。我更喜欢 python,但任何 API 都可以。我搜索了整个谷歌世界,但没有任何线索。任何提示表示赞赏。
最佳答案
我找到了 Telethon 库的解决方案。它对我有用( http://telethon.readthedocs.io/en/latest/extra/advanced-usage/update-modes.html )
def callback(update):
print('I received', update)
client = TelegramClient('session', api_id, api_hash,
update_workers=1, spawn_read_thread=False)
client.connect()
client.add_event_handler(callback)
client.idle() # ends with Ctrl+C
在回调函数中,您只能过滤 channel 帖子或群组消息。
关于python - 从 Telegram 私有(private) channel 转发帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50309017/