如何获取私人 Telegram 频道的 chat

编程入门 行业动态 更新时间:2024-10-25 13:23:10
本文介绍了如何获取私人 Telegram 频道的 chat_id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我使用 curl 来更新我的公共频道.这种语法:

I use curl to update my public channels. This kind of syntax:

curl -X POST "https://api.telegram/bot144377327:AAGqdElkZ-77zsPRoAXXXXXXXXXX/sendMessage" -d "chat_id=@MyChannel&text=my sample text"

但是私人频道的 chat_id 是什么?这不是您在私人邀请中拥有的那个.

But what's the chat_id of a private channel? It's not the one you have in the private invite.

因为现在我们可以在所有方法中传递一个频道用户名(格式为@channelusername)代替chat_id(而不是forwardMessage中的from_chat_id).但是我管理的私人频道的@channelusername 是什么?

Because now we can pass a channel username (in the format @channelusername) in the place of chat_id in all methods (and instead of from_chat_id in forwardMessage). But what's the @channelusername of a private channel that I administer?

推荐答案

我在私人频道找到了写作的方法.

I found the way to write in private channels.

你应该使用@channelName 将其转换为公开

You should convert it to public with some @channelName

通过 Bot API 向该频道发送消息

Send message to this channel through Bot API

https://api.telegram/bot111:222/sendMessage?chat_id=@channelName&text=123

作为回复,您将获得带有您频道的 chat_id 的信息.

As response you will get info with chat_id of your channel.

{
  "ok" : true,
  "result" : {
    "chat" : {
      **"id" : -1001005582487,**
      "title" : "Test Private Channel",
      "type" : "channel"
    },
    "date" : 1448245538,
    "message_id" : 7,
    "text" : "123ds"
  }
}

现在您可以将频道转换回私人频道(通过删除频道的链接)并直接向此 chat_id -1001005582487"发送消息

Now you can convert Channel back to private (by deleting channel's link) and send message directly to this chat_id "-1001005582487"

https://api.telegram/bot111:222/sendMessage?chat_id=-1001005582487&text=123

这篇关于如何获取私人 Telegram 频道的 chat_id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 07:06:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:私人   频道   Telegram   chat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!