-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
Ivan Karmanov edited this page Jul 5, 2025
·
1 revision
@Configuration
@EnableConfigurationProperties(BotProperties.class)
public class BotConfig {
private final BotProperties botProperties;
public BotConfig(BotProperties botProperties) {
this.botProperties = botProperties;
}
@Bean
public TelegramBot telegramBot() {
return new TelegramBot(botProperties.token(), botProperties.name(), botProperties.webHookPath());
}
@Bean
public BotHandler botHandler() {
return new DefaultBotHandler();
}
}@RestController
public class WebHookController {
private final BotHandler botHandler;
public WebHookController(BotHandler botHandler) {
this.botHandler = botHandler;
}
@PostMapping("/webhook")
public ResponseEntity<?> receiveWebhook(@RequestBody Update update) {
botHandler.handleMessage(update);
return ResponseEntity.ok().build();
}
}- Текстовые сообщения (@BotText)
- Callback-запросы (@BotCallBack)
- Документы (@BotDocument)
- Голосовые (@BotVoice)
- Медиафайлы (@BotMedia)
- Фото (@BotPhoto)
- Геолокация (@BotLocation)
- Планировщик (@BotScheduled)
- Ограничение по ролям (@RoleBasedAccess)