telegram-bot-api
telegram-bot-api copied to clipboard
🤖 telegram bot api by java, help you quickly create a little robot.
telegram-bot-api
这是一个 Telegram 的机器人库,能够帮你快速搭建一个机器人程序运行。
特性
- 快速接入API
- 内置多种实现
- 支持代理,不怕被墙
- 依赖更少,简单最好
- 异步调用,效率更高
- 灵活配置,满足自定义需求
快速接入
下面是Maven坐标
<dependency>
<groupId>io.github.biezhi</groupId>
<artifactId>telegram-bot-api</artifactId>
<version>最新版本</version>
</dependency>
示例代码
GetMe
TelegramBot bot = new TelegramBot(TOKEN);
System.out.println(bot.getMe());
监听文本指令
TelegramBot bot = new TelegramBot(TOKEN);
bot.onCmd("/help", message -> {
log.info("收到消息: {}", message);
bot.text(message, "/echo\r\n/me\r\n/hi");
}).await();
监听贴纸消息
TelegramBot bot = new TelegramBot(TOKEN);
bot.onSticker(message -> {
log.info("收到贴图: {}", message);
}).await();
监听其他消息
TelegramBot bot = new TelegramBot(TOKEN);
bot.onOther(message -> {
log.info("收到消息: {}", message);
}).await();