如何在使用 c# 的电报机器人上使用组名而不是聊天 ID 在组中发送消息?

How to send message in the group using group name not a chat id on telegram bot using c#?

大家好,我现在让我的应用程序与电报同步 bot.and 我需要在电报 bot.for 上发送一些消息。我在电报机器人上创建了一个群组,群组名称是 "Rock",我的机器人名称是 "ABC"。现在我需要从我的 C# 端创建 api 并使用组名发送消息。我找到了很多 link,但所有 link 都提供了带有聊天 ID 的想法。但我想与群组 name.here 一起工作 我已经为发送消息创建了一个 api 但它正在使用聊天 ID,而不是为群组工作。

这是我的 api =>

 [System.Web.Http.AcceptVerbs("GET", "POST")]
    public void sendMessage(string destID, string text)
    {
        try
        {
            Bot.SendTextMessageAsync(destID, text);                
        }
        catch (Exception e)
        {
            Console.WriteLine("err");
        }
    }

任何人都知道怎么做,请告诉我。使用组名我想在电报机器人上发送消息。

不能用title作为参数来发消息,想想两个群同名? :)

如果您不想通过聊天 ID 发送,请尝试群组用户名。

Unique identifier for the target chat or username of the target channel (in the format @channelusername)

组名不是唯一的,telegram 不能用它来发送消息。因为一个名称可能用于多个组。应该选哪一个?

你别无选择,但如果你想简化代码,你可以将 group-id 存储为 const 变量:

public const double Rock= '164865465465';  

并像这样使用:

 SendMessage(Rock, text);