Skip to content

nomad4tech/telegrambot4j-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

telegrambot4j-demo

Example Spring Boot application demonstrating telegrambot4j usage

What's included

  • /start, /help, /scan command handlers
  • Inline buttons demo with callback handling (/buttons)
  • Spring Boot auto-wiring of all handlers via List<UpdateHandler>

Project structure

handler/
  StartCommandHandler.java      - /start command
  HelpHandler.java              - /help command
  ScanCommandHandler.java       - /scan command
  ButtonsCommandHandler.java    - /buttons command, sends inline keyboard
  ButtonsCallbackHandler.java   - handles button callbacks (approve, reject, etc.)
config/
  BotConfiguration.java         - wires TelegramApiClient, UpdateDispatcher, PollingService

Configuration

Add to application.properties:

telegram.bot.token=YOUR_BOT_TOKEN
telegram.bot.name=mybot
telegram.bot.polling.timeout=30
telegram.bot.polling.error-delay=3000

spring.main.keep-alive=true  # Keeps Spring Boot alive after startup

Running

mvn spring-boot:run

GitHub Packages auth

To pull telegrambot4j from GitHub Packages, add to ~/.m2/settings.xml:

<servers>
  <server>
    <id>github</id>
    <username>YOUR_GITHUB_USERNAME</username>
    <password>YOUR_GITHUB_TOKEN</password>
  </server>
</servers>

Token needs read:packages scope.

About

Example Spring Boot application demonstrating telegrambot4j library usage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages