简体   繁体   English

如何使用JAVA / Node.js在TELEGRAM中没有机器人的情况下向群组发送消息

[英]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. 我被要求研究如何在没有机器人的情况下使用JAVA将消息发送到电报频道。 I am totally new to this Telegram API and all the examples I found uses a BOT. 我对这个Telegram API完全陌生,我发现的所有示例都使用了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 我用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) 通过Bot发送(您可以在系统或服务器上运行它)
  • Send by Telegram Cli (You can run it on your system or server) 通过Telegram Cli发送(您可以在系统或服务器上运行它)
  • send by Telegram desktop client .(You can run it on your system or server) 通过Telegram桌面客户端发送。(您可以在系统或服务器上运行它)
  • 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) 通过在可以与核心API电报交互,例如客户端发送, 马拉松式节目的Python语言, MadelineProto为PHP语言, TLSharp为C#语言, Kotlogram对于Java语言等..(可以在系统或服务器上运行)

You can give a try to tdlib/td , a cross-platform library for building Telegram clients created by Telegram in C++. 您可以尝试tdlib/td ,这是一个跨平台的库,用于构建由Telegram在C ++中创建的Telegram客户端。 You can use it in Java via JNI (Java Native Interface). 您可以通过JNI(Java本机接口)在Java中使用它。 They provide a Java client example to help you get started and build your own client. 他们提供了一个Java客户端示例,以帮助您入门和构建自己的客户端。

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: 相关资源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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