release-0.0.2
This commit is contained in:
parent
6f73b7f93a
commit
47d8f4d92b
307
pom.xml
307
pom.xml
@ -3,12 +3,13 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.sadtech.bot.godfather</groupId>
|
||||
<artifactId>telegram</artifactId>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>telegram-bot</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<packaging>pom</packaging>
|
||||
<version>0.0.1-RELEASE</version>
|
||||
|
||||
<modules>
|
||||
<module>telegram-bot</module>
|
||||
<module>telegram-core</module>
|
||||
</modules>
|
||||
|
||||
<name>Telegram Bot</name>
|
||||
@ -16,31 +17,167 @@
|
||||
<url>https://github.com/Godfather-Bots/telegram-bot</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
|
||||
<comments>
|
||||
Copyright 2010 the original author or authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
</comments>
|
||||
<name>BSD 3-Clause "New" or "Revised" License</name>
|
||||
<url>https://github.com/Godfather-Bots/godfather/blob/master/LICENSE</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/Godfather-Bots/telegram-bot/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<organization>
|
||||
<name>SADTECH</name>
|
||||
<url>https://sadtech.org</url>
|
||||
</organization>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<godfather.core.ver>0.0.2</godfather.core.ver>
|
||||
<telegrambots.ver>5.4.0.1</telegrambots.ver>
|
||||
|
||||
<plugin.maven.compiler.ver>3.9.0</plugin.maven.compiler.ver>
|
||||
<plugin.nexus.staging.ver>1.6.8</plugin.nexus.staging.ver>
|
||||
<plugin.maven.source.ver>3.2.1</plugin.maven.source.ver>
|
||||
<plugin.maven.javadoc.ver>3.3.1</plugin.maven.javadoc.ver>
|
||||
<plugin.maven.gpg.ver>3.0.1</plugin.maven.gpg.ver>
|
||||
<xstream.ver>1.4.15</xstream.ver>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<version>${godfather.core.ver}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>${telegrambots.ver}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-abilities</artifactId>
|
||||
<version>${telegrambots.ver}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambotsextensions</artifactId>
|
||||
<version>${telegrambots.ver}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>${plugin.nexus.staging.ver}</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>${xstream.ver}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${plugin.maven.source.ver}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${plugin.maven.javadoc.ver}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>${plugin.maven.gpg.ver}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${plugin.maven.compiler.ver}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://github.com/Godfather-Bots/telegram-bot.git</connection>
|
||||
@ -55,126 +192,12 @@
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/Godfather-Bots/telegram-bot/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.sadtech.social</groupId>
|
||||
<artifactId>social-bot</artifactId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots</artifactId>
|
||||
<version>4.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambots-abilities</artifactId>
|
||||
<version>4.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
<artifactId>telegrambotsextensions</artifactId>
|
||||
<version>4.4.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>uPagge</id>
|
||||
<name>Struchkov Mark</name>
|
||||
<email>upagge@ya.ru</email>
|
||||
<organization>SADTECH</organization>
|
||||
<organizationUrl>https://sadtech.org</organizationUrl>
|
||||
<url>https://uPagge.sadtech.org</url>
|
||||
<roles>
|
||||
<role>Project lead</role>
|
||||
</roles>
|
||||
<timezone>+3</timezone>
|
||||
<email>mark@struchkov.dev</email>
|
||||
<url>https://mark.struchkov.dev</url>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
//package org.sadtech.telegram.bot;
|
||||
//
|
||||
//import lombok.NonNull;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.sadtech.telegram.bot.config.TelegramWebHookConfig;
|
||||
//import org.sadtech.telegram.bot.listen.EventDistributor;
|
||||
//import org.sadtech.telegram.bot.listen.EventDistributorImpl;
|
||||
//import org.telegram.telegrambots.bots.TelegramWebhookBot;
|
||||
//import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
//import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
//import org.telegram.telegrambots.meta.bots.AbsSender;
|
||||
//
|
||||
///**
|
||||
// * TODO: Добавить описание класса.
|
||||
// *
|
||||
// * @author upagge [12.02.2020]
|
||||
// */
|
||||
//@RequiredArgsConstructor
|
||||
//public class TelegramHookBot extends TelegramWebhookBot implements TelegramBot {
|
||||
//
|
||||
// private final TelegramWebHookConfig webHookConfig;
|
||||
// private EventDistributor eventDistributor;
|
||||
//
|
||||
// @Override
|
||||
// public BotApiMethod onWebhookUpdateReceived(Update update) {
|
||||
// return eventDistributor.processing(update);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getBotUsername() {
|
||||
// return webHookConfig.getBotUsername();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getBotToken() {
|
||||
// return webHookConfig.getBotToken();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getBotPath() {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public AbsSender getAdsSender() {
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initEventDistributor(@NonNull EventDistributorImpl eventDistributor) {
|
||||
// this.eventDistributor = eventDistributor;
|
||||
// }
|
||||
//
|
||||
//}
|
@ -1,29 +0,0 @@
|
||||
package org.sadtech.bot.godfather.telegram.convert;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.sadtech.social.core.domain.content.Mail;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание класса.
|
||||
*
|
||||
* @author upagge [18.08.2019]
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class MessageMailConvert {
|
||||
|
||||
public static Mail apply(Message message) {
|
||||
Mail mail = new Mail();
|
||||
mail.setPersonId(message.getChatId());
|
||||
mail.setAddDate(LocalDateTime.now());
|
||||
mail.setText(message.getText());
|
||||
mail.setCreateDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(message.getDate()), ZoneId.systemDefault()));
|
||||
return mail;
|
||||
}
|
||||
|
||||
}
|
@ -3,23 +3,25 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.sadtech.bot.godfather</groupId>
|
||||
<artifactId>telegram</artifactId>
|
||||
<version>0.0.1-RELEASE</version>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>telegram-bot</artifactId>
|
||||
<version>0.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>telegram-bot</artifactId>
|
||||
<version>0.0.1-RELEASE</version>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>telegram-core</artifactId>
|
||||
<version>0.0.2</version>
|
||||
|
||||
<name>Telegram Core</name>
|
||||
<description>Allows you to create bots for Telegram</description>
|
||||
<url>https://github.com/uPagge/telegram-bot</url>
|
||||
|
||||
<properties>
|
||||
<skip.deploy>false</skip.deploy>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.sadtech.social</groupId>
|
||||
<artifactId>social-bot</artifactId>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -38,19 +40,20 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>uPagge</id>
|
||||
<name>Struchkov Mark</name>
|
||||
<email>upagge@ya.ru</email>
|
||||
<organization>SADTECH</organization>
|
||||
<organizationUrl>https://sadtech.org</organizationUrl>
|
||||
<url>https://uPagge.sadtech.org</url>
|
||||
<roles>
|
||||
<role>Project lead</role>
|
||||
</roles>
|
||||
<timezone>+3</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipNexusStagingDeployMojo>${skip.deploy}</skipNexusStagingDeployMojo>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,4 +1,4 @@
|
||||
package org.sadtech.bot.godfather.telegram;
|
||||
package dev.struchkov.godfather.telegram;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
@ -1,7 +1,7 @@
|
||||
package org.sadtech.bot.godfather.telegram;
|
||||
package dev.struchkov.godfather.telegram;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.bot.godfather.telegram.listen.EventDistributorImpl;
|
||||
import dev.struchkov.godfather.telegram.listen.EventDistributorImpl;
|
||||
import org.telegram.telegrambots.meta.bots.AbsSender;
|
||||
|
||||
/**
|
@ -1,9 +1,9 @@
|
||||
package org.sadtech.bot.godfather.telegram;
|
||||
package dev.struchkov.godfather.telegram;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.bot.godfather.telegram.listen.EventDistributorImpl;
|
||||
import org.sadtech.bot.godfather.telegram.config.TelegramPollingConfig;
|
||||
import org.sadtech.bot.godfather.telegram.listen.EventDistributor;
|
||||
import dev.struchkov.godfather.telegram.listen.EventDistributorImpl;
|
||||
import dev.struchkov.godfather.telegram.config.TelegramPollingConfig;
|
||||
import dev.struchkov.godfather.telegram.listen.EventDistributor;
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions;
|
||||
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
@ -1,11 +1,11 @@
|
||||
package org.sadtech.bot.godfather.telegram.autoresponder;
|
||||
package dev.struchkov.godfather.telegram.autoresponder;
|
||||
|
||||
import dev.struchkov.godfather.context.domain.content.Mail;
|
||||
import dev.struchkov.godfather.context.service.MessageService;
|
||||
import dev.struchkov.godfather.context.service.sender.Sending;
|
||||
import dev.struchkov.godfather.core.GeneralAutoResponder;
|
||||
import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
||||
import org.sadtech.autoresponder.repository.UnitPointerRepository;
|
||||
import org.sadtech.social.bot.GeneralAutoResponder;
|
||||
import org.sadtech.social.bot.domain.unit.MainUnit;
|
||||
import org.sadtech.social.core.domain.content.Mail;
|
||||
import org.sadtech.social.core.service.MessageService;
|
||||
import org.sadtech.social.core.service.sender.Sending;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package org.sadtech.bot.godfather.telegram.config;
|
||||
package dev.struchkov.godfather.telegram.config;
|
||||
|
||||
import dev.struchkov.godfather.telegram.ProxyConfig;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.bot.godfather.telegram.ProxyConfig;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание класса.
|
@ -1,4 +1,4 @@
|
||||
package org.sadtech.bot.godfather.telegram.config;
|
||||
package dev.struchkov.godfather.telegram.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
@ -1,6 +1,6 @@
|
||||
package org.sadtech.bot.godfather.telegram.convert;
|
||||
package dev.struchkov.godfather.telegram.convert;
|
||||
|
||||
import org.sadtech.social.core.domain.content.Mail;
|
||||
import dev.struchkov.godfather.context.domain.content.Mail;
|
||||
import org.telegram.telegrambots.meta.api.objects.CallbackQuery;
|
||||
|
||||
import java.time.LocalDateTime;
|
@ -0,0 +1,57 @@
|
||||
package dev.struchkov.godfather.telegram.convert;
|
||||
|
||||
import dev.struchkov.godfather.context.domain.content.Mail;
|
||||
import dev.struchkov.godfather.context.domain.content.attachment.Attachment;
|
||||
import dev.struchkov.godfather.context.domain.content.attachment.Link;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.MessageEntity;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание класса.
|
||||
*
|
||||
* @author upagge [18.08.2019]
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class MessageMailConvert {
|
||||
|
||||
public static Mail apply(Message message) {
|
||||
Mail mail = new Mail();
|
||||
mail.setPersonId(message.getChatId());
|
||||
mail.setAddDate(LocalDateTime.now());
|
||||
mail.setText(message.getText());
|
||||
mail.setCreateDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(message.getDate()), ZoneId.systemDefault()));
|
||||
List<MessageEntity> entities = message.getEntities();
|
||||
if (entities != null) {
|
||||
mail.setAttachments(convertAttachments(entities));
|
||||
}
|
||||
|
||||
if (message.getReplyToMessage() != null) {
|
||||
mail.setForwardMail(Collections.singletonList(apply(message.getReplyToMessage())));
|
||||
}
|
||||
|
||||
return mail;
|
||||
}
|
||||
|
||||
private static List<Attachment> convertAttachments(List<MessageEntity> entities) {
|
||||
final List<Attachment> attachments = new ArrayList();
|
||||
for (MessageEntity entity : entities) {
|
||||
String type = entity.getType();
|
||||
if ("text_link".equals(type)) {
|
||||
Link link = new Link();
|
||||
link.setUrl(entity.getUrl());
|
||||
attachments.add(link);
|
||||
}
|
||||
}
|
||||
return attachments;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.sadtech.bot.godfather.telegram.listen;
|
||||
package dev.struchkov.godfather.telegram.listen;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
@ -1,9 +1,9 @@
|
||||
package org.sadtech.bot.godfather.telegram.listen;
|
||||
package dev.struchkov.godfather.telegram.listen;
|
||||
|
||||
import dev.struchkov.godfather.context.service.MailService;
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.social.core.service.MailService;
|
||||
import org.sadtech.bot.godfather.telegram.convert.CallbackQueryConvert;
|
||||
import org.sadtech.bot.godfather.telegram.convert.MessageMailConvert;
|
||||
import dev.struchkov.godfather.telegram.convert.CallbackQueryConvert;
|
||||
import dev.struchkov.godfather.telegram.convert.MessageMailConvert;
|
||||
import org.telegram.telegrambots.meta.api.objects.CallbackQuery;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
@ -1,16 +1,15 @@
|
||||
package org.sadtech.bot.godfather.telegram.listen;
|
||||
package dev.struchkov.godfather.telegram.listen;
|
||||
|
||||
import dev.struchkov.godfather.telegram.ProxyConfig;
|
||||
import dev.struchkov.godfather.telegram.TelegramBot;
|
||||
import dev.struchkov.godfather.telegram.TelegramPollingBot;
|
||||
import dev.struchkov.godfather.telegram.config.TelegramPollingConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.sadtech.bot.godfather.telegram.ProxyConfig;
|
||||
import org.sadtech.bot.godfather.telegram.TelegramBot;
|
||||
import org.sadtech.bot.godfather.telegram.TelegramPollingBot;
|
||||
import org.sadtech.bot.godfather.telegram.config.TelegramPollingConfig;
|
||||
import org.telegram.telegrambots.ApiContextInitializer;
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions;
|
||||
import org.telegram.telegrambots.meta.ApiContext;
|
||||
import org.telegram.telegrambots.meta.TelegramBotsApi;
|
||||
import org.telegram.telegrambots.meta.bots.AbsSender;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
|
||||
|
||||
import java.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
@ -23,10 +22,6 @@ import java.net.PasswordAuthentication;
|
||||
@Slf4j
|
||||
public class TelegramConnect {
|
||||
|
||||
static {
|
||||
ApiContextInitializer.init();
|
||||
}
|
||||
|
||||
private TelegramBot telegramBot;
|
||||
|
||||
public TelegramConnect(TelegramPollingConfig telegramPollingConfig) {
|
||||
@ -66,21 +61,27 @@ public class TelegramConnect {
|
||||
}
|
||||
}
|
||||
|
||||
TelegramBotsApi botapi = new TelegramBotsApi();
|
||||
final TelegramBotsApi botapi;
|
||||
try {
|
||||
if (proxyConfig != null && proxyConfig.getHost() != null) {
|
||||
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
|
||||
System.setProperty("javax.net.debug", "all");
|
||||
log.info(System.getProperty("https.protocols"));
|
||||
DefaultBotOptions botOptions = ApiContext.getInstance(DefaultBotOptions.class);
|
||||
DefaultBotOptions botOptions = new DefaultBotOptions();
|
||||
botOptions.setProxyHost(proxyConfig.getHost());
|
||||
botOptions.setProxyPort(proxyConfig.getPort());
|
||||
botOptions.setProxyType(convertProxyType(proxyConfig.getType()));
|
||||
|
||||
|
||||
final TelegramPollingBot bot = new TelegramPollingBot(telegramPollingConfig, botOptions);
|
||||
|
||||
|
||||
botapi = new TelegramBotsApi(DefaultBotSession.class);
|
||||
botapi.registerBot(bot);
|
||||
this.telegramBot = bot;
|
||||
} else {
|
||||
final TelegramPollingBot bot = new TelegramPollingBot(telegramPollingConfig);
|
||||
botapi = new TelegramBotsApi(DefaultBotSession.class);
|
||||
botapi.registerBot(bot);
|
||||
this.telegramBot = bot;
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
package org.sadtech.bot.godfather.telegram.listen;
|
||||
package dev.struchkov.godfather.telegram.listen;
|
||||
|
||||
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoard;
|
||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardButton;
|
||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardLine;
|
||||
import dev.struchkov.godfather.context.domain.keyboard.button.KeyBoardButtonText;
|
||||
import dev.struchkov.godfather.context.service.sender.SendType;
|
||||
import dev.struchkov.godfather.context.service.sender.Sending;
|
||||
import dev.struchkov.godfather.telegram.service.SendPreProcessing;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.sadtech.bot.godfather.telegram.service.SendPreProcessing;
|
||||
import org.sadtech.social.core.domain.BoxAnswer;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoard;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
|
||||
import org.sadtech.social.core.domain.keyboard.KeyBoardLine;
|
||||
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonText;
|
||||
import org.sadtech.social.core.service.sender.SendType;
|
||||
import org.sadtech.social.core.service.sender.Sending;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
||||
@ -64,7 +64,7 @@ public class TelegramSender implements Sending {
|
||||
keyBoard.getKeyBoardLines()
|
||||
.stream()
|
||||
.map(this::convertLint)
|
||||
.collect(Collectors.toList())
|
||||
.toList()
|
||||
);
|
||||
return inlineKeyboardMarkup;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.sadtech.bot.godfather.telegram.service;
|
||||
package dev.struchkov.godfather.telegram.service;
|
||||
|
||||
/**
|
||||
* // TODO: 18.09.2020 Добавить описание.
|
8
telegram-core/telegram-core.iml
Normal file
8
telegram-core/telegram-core.iml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="CheckStyle-IDEA-Module">
|
||||
<option name="configuration">
|
||||
<map />
|
||||
</option>
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in New Issue
Block a user