所以我有这个 python 代码,它计算出频道聊天 ID,以便为给定列表中的多个频道发送消息。
我只有频道邀请链接
我仍然不知道如何仅通过名称获取频道 ID。
import os
import telebot
API_KEY = os.environ['API_KEY']
bot = telebot.TeleBot(API_KEY)
a=input("edit msg.txt to send the msg if done press enter")
message=open("message.txt","a+")
bot.send_message(chat_id,message)
答案 0 :(得分:0)
您可以使用 getChat
方法将频道用户名解析为聊天 ID。您也可以仅使用用户名发送消息 - 请参阅 sendMessage
的文档,例如this answer。