Merge pull request #386 from rubenlagus/dev

Dev
This commit is contained in:
Ruben Bermudez 2018-02-14 20:59:10 +01:00 committed by GitHub
commit 7e369ea2fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 1534 additions and 179 deletions

548
Bots.ipr
View File

@ -36,6 +36,466 @@
<module name="telegrambots-meta" target="1.8" />
</bytecodeTargetLevel>
</component>
<component name="DBNavigator.Project.DataEditorManager">
<record-view-column-sorting-type value="BY_INDEX" />
<value-preview-text-wrapping value="true" />
<value-preview-pinned value="false" />
</component>
<component name="DBNavigator.Project.DataExportManager">
<export-instructions>
<create-header value="true" />
<quote-values-containing-separator value="true" />
<quote-all-values value="false" />
<value-separator value="" />
<file-name value="" />
<file-location value="" />
<scope value="GLOBAL" />
<destination value="FILE" />
<format value="EXCEL" />
<charset value="UTF-8" />
</export-instructions>
</component>
<component name="DBNavigator.Project.DatabaseBrowserManager">
<autoscroll-to-editor value="false" />
<autoscroll-from-editor value="true" />
<show-object-properties value="true" />
<loaded-nodes />
</component>
<component name="DBNavigator.Project.EditorStateManager">
<last-used-providers />
</component>
<component name="DBNavigator.Project.MethodExecutionManager">
<method-browser />
<execution-history>
<group-entries value="true" />
<execution-inputs />
</execution-history>
<argument-values-cache />
</component>
<component name="DBNavigator.Project.ObjectDependencyManager">
<last-used-dependency-type value="INCOMING" />
</component>
<component name="DBNavigator.Project.ObjectQuickFilterManager">
<last-used-operator value="EQUAL" />
<filters />
</component>
<component name="DBNavigator.Project.ScriptExecutionManager" clear-outputs="true">
<recently-used-interfaces />
</component>
<component name="DBNavigator.Project.Settings">
<connections />
<browser-settings>
<general>
<display-mode value="TABBED" />
<navigation-history-size value="100" />
<show-object-details value="false" />
</general>
<filters>
<object-type-filter>
<object-type name="SCHEMA" enabled="true" />
<object-type name="USER" enabled="true" />
<object-type name="ROLE" enabled="true" />
<object-type name="PRIVILEGE" enabled="true" />
<object-type name="CHARSET" enabled="true" />
<object-type name="TABLE" enabled="true" />
<object-type name="VIEW" enabled="true" />
<object-type name="MATERIALIZED_VIEW" enabled="true" />
<object-type name="NESTED_TABLE" enabled="true" />
<object-type name="COLUMN" enabled="true" />
<object-type name="INDEX" enabled="true" />
<object-type name="CONSTRAINT" enabled="true" />
<object-type name="DATASET_TRIGGER" enabled="true" />
<object-type name="DATABASE_TRIGGER" enabled="true" />
<object-type name="SYNONYM" enabled="true" />
<object-type name="SEQUENCE" enabled="true" />
<object-type name="PROCEDURE" enabled="true" />
<object-type name="FUNCTION" enabled="true" />
<object-type name="PACKAGE" enabled="true" />
<object-type name="TYPE" enabled="true" />
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
<object-type name="ARGUMENT" enabled="true" />
<object-type name="DIMENSION" enabled="true" />
<object-type name="CLUSTER" enabled="true" />
<object-type name="DBLINK" enabled="true" />
</object-type-filter>
</filters>
<sorting>
<object-type name="COLUMN" sorting-type="NAME" />
<object-type name="FUNCTION" sorting-type="NAME" />
<object-type name="PROCEDURE" sorting-type="NAME" />
<object-type name="ARGUMENT" sorting-type="POSITION" />
</sorting>
<default-editors>
<object-type name="VIEW" editor-type="SELECTION" />
<object-type name="PACKAGE" editor-type="SELECTION" />
<object-type name="TYPE" editor-type="SELECTION" />
</default-editors>
</browser-settings>
<navigation-settings>
<lookup-filters>
<lookup-objects>
<object-type name="SCHEMA" enabled="true" />
<object-type name="USER" enabled="false" />
<object-type name="ROLE" enabled="false" />
<object-type name="PRIVILEGE" enabled="false" />
<object-type name="CHARSET" enabled="false" />
<object-type name="TABLE" enabled="true" />
<object-type name="VIEW" enabled="true" />
<object-type name="MATERIALIZED VIEW" enabled="true" />
<object-type name="NESTED TABLE" enabled="false" />
<object-type name="COLUMN" enabled="false" />
<object-type name="INDEX" enabled="true" />
<object-type name="CONSTRAINT" enabled="true" />
<object-type name="DATASET TRIGGER" enabled="true" />
<object-type name="DATABASE TRIGGER" enabled="true" />
<object-type name="SYNONYM" enabled="false" />
<object-type name="SEQUENCE" enabled="true" />
<object-type name="PROCEDURE" enabled="true" />
<object-type name="FUNCTION" enabled="true" />
<object-type name="PACKAGE" enabled="true" />
<object-type name="TYPE" enabled="true" />
<object-type name="TYPE ATTRIBUTE" enabled="false" />
<object-type name="ARGUMENT" enabled="false" />
<object-type name="DIMENSION" enabled="false" />
<object-type name="CLUSTER" enabled="false" />
<object-type name="DBLINK" enabled="true" />
</lookup-objects>
<force-database-load value="false" />
<prompt-connection-selection value="true" />
<prompt-schema-selection value="true" />
</lookup-filters>
</navigation-settings>
<dataset-grid-settings>
<general>
<enable-zooming value="true" />
<enable-column-tooltip value="true" />
</general>
<sorting>
<nulls-first value="true" />
<max-sorting-columns value="4" />
</sorting>
<tracking-columns>
<columnNames value="" />
<visible value="true" />
<editable value="false" />
</tracking-columns>
</dataset-grid-settings>
<dataset-editor-settings>
<text-editor-popup>
<active value="false" />
<active-if-empty value="false" />
<data-length-threshold value="100" />
<popup-delay value="1000" />
</text-editor-popup>
<values-list-popup>
<show-popup-button value="true" />
<element-count-threshold value="1000" />
<data-length-threshold value="250" />
</values-list-popup>
<general>
<fetch-block-size value="100" />
<fetch-timeout value="30" />
<trim-whitespaces value="true" />
<convert-empty-strings-to-null value="true" />
<select-content-on-cell-edit value="true" />
<large-value-preview-active value="true" />
</general>
<filters>
<prompt-filter-dialog value="true" />
<default-filter-type value="BASIC" />
</filters>
<qualified-text-editor text-length-threshold="300">
<content-types>
<content-type name="Text" enabled="true" />
<content-type name="Properties" enabled="true" />
<content-type name="XML" enabled="true" />
<content-type name="DTD" enabled="true" />
<content-type name="HTML" enabled="true" />
<content-type name="XHTML" enabled="true" />
<content-type name="CSS" enabled="true" />
<content-type name="Java" enabled="true" />
<content-type name="SQL" enabled="true" />
<content-type name="PL/SQL" enabled="true" />
<content-type name="JPA QL" enabled="true" />
<content-type name="JavaScript" enabled="true" />
<content-type name="JSP" enabled="true" />
<content-type name="JSPx" enabled="true" />
<content-type name="Groovy" enabled="true" />
<content-type name="FTL" enabled="true" />
<content-type name="TML" enabled="true" />
<content-type name="GSP" enabled="true" />
<content-type name="ASP" enabled="true" />
<content-type name="VTL" enabled="true" />
<content-type name="AIDL" enabled="true" />
<content-type name="YAML" enabled="true" />
<content-type name="Flex" enabled="true" />
<content-type name="Manifest" enabled="true" />
</content-types>
</qualified-text-editor>
<record-navigation>
<navigation-target value="VIEWER" />
</record-navigation>
</dataset-editor-settings>
<code-editor-settings>
<general>
<show-object-navigation-gutter value="false" />
<show-spec-declaration-navigation-gutter value="true" />
</general>
<confirmations>
<save-changes value="false" />
<revert-changes value="true" />
</confirmations>
</code-editor-settings>
<code-completion-settings>
<filters>
<basic-filter>
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
<filter-element type="RESERVED_WORD" id="function" selected="true" />
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
<filter-element type="OBJECT" id="schema" selected="true" />
<filter-element type="OBJECT" id="role" selected="true" />
<filter-element type="OBJECT" id="user" selected="true" />
<filter-element type="OBJECT" id="privilege" selected="true" />
<user-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="false" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</user-schema>
<public-schema>
<filter-element type="OBJECT" id="table" selected="false" />
<filter-element type="OBJECT" id="view" selected="false" />
<filter-element type="OBJECT" id="materialized view" selected="false" />
<filter-element type="OBJECT" id="index" selected="false" />
<filter-element type="OBJECT" id="constraint" selected="false" />
<filter-element type="OBJECT" id="trigger" selected="false" />
<filter-element type="OBJECT" id="synonym" selected="false" />
<filter-element type="OBJECT" id="sequence" selected="false" />
<filter-element type="OBJECT" id="procedure" selected="false" />
<filter-element type="OBJECT" id="function" selected="false" />
<filter-element type="OBJECT" id="package" selected="false" />
<filter-element type="OBJECT" id="type" selected="false" />
<filter-element type="OBJECT" id="dimension" selected="false" />
<filter-element type="OBJECT" id="cluster" selected="false" />
<filter-element type="OBJECT" id="dblink" selected="false" />
</public-schema>
<any-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</any-schema>
</basic-filter>
<extended-filter>
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
<filter-element type="RESERVED_WORD" id="function" selected="true" />
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
<filter-element type="OBJECT" id="schema" selected="true" />
<filter-element type="OBJECT" id="user" selected="true" />
<filter-element type="OBJECT" id="role" selected="true" />
<filter-element type="OBJECT" id="privilege" selected="true" />
<user-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</user-schema>
<public-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</public-schema>
<any-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</any-schema>
</extended-filter>
</filters>
<sorting enabled="true">
<sorting-element type="RESERVED_WORD" id="keyword" />
<sorting-element type="RESERVED_WORD" id="datatype" />
<sorting-element type="OBJECT" id="column" />
<sorting-element type="OBJECT" id="table" />
<sorting-element type="OBJECT" id="view" />
<sorting-element type="OBJECT" id="materialized view" />
<sorting-element type="OBJECT" id="index" />
<sorting-element type="OBJECT" id="constraint" />
<sorting-element type="OBJECT" id="trigger" />
<sorting-element type="OBJECT" id="synonym" />
<sorting-element type="OBJECT" id="sequence" />
<sorting-element type="OBJECT" id="procedure" />
<sorting-element type="OBJECT" id="function" />
<sorting-element type="OBJECT" id="package" />
<sorting-element type="OBJECT" id="type" />
<sorting-element type="OBJECT" id="dimension" />
<sorting-element type="OBJECT" id="cluster" />
<sorting-element type="OBJECT" id="dblink" />
<sorting-element type="OBJECT" id="schema" />
<sorting-element type="OBJECT" id="role" />
<sorting-element type="OBJECT" id="user" />
<sorting-element type="RESERVED_WORD" id="function" />
<sorting-element type="RESERVED_WORD" id="parameter" />
</sorting>
<format>
<enforce-code-style-case value="true" />
</format>
</code-completion-settings>
<execution-engine-settings>
<statement-execution>
<fetch-block-size value="100" />
<execution-timeout value="20" />
<debug-execution-timeout value="600" />
<focus-result value="false" />
<prompt-execution value="false" />
<target-connection value="ASK" />
</statement-execution>
<script-execution>
<command-line-interfaces />
<execution-timeout value="300" />
</script-execution>
<method-execution>
<execution-timeout value="30" />
<debug-execution-timeout value="600" />
<parameter-history-size value="10" />
</method-execution>
</execution-engine-settings>
<operation-settings>
<transactions>
<uncommitted-changes>
<on-project-close value="ASK" />
<on-disconnect value="ASK" />
<on-autocommit-toggle value="ASK" />
</uncommitted-changes>
<multiple-uncommitted-changes>
<on-commit value="ASK" />
<on-rollback value="ASK" />
</multiple-uncommitted-changes>
</transactions>
<session-browser>
<disconnect-session value="ASK" />
<kill-session value="ASK" />
<reload-on-filter-change value="false" />
</session-browser>
<compiler>
<compile-type value="KEEP" />
<compile-dependencies value="ASK" />
<always-show-controls value="false" />
</compiler>
<debugger>
<debugger-type value="ASK" />
<use-generic-runners value="true" />
</debugger>
</operation-settings>
<ddl-file-settings>
<extensions>
<mapping file-type-id="VIEW" extensions="vw" />
<mapping file-type-id="TRIGGER" extensions="trg" />
<mapping file-type-id="PROCEDURE" extensions="prc" />
<mapping file-type-id="FUNCTION" extensions="fnc" />
<mapping file-type-id="PACKAGE" extensions="pkg" />
<mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
<mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
<mapping file-type-id="TYPE" extensions="tpe" />
<mapping file-type-id="TYPE_SPEC" extensions="tps" />
<mapping file-type-id="TYPE_BODY" extensions="tpb" />
</extensions>
<general>
<lookup-ddl-files value="true" />
<create-ddl-files value="false" />
<synchronize-ddl-files value="true" />
<use-qualified-names value="false" />
<make-scripts-rerunnable value="true" />
</general>
</ddl-file-settings>
<general-settings>
<regional-settings>
<date-format value="MEDIUM" />
<number-format value="UNGROUPED" />
<locale value="SYSTEM_DEFAULT" />
<use-custom-formats value="false" />
</regional-settings>
<environment>
<environment-types>
<environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" />
<environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" />
<environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" />
<environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" />
</environment-types>
<visibility-settings>
<connection-tabs value="true" />
<dialog-headers value="true" />
<object-editor-tabs value="true" />
<script-editor-tabs value="false" />
<execution-result-tabs value="true" />
</visibility-settings>
</environment>
</general-settings>
</component>
<component name="DBNavigator.Project.StatementExecutionManager">
<execution-variables />
</component>
<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" />
@ -46,9 +506,39 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<option name="myLocal" value="true" />
<inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="JSLint" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="note" />
</inspection_tool>
</profile>
<version value="1.0" />
</component>
@ -129,9 +619,6 @@
<exe-path>/usr/local/bin/bower</exe-path>
<config-path />
</component>
<component name="KotlinCommonCompilerArguments">
<option name="coroutinesWarn" value="false" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
@ -262,7 +749,32 @@
</component>
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value />
<value>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</value>
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="GoogleStyle" />
</component>
@ -960,6 +1472,32 @@
<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.telegram:telegrambots-meta:3.5">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots-meta/3.5/telegrambots-meta-3.5.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$PROJECT_DIR$/telegrambots-meta/telegrambots-meta-3.5-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots-meta/3.5/telegrambots-meta-3.5-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$PROJECT_DIR$/telegrambots-meta/telegrambots-meta-3.5-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots-meta/3.5/telegrambots-meta-3.5-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.telegram:telegrambots:3.5">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots/3.5/telegrambots-3.5.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$PROJECT_DIR$/telegrambots/telegrambots-3.5-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots/3.5/telegrambots-3.5-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$PROJECT_DIR$/telegrambots/telegrambots-3.5-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/telegram/telegrambots/3.5/telegrambots-3.5-sources.jar!/" />
</SOURCES>
</library>
</component>
<component name="masterDetails">
<states>

