Skip to content

Version 1.0.1

Compare
Choose a tag to compare
@nazarovctrl nazarovctrl released this 21 Aug 06:28
· 52 commits to master since this release
cdbd66f

Java documentation

Library link in Maven Central

Maven dependency

    <dependency>
        <groupId>io.github.nazarovctrl</groupId>
        <artifactId>telegram-bot-spring</artifactId>
        <version>1.0.1</version>
    </dependency>

How to use library?

$\textcolor{red}{\textsf{*}}$ required steps

1.Add annotation @EnableTelegramLongPollingBot or @EnableTelegramWebhookBot $\textcolor{red}{\textsf{*}}$

image_2023-08-20_20-52-11
Use @EnableTelegramLongPollingBot annotation for creating telegram bot without webhook
Use @EnableTelegramWebhookBot annotation for telegram bot with webhook

2.Inherit from @updatecontroller abstract class $\textcolor{red}{\textsf{*}}$

image_2023-08-20_21-59-15
Override handle method
Make your class as a bean. In previous picture was used @Service annonation for making the class as a bean

3.Add bot configuration to application.properties $\textcolor{red}{\textsf{*}}$

image_2023-08-20_21-00-24
$\textcolor{red}{\textsf{Red line}}$ is always required field
bot.name your telegram bot username
bot.token your telegram bot token
If you are creating telegram bot with webhook you need to add bot.uri otherwise you don't need

4.Send messages(text,media etc.) with MessageSender

image_2023-08-20_23-48-20
Inject MessageSender
Use execute method of MessageSender
image_2023-08-20_21-15-45