简体   繁体   中英

How to send a message to a group without a bot in TELEGRAM using JAVA/Node.js

I have been asked to research in How to send a message to a telegram channel without a bot using JAVA. I am totally new to this Telegram API and all the examples I found uses a BOT. Could anyone please help me to start with a sample code with NO Bots please.

Thanks and really appreciate your views on this.

I didn't work much by Java

But in general, you can use the following ways to send a message to the telegram:

  • Send by Bot (You can run it on your system or server)
  • Send by Telegram Cli (You can run it on your system or server)
  • send by Telegram desktop client .(You can run it on your system or server)
  • Send by clients that can interact with Core API Telegram, for example, Telethon for Python language, MadelineProto for PHP language, TLSharp for C# language, Kotlogram for Java language and Etc... (You can run it on your system or server)

You can give a try to tdlib/td , a cross-platform library for building Telegram clients created by Telegram in C++. You can use it in Java via JNI (Java Native Interface). They provide a Java client example to help you get started and build your own client.

Their example provides the code for sending a message:

private static void sendMessage(long chatId, String message) {
    // initialize reply markup just for testing
    TdApi.InlineKeyboardButton[] row = {new TdApi.InlineKeyboardButton("https://telegram.org?1", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?2", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?3", new TdApi.InlineKeyboardButtonTypeUrl())};
    TdApi.ReplyMarkup replyMarkup = new TdApi.ReplyMarkupInlineKeyboard(new TdApi.InlineKeyboardButton[][]{row, row, row});

    TdApi.InputMessageContent content = new TdApi.InputMessageText(new TdApi.FormattedText(message, null), false, true);
    client.send(new TdApi.SendMessage(chatId, 0, false, false, replyMarkup, content), defaultHandler);
}

Related resources:

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