View File

@ -27,16 +27,16 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>3.5</version>
<version>3.6</version>
</dependency>
```
```gradle
compile "org.telegram:telegrambots:3.5"
compile "org.telegram:telegrambots:3.6"
```
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/3.5)
3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v3.5)
2. Using Jitpack from [here](https://jitpack.io/#rubenlagus/TelegramBots/3.6)
3. Download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v3.6)
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

View File

@ -1,3 +1,7 @@
### <a id="3.6"></a>3.6 ###
1. Support for Api Version [3.6](https://core.telegram.org/bots/api-changelog#february-13-2018)
2. Bug fixing and other improvements
### <a id="3.5"></a>3.5 ###
1. Support for Api Version [3.5](https://core.telegram.org/bots/api-changelog#november-17-2017)
2. Bug fixing: #168, #329 and #335

View File

@ -11,7 +11,7 @@ First you need ot get the library and add it to your project. There are few poss
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>3.5</version>
<version>3.6</version>
</dependency>
```
* With **Gradle**:
@ -53,7 +53,7 @@ Now that we have the library, we can start coding. There are few steps to follow
```
* `getBotUsermane()`: This method must always return your **Bot username**. May look like:
* `getBotUsername()`: This method must always return your **Bot username**. May look like:
```java

View File

@ -1,7 +1,7 @@
# Advanced
This will be more of a FAQ on some important notes before you embark on your next big bot project!
## Default Abilties
## Default Abilities
It is possible to declare "DEFAULT" abilities that process non-command messages. This is quite close to a reply. If a user says "Hey there" and the default ability is implemented, it will process this input.
```java

View File

@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilties</artifactId>
<version>3.5</version>
<version>3.6</version>
</dependency>
```
* **Gradle**
```groovy
compile group: 'org.telegram', name: 'telegrambots-abilties', version: '3.5'
compile group: 'org.telegram', name: 'telegrambots-abilties', version: '3.6'
```
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)

View File

@ -7,7 +7,7 @@
<groupId>org.telegram</groupId>
<artifactId>Bots</artifactId>
<packaging>pom</packaging>
<version>3.5</version>
<version>3.6</version>
<modules>
<module>telegrambots</module>
@ -26,6 +26,6 @@
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<bots.version>3.5</bots.version>
<bots.version>3.6</bots.version>
</properties>
</project>

View File

