简体   繁体   中英

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

Hello every one i have right now go for the my app to sync with telegram bot.and i need to send some messages on group on the telegram bot.for ex. i have create one one group on the telegram bot like group name is "Rock" and my bot name is like "ABC". now i need to from my c# side need some create api and send message using group name. i have find many links but all link give idea with chat id. but i want work with group name.here i have create one api for the send message but it's working with chat id and not work for the group.

Here this is my 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");
        }
    }

any one know how can do that please let me know. using group name i want to send message on telegram bot.

You can't use title as parameter to send message, think about two group have same name? :)

If you don't want to send via Chat ID, try group username.

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

The group name isn't unique and telegram can't use that for sending a message. Because a name may be used for several groups. Which one should be selected?

You have no another option but if you want to simplify your code, you can store group-id as const variable:

public const double Rock= '164865465465';  

and use like this:

 SendMessage(Rock, text);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM