Update to version 4.0.0

This commit is contained in:
Ruben Bermudez 2018-07-27 00:48:40 +02:00
parent fe10bc8c03
commit 1c1f340dc9
7 changed files with 183 additions and 31 deletions

136
Bots.ipr
View File

@ -18,6 +18,7 @@
<outputRelativeToContentRoot value="true" />
<module name="telegrambots" />
<module name="telegrambots-abilities" />
<module name="telegrambots-chat-session-bot" />
<module name="telegrambots-extensions" />
<module name="telegrambots-meta" />
<module name="telegrambots-spring-boot-starter" />
@ -33,6 +34,7 @@
<module name="Bots" target="1.5" />
<module name="telegrambots" target="1.8" />
<module name="telegrambots-abilities" target="1.8" />
<module name="telegrambots-chat-session-bot" target="1.8" />
<module name="telegrambots-extensions" target="1.8" />
<module name="telegrambots-meta" target="1.8" />
<module name="telegrambots-spring-boot-starter" target="1.8" />
@ -502,6 +504,7 @@
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="file://$PROJECT_DIR$/telegrambots" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/telegrambots-abilities" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/telegrambots-chat-session-bot" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/telegrambots-extensions" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/telegrambots-meta" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/telegrambots-spring-boot-starter" charset="UTF-8" />
@ -840,6 +843,7 @@
<module fileurl="file://$PROJECT_DIR$/Bots.iml" filepath="$PROJECT_DIR$/Bots.iml" />
<module fileurl="file://$PROJECT_DIR$/telegrambots/telegrambots.iml" filepath="$PROJECT_DIR$/telegrambots/telegrambots.iml" />
<module fileurl="file://$PROJECT_DIR$/telegrambots-abilities/telegrambots-abilities.iml" filepath="$PROJECT_DIR$/telegrambots-abilities/telegrambots-abilities.iml" />
<module fileurl="file://$PROJECT_DIR$/telegrambots-chat-session-bot/telegrambots-chat-session-bot.iml" filepath="$PROJECT_DIR$/telegrambots-chat-session-bot/telegrambots-chat-session-bot.iml" />
<module fileurl="file://$PROJECT_DIR$/telegrambots-extensions/telegrambots-extensions.iml" filepath="$PROJECT_DIR$/telegrambots-extensions/telegrambots-extensions.iml" />
<module fileurl="file://$PROJECT_DIR$/telegrambots-meta/telegrambots-meta.iml" filepath="$PROJECT_DIR$/telegrambots-meta/telegrambots-meta.iml" />
<module fileurl="file://$PROJECT_DIR$/telegrambots-spring-boot-starter/telegrambots-spring-boot-starter.iml" filepath="$PROJECT_DIR$/telegrambots-spring-boot-starter/telegrambots-spring-boot-starter.iml" />
@ -980,6 +984,17 @@
<root url="jar://$MAVEN_REPOSITORY$/com/google/inject/guice/4.1.0/guice-4.1.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: commons-beanutils:commons-beanutils:1.9.3">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: commons-codec:commons-codec:1.9">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.9/commons-codec-1.9.jar!/" />
@ -991,6 +1006,17 @@
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.9/commons-codec-1.9-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: commons-collections:commons-collections:3.2.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: commons-io:commons-io:2.5">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.5/commons-io-2.5.jar!/" />
@ -1156,6 +1182,105 @@
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpmime/4.5.3/httpmime-4.5.3-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-cache:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-cache/1.4.0/shiro-cache-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-cache/1.4.0/shiro-cache-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-cache/1.4.0/shiro-cache-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-config-core:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-config-core/1.4.0/shiro-config-core-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-config-core/1.4.0/shiro-config-core-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-config-core/1.4.0/shiro-config-core-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-config-ogdl:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-config-ogdl/1.4.0/shiro-config-ogdl-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-config-ogdl/1.4.0/shiro-config-ogdl-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-config-ogdl/1.4.0/shiro-config-ogdl-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-core:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-core/1.4.0/shiro-core-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-core/1.4.0/shiro-core-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-core/1.4.0/shiro-core-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-crypto-cipher:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-cipher/1.4.0/shiro-crypto-cipher-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-cipher/1.4.0/shiro-crypto-cipher-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-cipher/1.4.0/shiro-crypto-cipher-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-crypto-core:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-core/1.4.0/shiro-crypto-core-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-core/1.4.0/shiro-crypto-core-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-core/1.4.0/shiro-crypto-core-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-crypto-hash:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-hash/1.4.0/shiro-crypto-hash-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-hash/1.4.0/shiro-crypto-hash-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-crypto-hash/1.4.0/shiro-crypto-hash-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-event:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-event/1.4.0/shiro-event-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-event/1.4.0/shiro-event-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-event/1.4.0/shiro-event-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.shiro:shiro-lang:1.4.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-lang/1.4.0/shiro-lang-1.4.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-lang/1.4.0/shiro-lang-1.4.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/shiro/shiro-lang/1.4.0/shiro-lang-1.4.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.assertj:assertj-core:3.9.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/assertj/assertj-core/3.9.1/assertj-core-3.9.1.jar!/" />
@ -1541,6 +1666,17 @@
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-all/2.0.2-beta/mockito-all-2.0.2-beta-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.slf4j:slf4j-api:1.7.21">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.0.2.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-autoconfigure/2.0.2.RELEASE/spring-boot-autoconfigure-2.0.2.RELEASE.jar!/" />

