You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 27, 2022. It is now read-only.
TelegramBots4Java is a Java implementation of the Telegram Bot API
3
+
##### TelegramBots4Java is a Java implementation of the [Telegram Bot API](https://core.telegram.org/bots/api)
4
4
5
-
See [https://core.telegram.org/bots/api](https://core.telegram.org/bots/api)
5
+
This API is designed to be *extensible*, while preserving *simplicity* and *conciseness*.
6
+
It provides [core classes](https://cdn.rawgit.com/pevdh/TelegramBots4Java/master/docs/co/vandenham/telegram/botapi/requests/package-summary.html) to interact with the Telegram Bot API, and it encapsulates these classes in [one simple, extensible class](https://cdn.rawgit.com/pevdh/TelegramBots4Java/master/docs/co/vandenham/telegram/botapi/TelegramBot.html). However, nothing holds you back to use the [core classes](https://cdn.rawgit.com/pevdh/TelegramBots4Java/master/docs/co/vandenham/telegram/botapi/requests/package-summary.html) directly.
You'll find the .jar file in the api\build\libs directory.
22
25
23
-
For now, you can check out the [EchoBot example](https://github.com/pevdh/TelegramBots4Java/tree/master/EchoBot/src/main/java/co/vandenham/telegram/botapi/examples) and the [Javadocs](https://cdn.rawgit.com/pevdh/TelegramBots4Java/master/docs/index.html)
26
+
## How to use
27
+
28
+
### A simple echo bot
29
+
*The import statements are left out for simplicity.*
30
+
31
+
```java
32
+
publicclassEchoBotextendsTelegramBot {
33
+
34
+
publicEchoBot() {
35
+
super("<YOUR_BOT_TOKEN>");
36
+
}
37
+
38
+
// This handler gets called whenever a user sends /start or /help
39
+
@CommandHandler({"start", "help"})
40
+
publicvoidhandleHelp(Messagemessage) {
41
+
replyTo(message, "Hi there! I am here to echo all your kind words back to you!");
42
+
}
43
+
44
+
// This handler gets called whenever a user sends a general text message.
// This is the default handler, called when the other two handlers don't apply.
52
+
@DefaultHandler
53
+
publicvoidhandleDefault(Messagemessage) {
54
+
replyTo(message, "Say what?");
55
+
}
56
+
57
+
publicstaticvoidmain(String[] args) {
58
+
TelegramBot bot =newEchoBot();
59
+
bot.start();
60
+
}
61
+
}
62
+
```
63
+
### Further reference
64
+
This project has [Javadocs](https://cdn.rawgit.com/pevdh/TelegramBots4Java/master/docs/index.html).
65
+
66
+
*TelegramBot.java* provides a good entry point into this API. You can have a look at the [Javadoc reference](https://cdn.rawgit.com/pevdh/TelegramBots4Java/master/docs/co/vandenham/telegram/botapi/TelegramBot.html) for this class, or look at the [source code](https://github.com/pevdh/TelegramBots4Java/blob/master/api/src/main/java/co/vandenham/telegram/botapi/TelegramBot.java) directly.
0 commit comments