gpt4 book ai didi

telegram - 如何让 Telegram Bot 将消息发布到我的 channel 而不是它自己的 channel

转载 作者:行者123 更新时间:2023-12-05 01:04:52 26 4
gpt4 key购买 nike

我有一个 Telegram Bot ,它使用此代码向某个机器人发布消息。

import telegram
from telegram import ParseMode
def send_msg(text):
token = '1*****:AAF*************esns'
chat_id = "34*****4"
bot = telegram.Bot(token=token)

bot.sendMessage(chat_id=chat_id, text=text, parse_mode=ParseMode.MARKDOWN_V2)

我想知道的是, Telegram Bot 是否可以将消息发送到我已将其设为管理员的 channel ,而不是其自己的名为 somebot 的 channel 。

最佳答案

由于您的 Bot 已经是您希望它发布的 channel 的管理员,您只需将 Bot.send_message()chat_id 更改为机器人用于发送帖子的 channel 。

例如,您可以使用 Bgram Telegram client 获取此 ID。或 IDBot .请注意,您可能必须将 -100 添加到您获得的 ID 前,因为 channel 只是特殊的 super 组。

希望对你有帮助;)

关于telegram - 如何让 Telegram Bot 将消息发布到我的 channel 而不是它自己的 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71275683/

26 4 0
文章推荐: haskell - 模式匹配语法不是构造函数应用程序语法
文章推荐: javascript - 如何使用带有 HTML 的 JavaScript 根据颜色 <input> 更改特定
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com