@ -18,19 +18,19 @@ Usage
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>3.5</version>
<version>3.6</version>
</dependency>
```
**Gradle**
```gradle
compile "org.telegram:telegrambots-abilities:3.5"
compile "org.telegram:telegrambots-abilities:3.6"
```
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v3.5)
**JitPack** - [JitPack](https://jitpack.io/#rubenlagus/TelegramBots/v3.6)
**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v3.5)
**Plain imports** - [Here](https://github.com/rubenlagus/TelegramBots/releases/tag/v3.6)
Motivation
----------

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-abilities</artifactId>
<version>3.5</version>
<version>3.6</version>
<packaging>jar</packaging>
<name>Telegram Ability Bot</name>
@ -65,7 +65,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bots.version>3.5</bots.version>
<bots.version>3.6</bots.version>
<commonslang.version>3.5</commonslang.version>
<mapdb.version>3.0.4</mapdb.version>
<guava.version>19.0</guava.version>

View File

@ -10,6 +10,7 @@ import org.telegram.abilitybots.api.util.AbilityUtils;
import org.telegram.abilitybots.api.util.Pair;
import org.telegram.abilitybots.api.util.Trio;
import org.telegram.telegrambots.api.methods.GetFile;
import org.telegram.telegrambots.api.methods.groupadministration.GetChatAdministrators;
import org.telegram.telegrambots.api.methods.send.SendDocument;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.Update;
@ -24,10 +25,7 @@ import java.io.FileReader;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.stream.Stream;
@ -413,10 +411,10 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
Set<Integer> blacklist = blacklist();
if (blacklist.contains(userId))
silent.sendMd(format("%s is already *banned*.", bannedUser), ctx.chatId());
silent.sendMd(format("%s is already *banned*.", escape(bannedUser)), ctx.chatId());
else {
blacklist.add(userId);
silent.sendMd(format("%s is now *banned*.", bannedUser), ctx.chatId());
silent.sendMd(format("%s is now *banned*.", escape(bannedUser)), ctx.chatId());
}
})
.post(commitTo(db))
@ -441,9 +439,9 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
Set<Integer> blacklist = blacklist();
if (!blacklist.remove(userId))
silent.sendMd(format("@%s is *not* on the *blacklist*.", username), ctx.chatId());
silent.sendMd(format("@%s is *not* on the *blacklist*.", escape(username)), ctx.chatId());
else {
silent.sendMd(format("@%s, your ban has been *lifted*.", username), ctx.chatId());
silent.sendMd(format("@%s, your ban has been *lifted*.", escape(username)), ctx.chatId());
}
})
.post(commitTo(db))
@ -465,10 +463,10 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
Set<Integer> admins = admins();
if (admins.contains(userId))
silent.sendMd(format("@%s is already an *admin*.", username), ctx.chatId());
silent.sendMd(format("@%s is already an *admin*.", escape(username)), ctx.chatId());
else {
admins.add(userId);
silent.sendMd(format("@%s has been *promoted*.", username), ctx.chatId());
silent.sendMd(format("@%s has been *promoted*.", escape(username)), ctx.chatId());
}
}).post(commitTo(db))
.build();
@ -489,9 +487,9 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
Set<Integer> admins = admins();
if (admins.remove(userId)) {
silent.sendMd(format("@%s has been *demoted*.", username), ctx.chatId());
silent.sendMd(format("@%s has been *demoted*.", escape(username)), ctx.chatId());
} else {
silent.sendMd(format("@%s is *not* an *admin*.", username), ctx.chatId());
silent.sendMd(format("@%s is *not* an *admin*.", escape(username)), ctx.chatId());
}
})
.post(commitTo(db))
@ -540,7 +538,7 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
abilities = stream(this.getClass().getMethods())
.filter(method -> method.getReturnType().equals(Ability.class))
.map(this::returnAbility)
.collect(toMap(Ability::name, identity()));
.collect(toMap(ability -> ability.name().toLowerCase(), identity()));
Stream<Reply> methodReplies = stream(this.getClass().getMethods())
.filter(method -> method.getReturnType().equals(Reply.class))
@ -617,7 +615,7 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
boolean isOk = abilityTokens == 0 || (tokens.length > 0 && tokens.length == abilityTokens);
if (!isOk)
silent.send(String.format("Sorry, this feature requires %d additional %s.", abilityTokens, abilityTokens == 1 ? "input" : "inputs"), getChatId(trio.a()));
silent.send(format("Sorry, this feature requires %d additional %s.", abilityTokens, abilityTokens == 1 ? "input" : "inputs"), getChatId(trio.a()));
return isOk;
}
@ -629,7 +627,7 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
boolean isOk = abilityLocality == ALL || locality == abilityLocality;
if (!isOk)
silent.send(String.format("Sorry, %s-only feature.", abilityLocality.toString().toLowerCase()), getChatId(trio.a()));
silent.send(format("Sorry, %s-only feature.", abilityLocality.toString().toLowerCase()), getChatId(trio.a()));
return isOk;
}
@ -639,15 +637,24 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
Privacy privacy;
int id = user.id();
privacy = isCreator(id) ? CREATOR : isAdmin(id) ? ADMIN : PUBLIC;
privacy = isCreator(id) ? CREATOR : isAdmin(id) ? ADMIN : isGroupAdmin(update, id)? GROUP_ADMIN : PUBLIC;
boolean isOk = privacy.compareTo(trio.b().privacy()) >= 0;
if (!isOk)
silent.send(String.format("Sorry, %s-only feature.", trio.b().privacy().toString().toLowerCase()), getChatId(trio.a()));
silent.send("Sorry, you don't have the required access level to do that.", getChatId(trio.a()));
return isOk;
}
private boolean isGroupAdmin(Update update, int id) {
GetChatAdministrators admins = new GetChatAdministrators().setChatId(getChatId(update));
return isGroupUpdate(update) && silent.execute(admins)
.orElse(new ArrayList<>()).stream()
.anyMatch(member -> member.getUser().getId() == id);
}
private boolean isCreator(int id) {
return id == creatorId();
}
@ -667,11 +674,10 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
if (!update.hasMessage() || !msg.hasText())
return Trio.of(update, abilities.get(DEFAULT), new String[]{});
// Priority goes to text before captions
String[] tokens = msg.getText().split(" ");
if (tokens[0].startsWith("/")) {
String abilityToken = stripBotUsername(tokens[0].substring(1));
String abilityToken = stripBotUsername(tokens[0].substring(1)).toLowerCase();
Ability ability = abilities.get(abilityToken);
tokens = Arrays.copyOfRange(tokens, 1, tokens.length);
return Trio.of(update, ability, tokens);
@ -743,4 +749,8 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
private File downloadFileWithId(String fileId) throws TelegramApiException {
return sender.downloadFile(sender.execute(new GetFile().setFileId(fileId)));
}
private String escape(String username) {
return username.replace("_", "\\_");
}
}

View File

@ -10,6 +10,10 @@ public enum Privacy {
* Anybody who is not a bot admin or its creator will be considered as a public user.
*/
PUBLIC,
/**
* Only group admins would get to initiate this command.
*/
GROUP_ADMIN,
/**
* A global admin of the bot, regardless of the group the bot is in.
*/

View File

@ -64,6 +64,28 @@ public final class AbilityUtils {
}
}
/**
* A "best-effort" boolean stating whether the update is a group message or not.
*
* @param update a Telegram {@link Update}
* @return whether the update is linked to a group
*/
public static boolean isGroupUpdate(Update update) {
if (MESSAGE.test(update)) {
return update.getMessage().isGroupMessage();
} else if (CALLBACK_QUERY.test(update)) {
return update.getCallbackQuery().getMessage().isGroupMessage();
} else if (CHANNEL_POST.test(update)) {
return update.getChannelPost().isGroupMessage();
} else if (EDITED_CHANNEL_POST.test(update)) {
return update.getEditedChannelPost().isGroupMessage();
} else if (EDITED_MESSAGE.test(update)) {
return update.getEditedMessage().isGroupMessage();
} else {
return false;
}
}
/**
* Fetches the direct chat ID of the specified update.
*

View File

@ -2,7 +2,6 @@ package org.telegram.abilitybots.api.bot;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull;
import org.junit.After;
import org.junit.Before;
@ -13,6 +12,7 @@ import org.telegram.abilitybots.api.sender.MessageSender;
import org.telegram.abilitybots.api.sender.SilentSender;
import org.telegram.abilitybots.api.util.Pair;
import org.telegram.abilitybots.api.util.Trio;
import org.telegram.telegrambots.api.methods.groupadministration.GetChatAdministrators;
import org.telegram.telegrambots.api.objects.*;
import org.telegram.telegrambots.exceptions.TelegramApiException;
@ -21,11 +21,14 @@ import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
import static java.lang.String.format;
import static java.util.Collections.emptySet;
import static java.util.Optional.empty;
import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.lang3.ArrayUtils.addAll;
import static org.apache.commons.lang3.StringUtils.EMPTY;
@ -43,8 +46,7 @@ import static org.telegram.abilitybots.api.objects.Flag.MESSAGE;
import static org.telegram.abilitybots.api.objects.Locality.ALL;
import static org.telegram.abilitybots.api.objects.Locality.GROUP;
import static org.telegram.abilitybots.api.objects.MessageContext.newContext;
import static org.telegram.abilitybots.api.objects.Privacy.ADMIN;
import static org.telegram.abilitybots.api.objects.Privacy.PUBLIC;
import static org.telegram.abilitybots.api.objects.Privacy.*;
public class AbilityBotTest {
private static final String[] EMPTY_ARRAY = {};
@ -77,7 +79,7 @@ public class AbilityBotTest {
bot.onUpdateReceived(update);
verify(silent, times(1)).send(format("Sorry, %s-only feature.", "admin"), MUSER.id());
verify(silent, times(1)).send("Sorry, you don't have the required access level to do that.", MUSER.id());
}
@Test
@ -342,20 +344,61 @@ public class AbilityBotTest {
Message message = mock(Message.class);
org.telegram.telegrambots.api.objects.User user = mock(User.class);
Ability publicAbility = getDefaultBuilder().privacy(PUBLIC).build();
Ability groupAdminAbility = getDefaultBuilder().privacy(GROUP_ADMIN).build();
Ability adminAbility = getDefaultBuilder().privacy(ADMIN).build();
Ability creatorAbility = getDefaultBuilder().privacy(Privacy.CREATOR).build();
Trio<Update, Ability, String[]> publicTrio = Trio.of(update, publicAbility, TEXT);
Trio<Update, Ability, String[]> groupAdminTrio = Trio.of(update, groupAdminAbility, TEXT);
Trio<Update, Ability, String[]> adminTrio = Trio.of(update, adminAbility, TEXT);
Trio<Update, Ability, String[]> creatorTrio = Trio.of(update, creatorAbility, TEXT);
mockUser(update, message, user);
assertEquals("Unexpected result when checking for privacy", true, bot.checkPrivacy(publicTrio));
assertEquals("Unexpected result when checking for privacy", false, bot.checkPrivacy(groupAdminTrio));
assertEquals("Unexpected result when checking for privacy", false, bot.checkPrivacy(adminTrio));
assertEquals("Unexpected result when checking for privacy", false, bot.checkPrivacy(creatorTrio));
}
@Test
public void canValidateGroupAdminPrivacy() throws TelegramApiException {
Update update = mock(Update.class);
Message message = mock(Message.class);
org.telegram.telegrambots.api.objects.User user = mock(User.class);
Ability groupAdminAbility = getDefaultBuilder().privacy(GROUP_ADMIN).build();
Trio<Update, Ability, String[]> groupAdminTrio = Trio.of(update, groupAdminAbility, TEXT);
mockUser(update, message, user);
when(message.isGroupMessage()).thenReturn(true);
ChatMember member = mock(ChatMember.class);
when(member.getUser()).thenReturn(user);
when(member.getUser()).thenReturn(user);
when(silent.execute(any(GetChatAdministrators.class))).thenReturn(Optional.of(newArrayList(member)));
assertEquals("Unexpected result when checking for privacy", true, bot.checkPrivacy(groupAdminTrio));
}
@Test
public void canRestrictNormalUsersFromGroupAdminAbilities() throws TelegramApiException {
Update update = mock(Update.class);
Message message = mock(Message.class);
org.telegram.telegrambots.api.objects.User user = mock(User.class);
Ability groupAdminAbility = getDefaultBuilder().privacy(GROUP_ADMIN).build();
Trio<Update, Ability, String[]> groupAdminTrio = Trio.of(update, groupAdminAbility, TEXT);
mockUser(update, message, user);
when(message.isGroupMessage()).thenReturn(true);
when(silent.execute(any(GetChatAdministrators.class))).thenReturn(empty());
assertEquals("Unexpected result when checking for privacy", false, bot.checkPrivacy(groupAdminTrio));
}
@Test
public void canBlockAdminsFromCreatorAbilities() {
Update update = mock(Update.class);
@ -447,6 +490,25 @@ public class AbilityBotTest {
assertEquals("Wrong ability was fetched", expected, actual);
}
@Test
public void canFetchAbilityCaseInsensitive() {
Update update = mock(Update.class);
Message message = mock(Message.class);
String text = "/tESt";
when(update.hasMessage()).thenReturn(true);
when(update.getMessage()).thenReturn(message);
when(update.getMessage().hasText()).thenReturn(true);
when(message.getText()).thenReturn(text);
Trio<Update, Ability, String[]> trio = bot.getAbility(update);
Ability expected = bot.testAbility();
Ability actual = trio.b();
assertEquals("Wrong ability was fetched", expected, actual);
}
@Test
public void canFetchDefaultAbility() {
Update update = mock(Update.class);

View File

@ -31,7 +31,7 @@ public class MapDBContextTest {
}
@Test
public void canRecoverDB() throws IOException {
public void canRecoverDB() {
Map<Integer, EndUser> users = db.getMap(USERS);
Map<String, Integer> userIds = db.getMap(USER_ID);
users.put(CREATOR.id(), CREATOR);

View File

@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambotsextensions</artifactId>
<version>3.5</version>
<version>3.6</version>
</dependency>
```
2. Using Gradle:
```gradle
compile "org.telegram:telegrambotsextensions:3.5"
compile "org.telegram:telegrambotsextensions:3.6"
```

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambotsextensions</artifactId>
<version>3.5</version>
<version>3.6</version>
<packaging>jar</packaging>
<name>Telegram Bots Extensions</name>
@ -59,7 +59,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bots.version>3.5</bots.version>
<bots.version>3.6</bots.version>
</properties>
<dependencies>

