TelegramBots/telegrambots-chat-session-bot
Andrea Cavalli 6ea5b8c540 Merge commit 'b03fe98798192840402168e6e422d1b4cee48279'
Conflicts:
	pom.xml
	telegrambots-spring-boot-starter/pom.xml
	telegrambots/pom.xml
	telegrambots/src/main/java/org/telegram/telegrambots/updatesreceivers/DefaultWebhook.java
2020-11-11 15:40:29 +01:00
..
src/main/java/org/telegram/telegrambots/session Remove Guice 2020-11-03 02:57:36 +00:00
README.md Updage 5.0.1 2020-11-08 16:19:38 +00:00
pom.xml Merge commit 'b03fe98798192840402168e6e422d1b4cee48279' 2020-11-11 15:40:29 +01:00

README.md

Build Status Jitpack Telegram

Usage

Maven

    <dependency>
        <groupId>org.telegram</groupId>
        <artifactId>telegrambots-chat-session-bot</artifactId>
        <version>5.0.1</version>
    </dependency>

Motivation

Implementation of bot dialogs require saving some data about current state of conversation. That brings us to idea of chat session management.

How to use

Chat session bot was implemented by using Shiro Apache session manager. That allow to manage and store sessions.

To create default Long Polling Session Bot with in-memory store, you need simply implement TelegramLongPollingSessionBot

public class ExampleBotWithSession extends TelegramLongPollingSessionBot {

    @Override
    public void onUpdateReceived(Update update, Optional<Session> optionalSession) {
        //Do some action with update and session        
    }

    @Override
    public String getBotUsername() {
        return "ExampleBotWithSessionBot";
    }

    @Override
    public String getBotToken() {
        return "1234";
    }
}

Where session is implementation of org.apache.shiro.session.Session