View File

@ -1,11 +1,8 @@
<div align="center">
<img src="https://github.com/addo37/AbilityBots/blob/gh-pages/images/API%20BOT-03.png?raw=true" alt="abilitybots" width="200" height="200"/>
[![Build Status](https://travis-ci.org/rubenlagus/TelegramBots.svg?branch=master)](https://travis-ci.org/rubenlagus/TelegramBots)
[![Jitpack](https://jitpack.io/v/rubenlagus/TelegramBots.svg)](https://jitpack.io/#rubenlagus/TelegramBots)
[![JavaDoc](http://svgur.com/i/1Ex.svg)](https://addo37.github.io/AbilityBots/)
[![Telegram](http://trellobot.doomdns.org/telegrambadge.svg)](https://telegram.me/JavaBotsApi)
[![ghit.me](https://ghit.me/badge.svg?repo=rubenlagus/TelegramBots)](https://ghit.me/repo/rubenlagus/TelegramBots)
</div>
@ -18,7 +15,7 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-chat-session-bot</artifactId>
<version>3.6.1</version>
<version>4.0.0</version>
</dependency>
```

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-chat-session-bot</artifactId>
<version>3.6.1</version>
<version>4.0.0</version>
<packaging>jar</packaging>
<name>Telegram Bots Chat Session Bot</name>
@ -29,6 +29,12 @@
</ciManagement>
<developers>
<developer>
<email>rberlopez@gmail.com</email>
<name>Ruben Bermudez</name>
<url>https://github.com/rubenlagus</url>
<id>rubenlagus</id>
</developer>
<developer>
<email>bochkarevei@gmail.com</email>
<name>Egor Bochkarev</name>
@ -59,8 +65,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bots.version>3.6.1</bots.version>
<lombok.version>1.16.20</lombok.version>
<bots.version>4.0.0</bots.version>
<shiro.version>1.4.0</shiro.version>
</properties>
@ -79,14 +84,6 @@
<version>${shiro.version}</version>
</dependency>
<!--Adding additional functionality to classes (getter/setter)-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>

View File

@ -6,5 +6,5 @@ import org.apache.shiro.session.mgt.eis.SessionIdGenerator;
import java.io.Serializable;
public interface ChatIdConverter extends SessionKey, SessionIdGenerator {
public void setSessionId(Serializable sessionId);
void setSessionId(Serializable sessionId);
}

View File

@ -1,16 +1,22 @@
package org.telegram.telegrambots.session;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.apache.shiro.session.Session;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@SuppressWarnings({"unused", "WeakerAccess"})
public class DefaultChatIdConverter implements ChatIdConverter {
private long sessionId;
public DefaultChatIdConverter() {
super();
}
public DefaultChatIdConverter(long sessionId) {
this();
this.sessionId = sessionId;
}
@Override
public void setSessionId(Serializable sessionId){
this.sessionId = (long) sessionId;

View File

@ -1,20 +1,30 @@
package org.telegram.telegrambots.session;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.apache.shiro.session.mgt.SessionContext;
import java.io.Serializable;
import java.util.HashMap;
@AllArgsConstructor
@SuppressWarnings("WeakerAccess")
public class DefaultChatSessionContext extends HashMap<String, Object> implements SessionContext {
private long sessionId;
@Setter
@Getter
private String host;
public DefaultChatSessionContext(long sessionId, String host) {
this.sessionId = sessionId;
this.host = host;
}
@Override
public String getHost() {
return host;
}
@Override
public void setHost(String host) {
this.host = host;
}
@Override
public Serializable getSessionId() {
return sessionId;

View File

@ -1,22 +1,20 @@
package org.telegram.telegrambots.session;
import lombok.Setter;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.UnknownSessionException;
import org.apache.shiro.session.mgt.DefaultSessionManager;
import org.apache.shiro.session.mgt.SessionContext;
import org.apache.shiro.session.mgt.eis.AbstractSessionDAO;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import java.util.Optional;
@SuppressWarnings({"WeakerAccess", "OptionalUsedAsFieldOrParameterType", "unused"})
public abstract class TelegramLongPollingSessionBot extends TelegramLongPollingBot {
@Setter
DefaultSessionManager sessionManager;
@Setter
ChatIdConverter chatIdConverter;
public TelegramLongPollingSessionBot(){
@ -30,6 +28,14 @@ public abstract class TelegramLongPollingSessionBot extends TelegramLongPollingB
sessionDAO.setSessionIdGenerator(chatIdConverter);
}
public void setSessionManager(DefaultSessionManager sessionManager) {
this.sessionManager = sessionManager;
}
public void setChatIdConverter(ChatIdConverter chatIdConverter) {
this.chatIdConverter = chatIdConverter;
}
@Override
public void onUpdateReceived(Update update) {
Optional<Session> chatSession;