View File

@ -0,0 +1,117 @@
package org.telegram.telegrambots.bots.commandbot.commands.helpCommand;
import java.util.Collection;
import org.telegram.telegrambots.api.methods.send.SendMessage;
import org.telegram.telegrambots.api.objects.Chat;
import org.telegram.telegrambots.api.objects.User;
import org.telegram.telegrambots.bots.AbsSender;
import org.telegram.telegrambots.bots.commandbot.TelegramLongPollingCommandBot;
import org.telegram.telegrambots.bots.commandbot.commands.BotCommand;
import org.telegram.telegrambots.bots.commandbot.commands.ICommandRegistry;
import org.telegram.telegrambots.exceptions.TelegramApiException;
/**
* A special bot command used for printing help messages similiar to the Linux man command.
* The commands printed by this command should implement the {@link IManCommand} interface to provide an extended description.
* @author Lukas Prediger(Chase)
* @version 1.0.0
*
*/
public class HelpCommand extends ManCommand {
private static final String COMMAND_IDENTIFIER = "help";
private static final String COMMAND_DESCRIPTION = "shows all commands. Use /help [command] for more info";
private static final String EXTENDED_DESCRIPTION = "This command displays all commands the bot has to offer.\n /help [command] can display deeper information";
/**
* Returns the command and description of all supplied commands as a formatted String
* @param botCommands the Commands that should be included in the String
* @return a formatted String containing command and description for all supplied commands
*/
public static String getHelpText(BotCommand...botCommands) {
StringBuilder reply = new StringBuilder();
for (BotCommand com : botCommands) {
reply.append(com.toString()).append(System.lineSeparator()).append(System.lineSeparator());
}
return reply.toString();
}
/**
* Returns the command and description of all supplied commands as a formatted String
* @param botCommands a collection of commands that should be included in the String
* @return a formatted String containing command and description for all supplied commands
*/
public static String getHelpText(Collection<BotCommand> botCommands) {
return getHelpText(botCommands.toArray(new BotCommand[botCommands.size()]));
}
/**
* Returns the command and description of all supplied commands as a formatted String
* @param registry a commandRegistry which commands are formatted into the String
* @return a formatted String containing command and description for all supplied commands
*/
public static String getHelpText(ICommandRegistry registry) {
return getHelpText(registry.getRegisteredCommands());
}
/**
* Reads the extended Description from a BotCommand. If the Command is not of Type {@link IManCommand}, it calls toString();
* @param command a command the extended Descriptions is read from
* @return the extended Description or the toString() if IManCommand is not implemented
*/
public static String getManText(BotCommand command) {
return IManCommand.class.isInstance(command) ? getManText((IManCommand) command) : command.toString();
}
/**
* Reads the extended Description from a BotCommand;
* @param command a command the extended Descriptions is read from
* @return the extended Description
*/
public static String getManText(IManCommand command) {
return command.toMan();
}
/**
* Create a Help command with the standard Arguments.
*/
public HelpCommand() {
super(COMMAND_IDENTIFIER, COMMAND_DESCRIPTION, EXTENDED_DESCRIPTION);
}
/**
* Creates a Help Command with custom identifier, description and extended Description
* @param commandIdentifier the unique identifier of this command (e.g. the command string to enter into chat)
* @param description the description of this command
* @param extendedDescription The extended Description for the Command, should provide detailed information about arguments and possible options
*/
public HelpCommand(String commandIdentifier, String description, String extendedDescription) {
super(commandIdentifier, description, extendedDescription);
}
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] arguments) {
if (ICommandRegistry.class.isInstance(absSender)) {
ICommandRegistry registry = (ICommandRegistry) absSender;
if (arguments.length > 0) {
BotCommand command = registry.getRegisteredCommand(arguments[0]);
String reply = getManText(command);
try {
absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML"));
} catch (TelegramApiException e) {
e.printStackTrace();
}
} else {
String reply = getHelpText(registry);
try {
absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML"));
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -0,0 +1,21 @@
package org.telegram.telegrambots.bots.commandbot.commands.helpCommand;
/**
* Represents a Command that, aside the normal command description provides an extended Description similar to the output of the Linux <i>man</i> command
* @author Lukas Prediger(Chase)
* @version 1.0.0
*/
public interface IManCommand {
/**
* Returns the extended Description of this command
* @return the extendedDescription
*/
String getExtendedDescription();
/**
* Returns a String Representations of the Command and it's extended Description.
* @return a String representing the Command and it's extended Description
*/
String toMan();
}

View File

@ -0,0 +1,41 @@
package org.telegram.telegrambots.bots.commandbot.commands.helpCommand;
import org.telegram.telegrambots.bots.commandbot.commands.BotCommand;
public abstract class ManCommand extends BotCommand implements IManCommand {
private final String extendedDescription;
/**
* Create a new ManCommand providing a commandIdentifier, a short description and the extended description
* @param commandIdentifier the unique identifier of this command (e.g. the command string to enter into chat)
* @param description the description of this command
* @param extendedDescription The extended Description for the Command, should provide detailed information about arguments and possible options
*/
public ManCommand(String commandIdentifier, String description, String extendedDescription) {
super(commandIdentifier, description);
this.extendedDescription = extendedDescription;
}
/* (non-Javadoc)
* @see org.telegram.telegrambots.bots.commandbot.commands.helpCommand.IManCommand#getExtendedDescription()
*/
@Override
public String getExtendedDescription() {
return extendedDescription;
}
/* (non-Javadoc)
* @see org.telegram.telegrambots.bots.commandbot.commands.helpCommand.IManCommand#toMan()
*/
@Override
public String toMan() {
StringBuilder sb = new StringBuilder(toString());
sb.append(System.lineSeparator())
.append("-----------------")
.append(System.lineSeparator());
if (getExtendedDescription() != null) sb.append(getExtendedDescription());
return sb.toString();
}
}

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-meta</artifactId>
<version>3.5</version>
<version>3.6</version>
<packaging>jar</packaging>
<name>Telegram Bots Meta</name>

View File

@ -17,12 +17,11 @@ import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to send audio files, Use this method to send audio files, if you want
* Use this method to send audio files, Use this method to send audio files, if you want
* Telegram clients to display them in the music player. Your audio must be in an .mp3 format. On
* success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in
* size, this limit may be changed in the future.
* @note For sending voice notes, use sendVoice method instead.
* @date 16 of July of 2015
*/
public class SendAudio extends PartialBotApiMethod<Message> {
public static final String PATH = "sendaudio";
@ -36,6 +35,8 @@ public class SendAudio extends PartialBotApiMethod<Message> {
public static final String PERFOMER_FIELD = "performer";
public static final String TITLE_FIELD = "title";
public static final String CAPTION_FIELD = "caption";
public static final String PARSEMODE_FIELD = "parse_mode";
private Integer duration; ///< Integer Duration of the audio in seconds as defined by sender
private String chatId; ///< Unique identifier for the chat to send the message to (or Username fro channels)
@ -46,6 +47,7 @@ public class SendAudio extends PartialBotApiMethod<Message> {
private String performer; ///< Optional. Performer of sent audio
private String title; ///< Optional. Title of sent audio
private String caption; ///< Optional. Audio caption (may also be used when resending documents by file_id), 0-200 characters
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
private boolean isNewAudio; ///< True to upload a new audio, false to use a fileId
private String audioName;
@ -191,6 +193,15 @@ public class SendAudio extends PartialBotApiMethod<Message> {
return this;
}
public String getParseMode() {
return parseMode;
}
public SendAudio setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -239,11 +250,12 @@ public class SendAudio extends PartialBotApiMethod<Message> {
", replyMarkup=" + replyMarkup +
", performer='" + performer + '\'' +
", title='" + title + '\'' +
", caption='" + caption + '\'' +
", parseMode='" + parseMode + '\'' +
", isNewAudio=" + isNewAudio +
", audioName='" + audioName + '\'' +
", newAudioFile=" + newAudioFile +
", newAudioStream=" + newAudioStream +
", caption='" + caption + '\'' +
'}';
}
}

View File

@ -17,8 +17,7 @@ import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to send general files. On success, the sent Message is returned.
* @date 20 of June of 2015
* Use this method to send general files. On success, the sent Message is returned.
*/
public class SendDocument extends PartialBotApiMethod<Message> {
public static final String PATH = "senddocument";
@ -29,12 +28,15 @@ public class SendDocument extends PartialBotApiMethod<Message> {
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String PARSEMODE_FIELD = "parse_mode";
private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
private String document; ///< File file to send. file_id as String to resend a file that is already on the Telegram servers or Url to upload it
private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
private boolean isNewDocument; ///< True to upload a new document, false to use a fileId
private String documentName;
@ -154,6 +156,15 @@ public class SendDocument extends PartialBotApiMethod<Message> {
return this;
}
public String getParseMode() {
return parseMode;
}
public SendDocument setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -196,9 +207,15 @@ public class SendDocument extends PartialBotApiMethod<Message> {
return "SendDocument{" +
"chatId='" + chatId + '\'' +
", document='" + document + '\'' +
", caption='" + caption + '\'' +
", disableNotification=" + disableNotification +
", replyToMessageId=" + replyToMessageId +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
", isNewDocument=" + isNewDocument +
", documentName='" + documentName + '\'' +
", newDocumentFile=" + newDocumentFile +
", newDocumentStream=" + newDocumentStream +
'}';
}
}

View File

@ -187,6 +187,35 @@ public class SendMessage extends BotApiMethod<Message> {
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof SendMessage)) {
return false;
}
SendMessage sendMessage = (SendMessage) o;
return Objects.equals(chatId, sendMessage.chatId)
&& Objects.equals(disableNotification, sendMessage.disableNotification)
&& Objects.equals(disableWebPagePreview, sendMessage.disableWebPagePreview)
&& Objects.equals(parseMode, sendMessage.parseMode)
&& Objects.equals(replyMarkup, sendMessage.replyMarkup)
&& Objects.equals(replyToMessageId, sendMessage.replyToMessageId)
&& Objects.equals(text, sendMessage.text)
;
}
@Override
public int hashCode() {
return Objects.hash(
chatId,
disableNotification,
disableWebPagePreview,
parseMode,
replyMarkup,
replyToMessageId,
text);
}
@Override
public String toString() {
return "SendMessage{" +

View File

@ -17,8 +17,7 @@ import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to send photos. On success, the sent Message is returned.
* @date 20 of June of 2015
* Use this method to send photos. On success, the sent Message is returned.
*/
public class SendPhoto extends PartialBotApiMethod<Message> {
public static final String PATH = "sendphoto";
@ -29,12 +28,15 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String PARSEMODE_FIELD = "parse_mode";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
private String photo; ///< Photo to send. file_id as String to resend a photo that is already on the Telegram servers or URL to upload it
private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id).
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
private boolean isNewPhoto; ///< True if the photo must be uploaded from a file, file if it is a fileId
private String photoName; ///< Name of the photo
@ -142,6 +144,15 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
return this;
}
public String getParseMode() {
return parseMode;
}
public SendPhoto setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -184,9 +195,14 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
"chatId='" + chatId + '\'' +
", photo='" + photo + '\'' +
", caption='" + caption + '\'' +
", disableNotification=" + disableNotification +
", replyToMessageId=" + replyToMessageId +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
", isNewPhoto=" + isNewPhoto +
", photoName='" + photoName + '\'' +
", newPhotoFile=" + newPhotoFile +
", newPhotoStream=" + newPhotoStream +
'}';
}
}

View File

@ -31,17 +31,22 @@ public class SendVideo extends PartialBotApiMethod<Message> {
public static final String WIDTH_FIELD = "width";
public static final String HEIGHT_FIELD = "height";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String SUPPORTSSTREAMING_FIELD = "supports_streaming";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String PARSEMODE_FIELD = "parse_mode";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
private String video; ///< Video to send. file_id as String to resend a video that is already on the Telegram servers or URL to upload it
private Integer duration; ///< Optional. Duration of sent video in seconds
private String caption; ///< OptionaL. Video caption (may also be used when resending videos by file_id).
private Integer width; ///< Optional. Video width
private Integer height; ///< OptionaL. Video height
private Boolean supportsStreaming; ///< Optional. Pass True, if the uploaded video is suitable for streaming
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
private boolean isNewVideo; ///< True to upload a new video, false to use a fileId
private String videoName; ///< Name of the video
@ -176,6 +181,24 @@ public class SendVideo extends PartialBotApiMethod<Message> {
return this;
}
public Boolean getSupportsStreaming() {
return supportsStreaming;
}
public SendVideo setSupportsStreaming(Boolean supportsStreaming) {
this.supportsStreaming = supportsStreaming;
return this;
}
public String getParseMode() {
return parseMode;
}
public SendVideo setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
try {

View File

@ -17,10 +17,9 @@ import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to send voice notes, if you want Telegram clients to display the file as a
* Use this method to send voice notes, if you want Telegram clients to display the file as a
* playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS
* (other formats may be sent as Audio or Document).
* @date 16 of July of 2015
*/
public class SendVoice extends PartialBotApiMethod<Message> {
public static final String PATH = "sendvoice";
@ -32,6 +31,7 @@ public class SendVoice extends PartialBotApiMethod<Message> {
public static final String REPLYMARKUP_FIELD = "reply_markup";
public static final String DURATION_FIELD = "duration";
public static final String CAPTION_FIELD = "caption";
public static final String PARSEMODE_FIELD = "parse_mode";
private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
private String voice; ///< Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data.
@ -40,6 +40,7 @@ public class SendVoice extends PartialBotApiMethod<Message> {
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private Integer duration; ///< Optional. Duration of sent audio in seconds
private String caption; ///< Optional. Voice caption (may also be used when resending videos by file_id).
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
private boolean isNewVoice; ///< True to upload a new voice note, false to use a fileId
private String voiceName; ///< Name of the voice note
@ -156,6 +157,15 @@ public class SendVoice extends PartialBotApiMethod<Message> {
return this;
}
public String getParseMode() {
return parseMode;
}
public SendVoice setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
try {
@ -203,6 +213,7 @@ public class SendVoice extends PartialBotApiMethod<Message> {
", replyMarkup=" + replyMarkup +
", duration=" + duration +
", caption='" + caption + '\'' +
", parseMode='" + parseMode + '\'' +
", isNewVoice=" + isNewVoice +
", voiceName='" + voiceName + '\'' +
", newVoiceFile=" + newVoiceFile +

View File

@ -16,9 +16,8 @@ import java.io.Serializable;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to edit captions of messages sent by the bot or via the bot (for inline
* Use this method to edit captions of messages sent by the bot or via the bot (for inline
* bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @date 10 of April of 2016
*/
public class EditMessageCaption extends BotApiMethod<Serializable> {
public static final String PATH = "editmessagecaption";
@ -28,6 +27,7 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
private static final String CAPTION_FIELD = "caption";
private static final String REPLYMARKUP_FIELD = "reply_markup";
private static final String PARSEMODE_FIELD = "parse_mode";
/**
* Required if inline_message_id is not specified. Unique identifier for the chat to send the
@ -49,6 +49,8 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
private String caption; ///< Optional. New caption of the message
@JsonProperty(REPLYMARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public EditMessageCaption() {
super();
@ -99,6 +101,15 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
return this;
}
public String getParseMode() {
return parseMode;
}
public EditMessageCaption setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public String getMethod() {
return PATH;
@ -155,11 +166,12 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
@Override
public String toString() {
return "EditMessageCaption{" +
"chatId=" + chatId +
"chatId='" + chatId + '\'' +
", messageId=" + messageId +
", inlineMessageId=" + inlineMessageId +
", caption=" + caption +
", inlineMessageId='" + inlineMessageId + '\'' +
", caption='" + caption + '\'' +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -56,6 +56,7 @@ public class Message implements BotApiObject {
private static final String AUTHORSIGNATURE_FIELD = "author_signature";
private static final String FORWARDSIGNATURE_FIELD = "forward_signature";
private static final String MEDIAGROUPID_FIELD = "media_group_id";
private static final String CONNECTEDWEBSITE_FIELD = "connected_website";
@JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Integer Unique message identifier
@ -174,7 +175,9 @@ public class Message implements BotApiObject {
@JsonProperty(FORWARDSIGNATURE_FIELD)
private String forwardSignature; ///< Optional. Post author signature for messages forwarded from channel chats
@JsonProperty(MEDIAGROUPID_FIELD)
private String mediaGroupId;
private String mediaGroupId; ///< Optional. The unique identifier of a media message group this message belongs to
@JsonProperty(CONNECTEDWEBSITE_FIELD)
private String connectedWebsite; ///< Optional. The domain name of the website on which the user has logged in
public Message() {
super();
@ -418,6 +421,10 @@ public class Message implements BotApiObject {
return mediaGroupId;
}
public String getConnectedWebsite() {
return connectedWebsite;
}
@Override
public String toString() {
return "Message{" +
@ -462,6 +469,7 @@ public class Message implements BotApiObject {
", authorSignature='" + authorSignature + '\'' +
", forwardSignature='" + forwardSignature + '\'' +
", mediaGroupId='" + mediaGroupId + '\'' +
", connectedWebsite='" + connectedWebsite + '\'' +
'}';
}
}

View File

@ -9,12 +9,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to an mp3 audio file. By default, this audio file will be sent by the
* Represents a link to an mp3 audio file. By default, this audio file will be sent by the
* user. Alternatively, you can use input_message_content to send a message with the specified
* content instead of the audio.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultAudio implements InlineQueryResult {
@ -27,6 +26,7 @@ public class InlineQueryResultAudio implements InlineQueryResult {
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String CAPTION_FIELD = "caption";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "audio"; ///< Type of the result, must be "audio"
@ -46,6 +46,8 @@ public class InlineQueryResultAudio implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Audio caption (may also be used when resending documents by file_id), 0-200 characters
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultAudio() {
super();
@ -127,6 +129,15 @@ public class InlineQueryResultAudio implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultAudio setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -146,7 +157,8 @@ public class InlineQueryResultAudio implements InlineQueryResult {
@Override
public String toString() {
return "InlineQueryResultAudio{" +
"id='" + id + '\'' +
"type='" + type + '\'' +
", id='" + id + '\'' +
", audioUrl='" + audioUrl + '\'' +
", title='" + title + '\'' +
", performer='" + performer + '\'' +
@ -154,6 +166,7 @@ public class InlineQueryResultAudio implements InlineQueryResult {
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", caption='" + caption + '\'' +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -9,13 +9,12 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a file. By default, this file will be sent by the user with an
* Represents a link to a file. By default, this file will be sent by the user with an
* optional caption. Alternatively, you can use input_message_content to send a message with the
* specified content instead of the file.
* @note Currently, only .PDF and .ZIP files can be sent using this method.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 01 of January of 2016
*/
public class InlineQueryResultDocument implements InlineQueryResult {
@ -31,6 +30,7 @@ public class InlineQueryResultDocument implements InlineQueryResult {
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "document"; ///< Type of the result, must be "document"
@ -56,6 +56,8 @@ public class InlineQueryResultDocument implements InlineQueryResult {
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultDocument() {
super();
@ -164,6 +166,15 @@ public class InlineQueryResultDocument implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultDocument setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -191,16 +202,17 @@ public class InlineQueryResultDocument implements InlineQueryResult {
return "InlineQueryResultDocument{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", mimeType='" + mimeType + '\'' +
", documentUrl='" + documentUrl + '\'' +
", thumbHeight=" + thumbHeight +
", thumbWidth=" + thumbWidth +
", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' +
", documentUrl='" + documentUrl + '\'' +
", mimeType='" + mimeType + '\'' +
", description='" + description + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
", replyMarkup=" + replyMarkup +
", inputMessageContent=" + inputMessageContent +
", thumbUrl='" + thumbUrl + '\'' +
", thumbWidth=" + thumbWidth +
", thumbHeight=" + thumbHeight +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -9,13 +9,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to an animated GIF file. By default, this animated GIF file will be sent
* Represents a link to an animated GIF file. By default, this animated GIF file will be sent
* by the user with optional caption. Alternatively, you can use input_message_content to send a
* message with the specified content instead of the animation.
* @date 01 of January of 2016
*/
public class InlineQueryResultGif implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
private static final String ID_FIELD = "id";
private static final String GIFURL_FIELD = "gif_url";
@ -27,6 +25,7 @@ public class InlineQueryResultGif implements InlineQueryResult {
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String GIF_DURATION_FIELD = "gif_duration";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "gif"; ///< Type of the result, must be "gif"
@ -50,6 +49,8 @@ public class InlineQueryResultGif implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(GIF_DURATION_FIELD)
private Integer gifDuration; ///< Optional. Duration of the GIF
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultGif() {
super();
@ -144,8 +145,18 @@ public class InlineQueryResultGif implements InlineQueryResult {
return gifDuration;
}
public void setGifDuration(Integer gifDuration) {
public InlineQueryResultGif setGifDuration(Integer gifDuration) {
this.gifDuration = gifDuration;
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultGif setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
@ -178,6 +189,7 @@ public class InlineQueryResultGif implements InlineQueryResult {
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", gifDuration=" + gifDuration +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -27,6 +27,7 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String MPEG4_DURATION_FIELD = "mpeg4_duration";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
@ -50,6 +51,8 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(MPEG4_DURATION_FIELD)
private Integer mpeg4Duration; ///< Optional. Video duration
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultMpeg4Gif() {
super();
@ -144,8 +147,18 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
return mpeg4Duration;
}
public void setMpeg4Duration(Integer mpeg4Duration) {
public InlineQueryResultMpeg4Gif setMpeg4Duration(Integer mpeg4Duration) {
this.mpeg4Duration = mpeg4Duration;
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultMpeg4Gif setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
@ -178,6 +191,7 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", mpeg4Duration=" + mpeg4Duration +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -9,13 +9,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a photo. By default, this photo will be sent by the user with
* Represents a link to a photo. By default, this photo will be sent by the user with
* optional caption. Alternatively, you can use input_message_content to send a message with the
* specified content instead of the photo.
* @date 01 of January of 2016
*/
public class InlineQueryResultPhoto implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
private static final String ID_FIELD = "id";
private static final String PHOTOURL_FIELD = "photo_url";
@ -28,6 +26,7 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "photo"; ///< Type of the result, must be photo
@ -53,6 +52,8 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultPhoto() {
super();
@ -161,6 +162,15 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultPhoto setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -190,8 +200,9 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
", title='" + title + '\'' +
", description='" + description + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -9,13 +9,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents link to a page containing an embedded video player or a video file.
* Represents link to a page containing an embedded video player or a video file.
* Alternatively, you can use input_message_content to send a message with the specified content
* instead of the video.
* @date 01 of January of 2016
*/
public class InlineQueryResultVideo implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
private static final String ID_FIELD = "id";
private static final String MIMETYPE_FIELD = "mime_type";
@ -29,6 +27,7 @@ public class InlineQueryResultVideo implements InlineQueryResult {
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "video"; ///< Type of the result, must be "video"
@ -56,6 +55,8 @@ public class InlineQueryResultVideo implements InlineQueryResult {
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultVideo() {
super();
@ -173,6 +174,15 @@ public class InlineQueryResultVideo implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultVideo setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -203,8 +213,9 @@ public class InlineQueryResultVideo implements InlineQueryResult {
", title='" + title + '\'' +
", description='" + description + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -9,15 +9,13 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a voice recording in an .ogg container encoded with OPUS. By default,
* Represents a link to a voice recording in an .ogg container encoded with OPUS. By default,
* this voice recording will be sent by the user. Alternatively, you can use input_message_content
* to send a message with the specified content instead of the the voice message.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultVoice implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
private static final String ID_FIELD = "id";
private static final String VOICEURL_FIELD = "voice_url";
@ -26,6 +24,7 @@ public class InlineQueryResultVoice implements InlineQueryResult {
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String CAPTION_FIELD = "caption";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "voice"; ///< Type of the result, must be "voice"
@ -43,6 +42,8 @@ public class InlineQueryResultVoice implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Voice caption (may also be used when resending documents by file_id), 0-200 characters
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultVoice() {
super();
@ -134,13 +135,15 @@ public class InlineQueryResultVoice implements InlineQueryResult {
@Override
public String toString() {
return "InlineQueryResultVoice{" +
"id='" + id + '\'' +
"type='" + type + '\'' +
", id='" + id + '\'' +
", voiceUrl='" + voiceUrl + '\'' +
", title='" + title + '\'' +
", voiceDuration=" + voiceDuration +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", caption='" + caption + '\'' +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -25,6 +25,7 @@ public class InlineQueryResultCachedAudio implements InlineQueryResult {
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String CAPTION_FIELD = "caption";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "audio"; ///< Type of the result, must be "audio"
@ -38,6 +39,8 @@ public class InlineQueryResultCachedAudio implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Audio caption (may also be used when resending documents by file_id), 0-200 characters
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultCachedAudio() {
super();
@ -92,6 +95,15 @@ public class InlineQueryResultCachedAudio implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultCachedAudio setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -111,11 +123,13 @@ public class InlineQueryResultCachedAudio implements InlineQueryResult {
@Override
public String toString() {
return "InlineQueryResultCachedAudio{" +
"id='" + id + '\'' +
"type='" + type + '\'' +
", id='" + id + '\'' +
", audioFileId='" + audioFileId + '\'' +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", caption='" + caption + '\'' +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -10,13 +10,12 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a file stored on the Telegram servers. By default, this file will be
* Represents a link to a file stored on the Telegram servers. By default, this file will be
* sent by the user with an optional caption. Alternatively, you can use input_message_content to
* send a message with the specified content instead of the file.
* @note Currently, only pdf-files and zip archives can be sent using this method.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedDocument implements InlineQueryResult {
@ -28,6 +27,7 @@ public class InlineQueryResultCachedDocument implements InlineQueryResult {
private static final String CAPTION_FIELD = "caption";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "document"; ///< Type of the result, must be "document"
@ -45,6 +45,8 @@ public class InlineQueryResultCachedDocument implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the file
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultCachedDocument() {
super();
@ -117,6 +119,15 @@ public class InlineQueryResultCachedDocument implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultCachedDocument setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -141,12 +152,13 @@ public class InlineQueryResultCachedDocument implements InlineQueryResult {
return "InlineQueryResultCachedDocument{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", documentFileId='" + documentFileId + '\'' +
", caption='" + caption + '\'' +
", title='" + title + '\'' +
", documentFileId='" + documentFileId + '\'' +
", description='" + description + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
", caption='" + caption + '\'' +
", replyMarkup=" + replyMarkup +
", inputMessageContent=" + inputMessageContent +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -10,13 +10,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to an animated GIF file stored on the Telegram servers. By default, this
* Represents a link to an animated GIF file stored on the Telegram servers. By default, this
* animated GIF file will be sent by the user with an optional caption. Alternatively, you can use
* input_message_content to send a message with specified content instead of the animation.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedGif implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
private static final String ID_FIELD = "id";
private static final String GIF_FILE_ID_FIELD = "gif_file_id";
@ -24,6 +22,7 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "gif"; ///< Type of the result, must be "gif"
@ -39,6 +38,8 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the GIF animation
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultCachedGif() {
super();
@ -102,6 +103,15 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultCachedGif setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -123,11 +133,12 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
return "InlineQueryResultCachedGif{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", gifUrl='" + gifFileId + '\'' +
", gifFileId='" + gifFileId + '\'' +
", title='" + title + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -24,6 +24,7 @@ public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
@ -39,6 +40,8 @@ public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultCachedMpeg4Gif() {
super();
@ -102,6 +105,15 @@ public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultCachedMpeg4Gif setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -123,11 +135,12 @@ public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
return "InlineQueryResultCachedMpeg4Gif{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", mpeg4Url='" + mpeg4FileId + '\'' +
", mpeg4FileId='" + mpeg4FileId + '\'' +
", title='" + title + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -10,13 +10,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a photo stored on the Telegram servers. By default, this photo will
* Represents a link to a photo stored on the Telegram servers. By default, this photo will
* be sent by the user with an optional caption. Alternatively, you can use input_message_content to
* send a message with the specified content instead of the photo.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedPhoto implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
private static final String ID_FIELD = "id";
private static final String PHOTOFILEID_FIELD = "photo_file_id";
@ -25,6 +23,7 @@ public class InlineQueryResultCachedPhoto implements InlineQueryResult {
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "photo"; ///< Type of the result, must be photo
@ -42,6 +41,8 @@ public class InlineQueryResultCachedPhoto implements InlineQueryResult {
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultCachedPhoto() {
super();
@ -114,6 +115,15 @@ public class InlineQueryResultCachedPhoto implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultCachedPhoto setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -139,8 +149,9 @@ public class InlineQueryResultCachedPhoto implements InlineQueryResult {
", title='" + title + '\'' +
", description='" + description + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -10,13 +10,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a video file stored on the Telegram servers. By default, this video
* Represents a link to a video file stored on the Telegram servers. By default, this video
* file will be sent by the user with an optional caption. Alternatively, you can use
* input_message_content to send a message with the specified content instead of the video.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedVideo implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
private static final String ID_FIELD = "id";
private static final String VIDEO_FILE_ID_FIELD = "video_file_id";
@ -25,6 +23,7 @@ public class InlineQueryResultCachedVideo implements InlineQueryResult {
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "video"; ///< Type of the result, must be "video"
@ -42,6 +41,8 @@ public class InlineQueryResultCachedVideo implements InlineQueryResult {
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultCachedVideo() {
super();
@ -114,6 +115,15 @@ public class InlineQueryResultCachedVideo implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultCachedVideo setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -135,12 +145,13 @@ public class InlineQueryResultCachedVideo implements InlineQueryResult {
return "InlineQueryResultCachedVideo{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", caption='" + caption + '\'' +
", videoFileId='" + videoFileId + '\'' +
", title='" + title + '\'' +
", description='" + description + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -10,15 +10,13 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a voice message stored on the Telegram servers. By default, this
* Represents a link to a voice message stored on the Telegram servers. By default, this
* voice message will be sent by the user. Alternatively, you can use input_message_content to send
* a message with the specified content instead of the voice message.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedVoice implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
private static final String ID_FIELD = "id";
private static final String VOICE_FILE_ID_FIELD = "voice_file_id";
@ -26,6 +24,7 @@ public class InlineQueryResultCachedVoice implements InlineQueryResult {
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String CAPTION_FIELD = "caption";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(TYPE_FIELD)
private final String type = "voice"; ///< Type of the result, must be "voice"
@ -41,6 +40,8 @@ public class InlineQueryResultCachedVoice implements InlineQueryResult {
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Voice caption (may also be used when resending documents by file_id), 0-200 characters
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
public InlineQueryResultCachedVoice() {
super();
@ -104,6 +105,15 @@ public class InlineQueryResultCachedVoice implements InlineQueryResult {
return this;
}
public String getParseMode() {
return parseMode;
}
public InlineQueryResultCachedVoice setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (id == null || id.isEmpty()) {
@ -123,12 +133,14 @@ public class InlineQueryResultCachedVoice implements InlineQueryResult {
@Override
public String toString() {
return "InlineQueryResultCachedVoice{" +
"id='" + id + '\'' +
"type='" + type + '\'' +
", id='" + id + '\'' +
", voiceFileId='" + voiceFileId + '\'' +
", title='" + title + '\'' +
", inputMessageContent=" + inputMessageContent +
", replyMarkup=" + replyMarkup +
", caption='" + caption + '\'' +
", parseMode='" + parseMode + '\'' +
'}';
}
}

View File

@ -17,6 +17,7 @@ public abstract class InputMedia<T> implements InputBotApiObject, Validable {
protected static final String TYPE_FIELD = "type";
private static final String MEDIA_FIELD = "media";
private static final String CAPTION_FIELD = "caption";
private static final String PARSEMODE_FIELD = "parse_mode";
@JsonProperty(MEDIA_FIELD)
/**
@ -27,7 +28,8 @@ public abstract class InputMedia<T> implements InputBotApiObject, Validable {
private String media;
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the media to be sent, 0-200 characters
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
@JsonIgnore
private boolean isNewMedia; ///< True to upload a new media, false to use a fileId or URL
@JsonIgnore
@ -113,6 +115,15 @@ public abstract class InputMedia<T> implements InputBotApiObject, Validable {
return this;
}
public String getParseMode() {
return parseMode;
}
public InputMedia<T> setParseMode(String parseMode) {
this.parseMode = parseMode;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (isNewMedia) {

View File

@ -16,6 +16,7 @@ public class InputMediaVideo extends InputMedia<InputMediaVideo> {
private static final String WIDTH_FIELD = "width";
private static final String HEIGHT_FIELD = "height";
private static final String DURATION_FIELD = "duration";
private static final String SUPPORTSSTREAMING_FIELD = "supports_streaming";
@JsonProperty(WIDTH_FIELD)
private int width; ///< Optional. Video width
@ -23,6 +24,8 @@ public class InputMediaVideo extends InputMedia<InputMediaVideo> {
private int height; ///< Optional. Video height
@JsonProperty(DURATION_FIELD)
private int duration; ///< Optional. Video duration
@JsonProperty(SUPPORTSSTREAMING_FIELD)
private Boolean supportsStreaming; ///< Optional. Pass True, if the uploaded video is suitable for streaming
public InputMediaVideo() {
super();

View File

@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
@ -56,6 +58,25 @@ public class ForceReplyKeyboard implements ReplyKeyboard {
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ForceReplyKeyboard)) {
return false;
}
ForceReplyKeyboard forceReplyKeyboard = (ForceReplyKeyboard) o;
return Objects.equals(forceReply, forceReplyKeyboard.forceReply)
&& Objects.equals(selective, forceReplyKeyboard.selective)
;
}
@Override
public int hashCode() {
return Objects.hash(
forceReply,
selective);
}
@Override
public String toString() {
return "ForceReplyKeyboard{" +

View File

@ -7,6 +7,7 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author Ruben Bermudez
@ -50,6 +51,21 @@ public class InlineKeyboardMarkup implements ReplyKeyboard {
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof InlineKeyboardMarkup)) {
return false;
}
InlineKeyboardMarkup inlineKeyboardMarkup = (InlineKeyboardMarkup) o;
return Objects.equals(keyboard, inlineKeyboardMarkup.keyboard);
}
@Override
public int hashCode() {
return Objects.hash(keyboard);
}
@Override
public String toString() {
return "InlineKeyboardMarkup{" +

View File

@ -7,6 +7,7 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author Ruben Bermudez
@ -87,6 +88,29 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard {
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ReplyKeyboardMarkup)) {
return false;
}
ReplyKeyboardMarkup replyKeyboardMarkup = (ReplyKeyboardMarkup) o;
return Objects.equals(keyboard, replyKeyboardMarkup.keyboard)
&& Objects.equals(oneTimeKeyboard, replyKeyboardMarkup.oneTimeKeyboard)
&& Objects.equals(resizeKeyboard, replyKeyboardMarkup.resizeKeyboard)
&& Objects.equals(selective, replyKeyboardMarkup.selective)
;
}
@Override
public int hashCode() {
return Objects.hash(
keyboard,
oneTimeKeyboard,
resizeKeyboard,
selective);
}
@Override
public String toString() {
return "ReplyKeyboardMarkup{" +

View File

@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
@ -52,6 +54,25 @@ public class ReplyKeyboardRemove implements ReplyKeyboard {
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ReplyKeyboardRemove)) {
return false;
}
ReplyKeyboardRemove replyKeyboardRemove = (ReplyKeyboardRemove) o;
return Objects.equals(removeKeyboard, replyKeyboardRemove.removeKeyboard)
&& Objects.equals(selective, replyKeyboardRemove.selective)
;
}
@Override
public int hashCode() {
return Objects.hash(
removeKeyboard,
selective);
}
@Override
public String toString() {
return "ReplyKeyboardRemove{" +

View File

@ -6,6 +6,8 @@ import org.telegram.telegrambots.api.interfaces.Validable;
import org.telegram.telegrambots.api.objects.games.CallbackGame;
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@ -146,6 +148,35 @@ public class InlineKeyboardButton implements InputBotApiObject, Validable {
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof InlineKeyboardButton)) {
return false;
}
InlineKeyboardButton inlineKeyboardButton = (InlineKeyboardButton) o;
return Objects.equals(callbackData, inlineKeyboardButton.callbackData)
&& Objects.equals(callbackGame, inlineKeyboardButton.callbackGame)
&& Objects.equals(pay, inlineKeyboardButton.pay)
&& Objects.equals(switchInlineQuery, inlineKeyboardButton.switchInlineQuery)
&& Objects.equals(switchInlineQueryCurrentChat, inlineKeyboardButton.switchInlineQueryCurrentChat)
&& Objects.equals(text, inlineKeyboardButton.text)
&& Objects.equals(url, inlineKeyboardButton.url)
;
}
@Override
public int hashCode() {
return Objects.hash(
callbackData,
callbackGame,
pay,
switchInlineQuery,
switchInlineQueryCurrentChat,
text,
url);
}
@Override
public String toString() {
return "InlineKeyboardButton{" +

View File

@ -6,6 +6,8 @@ import org.telegram.telegrambots.api.interfaces.InputBotApiObject;
import org.telegram.telegrambots.api.interfaces.Validable;
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
import java.util.Objects;
/**
* @author Ruben Bermudez
* @version 1.0
@ -88,6 +90,27 @@ public class KeyboardButton implements InputBotApiObject, Validable {
}
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof KeyboardButton)) {
return false;
}
KeyboardButton keyboardButton = (KeyboardButton) o;
return Objects.equals(requestContact, keyboardButton.requestContact)
&& Objects.equals(requestLocation, keyboardButton.requestLocation)
&& Objects.equals(text, keyboardButton.text)
;
}
@Override
public int hashCode() {
return Objects.hash(
requestContact,
requestLocation,
text);
}
@Override
public String toString() {
return "KeyboardButton{" +

View File

@ -0,0 +1,25 @@
package org.telegram.telegrambots.api.methods.send;
import org.junit.Test;
import static org.junit.Assert.*;
public class SendMessageTest {
@Test
public void comparison() throws Exception {
SendMessage sm1 = new SendMessage().setChatId(1L).setText("Hello World");
SendMessage sm2 = new SendMessage().setChatId(1L).setText("Hello World");
SendMessage noMessage = new SendMessage().setChatId(1L);
SendMessage disabledNotification = new SendMessage().setChatId(1L).setText("Hello World").disableNotification();
assertTrue(sm1.equals(sm2));
assertFalse(sm1.equals(noMessage));
assertFalse(sm1.equals(disabledNotification));
assertTrue(sm1.hashCode() == sm2.hashCode());
assertFalse(sm1.hashCode() == noMessage.hashCode());
assertFalse(sm1.hashCode() == disabledNotification.hashCode());
}
}

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>3.5</version>
<version>3.6</version>
<packaging>jar</packaging>
<name>Telegram Bots</name>
@ -66,7 +66,7 @@
<jackson.version>2.8.7</jackson.version>
<jacksonanotation.version>2.8.0</jacksonanotation.version>
<commonio.version>2.5</commonio.version>
<bots.version>3.5</bots.version>
<bots.version>3.6</bots.version>
</properties>
<dependencyManagement>

View File

@ -51,7 +51,7 @@ import static org.telegram.telegrambots.Constants.SOCKET_TIMEOUT;
public abstract class DefaultAbsSender extends AbsSender {
private static final ContentType TEXT_PLAIN_CONTENT_TYPE = ContentType.create("text/plain", StandardCharsets.UTF_8);
private final ExecutorService exe;
protected final ExecutorService exe;
private final ObjectMapper objectMapper = new ObjectMapper();
private final DefaultBotOptions options;
private volatile CloseableHttpClient httpclient;
@ -157,6 +157,9 @@ public abstract class DefaultAbsSender extends AbsSender {
}
if (sendDocument.getCaption() != null) {
builder.addTextBody(SendDocument.CAPTION_FIELD, sendDocument.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
if (sendDocument.getParseMode() != null) {
builder.addTextBody(SendDocument.PARSEMODE_FIELD, sendDocument.getParseMode(), TEXT_PLAIN_CONTENT_TYPE);
}
}
if (sendDocument.getDisableNotification() != null) {
builder.addTextBody(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE);
@ -202,6 +205,9 @@ public abstract class DefaultAbsSender extends AbsSender {
}
if (sendPhoto.getCaption() != null) {
builder.addTextBody(SendPhoto.CAPTION_FIELD, sendPhoto.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
if (sendPhoto.getParseMode() != null) {
builder.addTextBody(SendPhoto.PARSEMODE_FIELD, sendPhoto.getParseMode(), TEXT_PLAIN_CONTENT_TYPE);
}
}
if (sendPhoto.getDisableNotification() != null) {
builder.addTextBody(SendPhoto.DISABLENOTIFICATION_FIELD, sendPhoto.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE);
@ -247,6 +253,12 @@ public abstract class DefaultAbsSender extends AbsSender {
}
if (sendVideo.getCaption() != null) {
builder.addTextBody(SendVideo.CAPTION_FIELD, sendVideo.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
if (sendVideo.getParseMode() != null) {
builder.addTextBody(SendVideo.PARSEMODE_FIELD, sendVideo.getParseMode(), TEXT_PLAIN_CONTENT_TYPE);
}
}
if (sendVideo.getSupportsStreaming() != null) {
builder.addTextBody(SendVideo.SUPPORTSSTREAMING_FIELD, sendVideo.getSupportsStreaming().toString(), TEXT_PLAIN_CONTENT_TYPE);
}
if (sendVideo.getDuration() != null) {
builder.addTextBody(SendVideo.DURATION_FIELD, sendVideo.getDuration().toString(), TEXT_PLAIN_CONTENT_TYPE);
@ -408,6 +420,9 @@ public abstract class DefaultAbsSender extends AbsSender {
}
if (sendAudio.getCaption() != null) {
builder.addTextBody(SendAudio.CAPTION_FIELD, sendAudio.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
if (sendAudio.getParseMode() != null) {
builder.addTextBody(SendAudio.PARSEMODE_FIELD, sendAudio.getParseMode(), TEXT_PLAIN_CONTENT_TYPE);
}
}
HttpEntity multipart = builder.build();
httppost.setEntity(multipart);
@ -462,6 +477,9 @@ public abstract class DefaultAbsSender extends AbsSender {
}
if (sendVoice.getCaption() != null) {
builder.addTextBody(SendVoice.CAPTION_FIELD, sendVoice.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
if (sendVoice.getParseMode() != null) {
builder.addTextBody(SendVoice.PARSEMODE_FIELD, sendVoice.getParseMode(), TEXT_PLAIN_CONTENT_TYPE);
}
}
HttpEntity multipart = builder.build();
httppost.setEntity(multipart);

View File

@ -55,4 +55,10 @@ public abstract class TelegramLongPollingBot extends DefaultAbsSender implements
throw new TelegramApiRequestException("Error executing setWebook method", e);
}
}
@Override
public void onClosing() {
exe.shutdown();
}
}

View File

@ -69,7 +69,7 @@ public class DefaultBotSession implements BotSession {
lastReceivedUpdate = 0;
readerThread = new ReaderThread(updatesSupplier);
readerThread = new ReaderThread(updatesSupplier, this);
readerThread.setName(callback.getBotUsername() + " Telegram Connection");
readerThread.start();
@ -135,12 +135,14 @@ public class DefaultBotSession implements BotSession {
private class ReaderThread extends Thread implements UpdatesReader {
private final UpdatesSupplier updatesSupplier;
private final Object lock;
private CloseableHttpClient httpclient;
private ExponentialBackOff exponentialBackOff;
private RequestConfig requestConfig;
public ReaderThread(UpdatesSupplier updatesSupplier) {
public ReaderThread(UpdatesSupplier updatesSupplier, Object lock) {
this.updatesSupplier = Optional.ofNullable(updatesSupplier).orElse(this::getUpdatesFromServer);
this.lock = lock;
}
@Override
@ -183,48 +185,52 @@ public class DefaultBotSession implements BotSession {
public void run() {
setPriority(Thread.MIN_PRIORITY);
while (running) {
try {
List<Update> updates = updatesSupplier.getUpdates();
if (updates.isEmpty()) {
synchronized (this) {
this.wait(500);
}
} else {
updates.removeIf(x -> x.getUpdateId() < lastReceivedUpdate);
lastReceivedUpdate = updates.parallelStream()
.map(
Update::getUpdateId)
.max(Integer::compareTo)
.orElse(0);
receivedUpdates.addAll(updates);
synchronized (lock) {
if (running) {
try {
List<Update> updates = updatesSupplier.getUpdates();
if (updates.isEmpty()) {
lock.wait(500);
} else {
updates.removeIf(x -> x.getUpdateId() < lastReceivedUpdate);
lastReceivedUpdate = updates.parallelStream()
.map(
Update::getUpdateId)
.max(Integer::compareTo)
.orElse(0);
receivedUpdates.addAll(updates);
synchronized (receivedUpdates) {
receivedUpdates.notifyAll();
synchronized (receivedUpdates) {
receivedUpdates.notifyAll();
}
}
} catch (InterruptedException e) {
if (!running) {
receivedUpdates.clear();
}
BotLogger.debug(LOGTAG, e);
interrupt();
} catch (Exception global) {
BotLogger.severe(LOGTAG, global);
try {
synchronized (lock) {
lock.wait(exponentialBackOff.nextBackOffMillis());
}
} catch (InterruptedException e) {
if (!running) {
receivedUpdates.clear();
}
BotLogger.debug(LOGTAG, e);
interrupt();
}
}
}
} catch (InterruptedException e) {
if (!running) {
receivedUpdates.clear();
}
BotLogger.debug(LOGTAG, e);
} catch (Exception global) {
BotLogger.severe(LOGTAG, global);
try {
synchronized (this) {
this.wait(exponentialBackOff.nextBackOffMillis());
}
} catch (InterruptedException e) {
if (!running) {
receivedUpdates.clear();
}
BotLogger.debug(LOGTAG, e);
}
}
}
BotLogger.debug(LOGTAG, "Reader thread has being closed");
}
private List<Update> getUpdatesFromServer() throws InterruptedException, Exception {
private List<Update> getUpdatesFromServer() throws IOException {
GetUpdates request = new GetUpdates()
.setLimit(100)
.setTimeout(ApiConstants.GETUPDATES_TIMEOUT)
@ -248,8 +254,8 @@ public class DefaultBotSession implements BotSession {
if (response.getStatusLine().getStatusCode() >= 500) {
BotLogger.warn(LOGTAG, responseContent);
synchronized (this) {
this.wait(500);
synchronized (lock) {
lock.wait(500);
}
} else {
try {
@ -260,14 +266,13 @@ public class DefaultBotSession implements BotSession {
BotLogger.severe(responseContent, LOGTAG, e);
}
}
} catch (SocketException e) {
if (!e.getMessage().equals("Socket Closed")) {
BotLogger.severe(LOGTAG, e);
}
} catch (SocketException | InvalidObjectException | TelegramApiRequestException e) {
BotLogger.severe(LOGTAG, e);
} catch (SocketTimeoutException e) {
BotLogger.fine(LOGTAG, e);
} catch (InvalidObjectException | TelegramApiRequestException e) {
BotLogger.severe(LOGTAG, e);
} catch (InterruptedException e) {
BotLogger.fine(LOGTAG, e);
interrupt();
}
return Collections.emptyList();
}
@ -275,7 +280,7 @@ public class DefaultBotSession implements BotSession {
public interface UpdatesSupplier {
List<Update> getUpdates() throws InterruptedException, Exception;
List<Update> getUpdates() throws Exception;
}
private List<Update> getUpdateList() {
@ -306,6 +311,7 @@ public class DefaultBotSession implements BotSession {
callback.onUpdatesReceived(updates);
} catch (InterruptedException e) {
BotLogger.debug(LOGTAG, e);
interrupt();
} catch (Exception e) {
BotLogger.severe(LOGTAG, e);
}

View File

@ -3,11 +3,17 @@ package org.telegram.telegrambots.test;
import org.junit.Test;
import org.mockito.Mockito;
import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.bots.DefaultBotOptions;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
public class TelegramLongPollingBotTest {
@ -21,4 +27,41 @@ public class TelegramLongPollingBotTest {
Mockito.verify(bot).onUpdateReceived(update1);
Mockito.verify(bot).onUpdateReceived(update2);
}
}
@Test
public void testExecutorShutdown() throws Exception {
TestBot bot = Mockito.spy(new TestBot());
DefaultBotSession session = new DefaultBotSession();
session.setCallback(bot);
session.setOptions(new DefaultBotOptions());
session.start();
session.stop();
Mockito.verify(bot).onClosing();
ExecutorService executor = bot.getExecutor();
assertThat("Executor was not shut down", executor.isShutdown(), is(true));
executor.awaitTermination(1, TimeUnit.SECONDS);
assertThat("Executor could not terminate", executor.isTerminated(), is(true));
}
private static class TestBot extends TelegramLongPollingBot {
@Override
public void onUpdateReceived(Update update) {
}
ExecutorService getExecutor() {
return exe;
}
@Override
public String getBotUsername() {
return "";
}
@Override
public String getBotToken() {
return "";
}
}
}