commit
7e369ea2fa
548
Bots.ipr
548
Bots.ipr
@ -36,6 +36,466 @@
|
|||||||
<module name="telegrambots-meta" target="1.8" />
|
<module name="telegrambots-meta" target="1.8" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</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">
|
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
|
||||||
<file url="file://$PROJECT_DIR$/telegrambots" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/telegrambots" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/telegrambots-abilities" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/telegrambots-abilities" charset="UTF-8" />
|
||||||
@ -46,9 +506,39 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<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="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||||
<inspection_tool class="JSLint" 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>
|
</profile>
|
||||||
<version value="1.0" />
|
<version value="1.0" />
|
||||||
</component>
|
</component>
|
||||||
@ -129,9 +619,6 @@
|
|||||||
<exe-path>/usr/local/bin/bower</exe-path>
|
<exe-path>/usr/local/bin/bower</exe-path>
|
||||||
<config-path />
|
<config-path />
|
||||||
</component>
|
</component>
|
||||||
<component name="KotlinCommonCompilerArguments">
|
|
||||||
<option name="coroutinesWarn" value="false" />
|
|
||||||
</component>
|
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="originalFiles">
|
||||||
<list>
|
<list>
|
||||||
@ -262,7 +749,32 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ProjectCodeStyleSettingsManager">
|
<component name="ProjectCodeStyleSettingsManager">
|
||||||
<option name="PER_PROJECT_SETTINGS">
|
<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>
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="GoogleStyle" />
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="GoogleStyle" />
|
||||||
</component>
|
</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!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-all/2.0.2-beta/mockito-all-2.0.2-beta-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</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>
|
||||||
<component name="masterDetails">
|
<component name="masterDetails">
|
||||||
<states>
|
<states>
|
||||||
|
@ -27,16 +27,16 @@ Just import add the library to your project with one of these options:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
```gradle
|
```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)
|
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.5)
|
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`.
|
In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.
|
||||||
|
|
||||||
|
@ -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 ###
|
### <a id="3.5"></a>3.5 ###
|
||||||
1. Support for Api Version [3.5](https://core.telegram.org/bots/api-changelog#november-17-2017)
|
1. Support for Api Version [3.5](https://core.telegram.org/bots/api-changelog#november-17-2017)
|
||||||
2. Bug fixing: #168, #329 and #335
|
2. Bug fixing: #168, #329 and #335
|
||||||
|
@ -11,7 +11,7 @@ First you need ot get the library and add it to your project. There are few poss
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* With **Gradle**:
|
* 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
|
```java
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Advanced
|
# Advanced
|
||||||
This will be more of a FAQ on some important notes before you embark on your next big bot project!
|
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.
|
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
|
```java
|
||||||
|
@ -9,12 +9,12 @@ As with any Java project, you will need to set your dependencies.
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-abilties</artifactId>
|
<artifactId>telegrambots-abilties</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
* **Gradle**
|
* **Gradle**
|
||||||
```groovy
|
```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)
|
* [JitPack](https://jitpack.io/#rubenlagus/TelegramBots)
|
||||||
|
|
||||||
|
4
pom.xml
4
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>Bots</artifactId>
|
<artifactId>Bots</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>telegrambots</module>
|
<module>telegrambots</module>
|
||||||
@ -26,6 +26,6 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.deploy.skip>true</maven.deploy.skip>
|
<maven.deploy.skip>true</maven.deploy.skip>
|
||||||
<bots.version>3.5</bots.version>
|
<bots.version>3.6</bots.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
@ -18,19 +18,19 @@ Usage
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Gradle**
|
**Gradle**
|
||||||
|
|
||||||
```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
|
Motivation
|
||||||
----------
|
----------
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-abilities</artifactId>
|
<artifactId>telegrambots-abilities</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Telegram Ability Bot</name>
|
<name>Telegram Ability Bot</name>
|
||||||
@ -65,7 +65,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<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>
|
<commonslang.version>3.5</commonslang.version>
|
||||||
<mapdb.version>3.0.4</mapdb.version>
|
<mapdb.version>3.0.4</mapdb.version>
|
||||||
<guava.version>19.0</guava.version>
|
<guava.version>19.0</guava.version>
|
||||||
|
@ -10,6 +10,7 @@ import org.telegram.abilitybots.api.util.AbilityUtils;
|
|||||||
import org.telegram.abilitybots.api.util.Pair;
|
import org.telegram.abilitybots.api.util.Pair;
|
||||||
import org.telegram.abilitybots.api.util.Trio;
|
import org.telegram.abilitybots.api.util.Trio;
|
||||||
import org.telegram.telegrambots.api.methods.GetFile;
|
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.methods.send.SendDocument;
|
||||||
import org.telegram.telegrambots.api.objects.Message;
|
import org.telegram.telegrambots.api.objects.Message;
|
||||||
import org.telegram.telegrambots.api.objects.Update;
|
import org.telegram.telegrambots.api.objects.Update;
|
||||||
@ -24,10 +25,7 @@ import java.io.FileReader;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -413,10 +411,10 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
|
|
||||||
Set<Integer> blacklist = blacklist();
|
Set<Integer> blacklist = blacklist();
|
||||||
if (blacklist.contains(userId))
|
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 {
|
else {
|
||||||
blacklist.add(userId);
|
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))
|
.post(commitTo(db))
|
||||||
@ -441,9 +439,9 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
Set<Integer> blacklist = blacklist();
|
Set<Integer> blacklist = blacklist();
|
||||||
|
|
||||||
if (!blacklist.remove(userId))
|
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 {
|
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))
|
.post(commitTo(db))
|
||||||
@ -465,10 +463,10 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
|
|
||||||
Set<Integer> admins = admins();
|
Set<Integer> admins = admins();
|
||||||
if (admins.contains(userId))
|
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 {
|
else {
|
||||||
admins.add(userId);
|
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))
|
}).post(commitTo(db))
|
||||||
.build();
|
.build();
|
||||||
@ -489,9 +487,9 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
|
|
||||||
Set<Integer> admins = admins();
|
Set<Integer> admins = admins();
|
||||||
if (admins.remove(userId)) {
|
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 {
|
} 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))
|
.post(commitTo(db))
|
||||||
@ -540,7 +538,7 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
abilities = stream(this.getClass().getMethods())
|
abilities = stream(this.getClass().getMethods())
|
||||||
.filter(method -> method.getReturnType().equals(Ability.class))
|
.filter(method -> method.getReturnType().equals(Ability.class))
|
||||||
.map(this::returnAbility)
|
.map(this::returnAbility)
|
||||||
.collect(toMap(Ability::name, identity()));
|
.collect(toMap(ability -> ability.name().toLowerCase(), identity()));
|
||||||
|
|
||||||
Stream<Reply> methodReplies = stream(this.getClass().getMethods())
|
Stream<Reply> methodReplies = stream(this.getClass().getMethods())
|
||||||
.filter(method -> method.getReturnType().equals(Reply.class))
|
.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);
|
boolean isOk = abilityTokens == 0 || (tokens.length > 0 && tokens.length == abilityTokens);
|
||||||
|
|
||||||
if (!isOk)
|
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;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,7 +627,7 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
boolean isOk = abilityLocality == ALL || locality == abilityLocality;
|
boolean isOk = abilityLocality == ALL || locality == abilityLocality;
|
||||||
|
|
||||||
if (!isOk)
|
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;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,15 +637,24 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
Privacy privacy;
|
Privacy privacy;
|
||||||
int id = user.id();
|
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;
|
boolean isOk = privacy.compareTo(trio.b().privacy()) >= 0;
|
||||||
|
|
||||||
if (!isOk)
|
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;
|
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) {
|
private boolean isCreator(int id) {
|
||||||
return id == creatorId();
|
return id == creatorId();
|
||||||
}
|
}
|
||||||
@ -667,11 +674,10 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
if (!update.hasMessage() || !msg.hasText())
|
if (!update.hasMessage() || !msg.hasText())
|
||||||
return Trio.of(update, abilities.get(DEFAULT), new String[]{});
|
return Trio.of(update, abilities.get(DEFAULT), new String[]{});
|
||||||
|
|
||||||
// Priority goes to text before captions
|
|
||||||
String[] tokens = msg.getText().split(" ");
|
String[] tokens = msg.getText().split(" ");
|
||||||
|
|
||||||
if (tokens[0].startsWith("/")) {
|
if (tokens[0].startsWith("/")) {
|
||||||
String abilityToken = stripBotUsername(tokens[0].substring(1));
|
String abilityToken = stripBotUsername(tokens[0].substring(1)).toLowerCase();
|
||||||
Ability ability = abilities.get(abilityToken);
|
Ability ability = abilities.get(abilityToken);
|
||||||
tokens = Arrays.copyOfRange(tokens, 1, tokens.length);
|
tokens = Arrays.copyOfRange(tokens, 1, tokens.length);
|
||||||
return Trio.of(update, ability, tokens);
|
return Trio.of(update, ability, tokens);
|
||||||
@ -743,4 +749,8 @@ public abstract class AbilityBot extends TelegramLongPollingBot {
|
|||||||
private File downloadFileWithId(String fileId) throws TelegramApiException {
|
private File downloadFileWithId(String fileId) throws TelegramApiException {
|
||||||
return sender.downloadFile(sender.execute(new GetFile().setFileId(fileId)));
|
return sender.downloadFile(sender.execute(new GetFile().setFileId(fileId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String escape(String username) {
|
||||||
|
return username.replace("_", "\\_");
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,6 +10,10 @@ public enum Privacy {
|
|||||||
* Anybody who is not a bot admin or its creator will be considered as a public user.
|
* Anybody who is not a bot admin or its creator will be considered as a public user.
|
||||||
*/
|
*/
|
||||||
PUBLIC,
|
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.
|
* A global admin of the bot, regardless of the group the bot is in.
|
||||||
*/
|
*/
|
||||||
|
@ -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.
|
* Fetches the direct chat ID of the specified update.
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,6 @@ package org.telegram.abilitybots.api.bot;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
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.sender.SilentSender;
|
||||||
import org.telegram.abilitybots.api.util.Pair;
|
import org.telegram.abilitybots.api.util.Pair;
|
||||||
import org.telegram.abilitybots.api.util.Trio;
|
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.api.objects.*;
|
||||||
import org.telegram.telegrambots.exceptions.TelegramApiException;
|
import org.telegram.telegrambots.exceptions.TelegramApiException;
|
||||||
|
|
||||||
@ -21,11 +21,14 @@ import java.io.IOException;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Lists.newArrayList;
|
||||||
import static com.google.common.collect.Sets.newHashSet;
|
import static com.google.common.collect.Sets.newHashSet;
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
import static java.util.Collections.emptySet;
|
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.io.FileUtils.deleteQuietly;
|
||||||
import static org.apache.commons.lang3.ArrayUtils.addAll;
|
import static org.apache.commons.lang3.ArrayUtils.addAll;
|
||||||
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
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.ALL;
|
||||||
import static org.telegram.abilitybots.api.objects.Locality.GROUP;
|
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.MessageContext.newContext;
|
||||||
import static org.telegram.abilitybots.api.objects.Privacy.ADMIN;
|
import static org.telegram.abilitybots.api.objects.Privacy.*;
|
||||||
import static org.telegram.abilitybots.api.objects.Privacy.PUBLIC;
|
|
||||||
|
|
||||||
public class AbilityBotTest {
|
public class AbilityBotTest {
|
||||||
private static final String[] EMPTY_ARRAY = {};
|
private static final String[] EMPTY_ARRAY = {};
|
||||||
@ -77,7 +79,7 @@ public class AbilityBotTest {
|
|||||||
|
|
||||||
bot.onUpdateReceived(update);
|
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
|
@Test
|
||||||
@ -342,20 +344,61 @@ public class AbilityBotTest {
|
|||||||
Message message = mock(Message.class);
|
Message message = mock(Message.class);
|
||||||
org.telegram.telegrambots.api.objects.User user = mock(User.class);
|
org.telegram.telegrambots.api.objects.User user = mock(User.class);
|
||||||
Ability publicAbility = getDefaultBuilder().privacy(PUBLIC).build();
|
Ability publicAbility = getDefaultBuilder().privacy(PUBLIC).build();
|
||||||
|
Ability groupAdminAbility = getDefaultBuilder().privacy(GROUP_ADMIN).build();
|
||||||
Ability adminAbility = getDefaultBuilder().privacy(ADMIN).build();
|
Ability adminAbility = getDefaultBuilder().privacy(ADMIN).build();
|
||||||
Ability creatorAbility = getDefaultBuilder().privacy(Privacy.CREATOR).build();
|
Ability creatorAbility = getDefaultBuilder().privacy(Privacy.CREATOR).build();
|
||||||
|
|
||||||
Trio<Update, Ability, String[]> publicTrio = Trio.of(update, publicAbility, TEXT);
|
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[]> adminTrio = Trio.of(update, adminAbility, TEXT);
|
||||||
Trio<Update, Ability, String[]> creatorTrio = Trio.of(update, creatorAbility, TEXT);
|
Trio<Update, Ability, String[]> creatorTrio = Trio.of(update, creatorAbility, TEXT);
|
||||||
|
|
||||||
mockUser(update, message, user);
|
mockUser(update, message, user);
|
||||||
|
|
||||||
assertEquals("Unexpected result when checking for privacy", true, bot.checkPrivacy(publicTrio));
|
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(adminTrio));
|
||||||
assertEquals("Unexpected result when checking for privacy", false, bot.checkPrivacy(creatorTrio));
|
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
|
@Test
|
||||||
public void canBlockAdminsFromCreatorAbilities() {
|
public void canBlockAdminsFromCreatorAbilities() {
|
||||||
Update update = mock(Update.class);
|
Update update = mock(Update.class);
|
||||||
@ -447,6 +490,25 @@ public class AbilityBotTest {
|
|||||||
assertEquals("Wrong ability was fetched", expected, actual);
|
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
|
@Test
|
||||||
public void canFetchDefaultAbility() {
|
public void canFetchDefaultAbility() {
|
||||||
Update update = mock(Update.class);
|
Update update = mock(Update.class);
|
||||||
|
@ -31,7 +31,7 @@ public class MapDBContextTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canRecoverDB() throws IOException {
|
public void canRecoverDB() {
|
||||||
Map<Integer, EndUser> users = db.getMap(USERS);
|
Map<Integer, EndUser> users = db.getMap(USERS);
|
||||||
Map<String, Integer> userIds = db.getMap(USER_ID);
|
Map<String, Integer> userIds = db.getMap(USER_ID);
|
||||||
users.put(CREATOR.id(), CREATOR);
|
users.put(CREATOR.id(), CREATOR);
|
||||||
|
@ -16,12 +16,12 @@ Just import add the library to your project with one of these options:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambotsextensions</artifactId>
|
<artifactId>telegrambotsextensions</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Using Gradle:
|
2. Using Gradle:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
compile "org.telegram:telegrambotsextensions:3.5"
|
compile "org.telegram:telegrambotsextensions:3.6"
|
||||||
```
|
```
|
@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambotsextensions</artifactId>
|
<artifactId>telegrambotsextensions</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Telegram Bots Extensions</name>
|
<name>Telegram Bots Extensions</name>
|
||||||
@ -59,7 +59,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<bots.version>3.5</bots.version>
|
<bots.version>3.6</bots.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots-meta</artifactId>
|
<artifactId>telegrambots-meta</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Telegram Bots Meta</name>
|
<name>Telegram Bots Meta</name>
|
||||||
|
@ -17,12 +17,11 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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
|
* 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.
|
* size, this limit may be changed in the future.
|
||||||
* @note For sending voice notes, use sendVoice method instead.
|
* @note For sending voice notes, use sendVoice method instead.
|
||||||
* @date 16 of July of 2015
|
|
||||||
*/
|
*/
|
||||||
public class SendAudio extends PartialBotApiMethod<Message> {
|
public class SendAudio extends PartialBotApiMethod<Message> {
|
||||||
public static final String PATH = "sendaudio";
|
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 PERFOMER_FIELD = "performer";
|
||||||
public static final String TITLE_FIELD = "title";
|
public static final String TITLE_FIELD = "title";
|
||||||
public static final String CAPTION_FIELD = "caption";
|
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 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)
|
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 performer; ///< Optional. Performer of sent audio
|
||||||
private String title; ///< Optional. Title 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 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 boolean isNewAudio; ///< True to upload a new audio, false to use a fileId
|
||||||
private String audioName;
|
private String audioName;
|
||||||
@ -191,6 +193,15 @@ public class SendAudio extends PartialBotApiMethod<Message> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendAudio setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||||
try {
|
try {
|
||||||
@ -239,11 +250,12 @@ public class SendAudio extends PartialBotApiMethod<Message> {
|
|||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", performer='" + performer + '\'' +
|
", performer='" + performer + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
|
", caption='" + caption + '\'' +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
", isNewAudio=" + isNewAudio +
|
", isNewAudio=" + isNewAudio +
|
||||||
", audioName='" + audioName + '\'' +
|
", audioName='" + audioName + '\'' +
|
||||||
", newAudioFile=" + newAudioFile +
|
", newAudioFile=" + newAudioFile +
|
||||||
", newAudioStream=" + newAudioStream +
|
", newAudioStream=" + newAudioStream +
|
||||||
", caption='" + caption + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,7 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @brief Use this method to send general files. On success, the sent Message is returned.
|
* Use this method to send general files. On success, the sent Message is returned.
|
||||||
* @date 20 of June of 2015
|
|
||||||
*/
|
*/
|
||||||
public class SendDocument extends PartialBotApiMethod<Message> {
|
public class SendDocument extends PartialBotApiMethod<Message> {
|
||||||
public static final String PATH = "senddocument";
|
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 DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
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 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 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 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 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 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 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 boolean isNewDocument; ///< True to upload a new document, false to use a fileId
|
||||||
private String documentName;
|
private String documentName;
|
||||||
@ -154,6 +156,15 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendDocument setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||||
try {
|
try {
|
||||||
@ -196,9 +207,15 @@ public class SendDocument extends PartialBotApiMethod<Message> {
|
|||||||
return "SendDocument{" +
|
return "SendDocument{" +
|
||||||
"chatId='" + chatId + '\'' +
|
"chatId='" + chatId + '\'' +
|
||||||
", document='" + document + '\'' +
|
", document='" + document + '\'' +
|
||||||
|
", caption='" + caption + '\'' +
|
||||||
|
", disableNotification=" + disableNotification +
|
||||||
", replyToMessageId=" + replyToMessageId +
|
", replyToMessageId=" + replyToMessageId +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
", isNewDocument=" + isNewDocument +
|
", isNewDocument=" + isNewDocument +
|
||||||
|
", documentName='" + documentName + '\'' +
|
||||||
|
", newDocumentFile=" + newDocumentFile +
|
||||||
|
", newDocumentStream=" + newDocumentStream +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SendMessage{" +
|
return "SendMessage{" +
|
||||||
|
@ -17,8 +17,7 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @brief Use this method to send photos. On success, the sent Message is returned.
|
* Use this method to send photos. On success, the sent Message is returned.
|
||||||
* @date 20 of June of 2015
|
|
||||||
*/
|
*/
|
||||||
public class SendPhoto extends PartialBotApiMethod<Message> {
|
public class SendPhoto extends PartialBotApiMethod<Message> {
|
||||||
public static final String PATH = "sendphoto";
|
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 DISABLENOTIFICATION_FIELD = "disable_notification";
|
||||||
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
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 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 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 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 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 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 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 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
|
private String photoName; ///< Name of the photo
|
||||||
@ -142,6 +144,15 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendPhoto setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||||
try {
|
try {
|
||||||
@ -184,9 +195,14 @@ public class SendPhoto extends PartialBotApiMethod<Message> {
|
|||||||
"chatId='" + chatId + '\'' +
|
"chatId='" + chatId + '\'' +
|
||||||
", photo='" + photo + '\'' +
|
", photo='" + photo + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
|
", disableNotification=" + disableNotification +
|
||||||
", replyToMessageId=" + replyToMessageId +
|
", replyToMessageId=" + replyToMessageId +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
", isNewPhoto=" + isNewPhoto +
|
", isNewPhoto=" + isNewPhoto +
|
||||||
|
", photoName='" + photoName + '\'' +
|
||||||
|
", newPhotoFile=" + newPhotoFile +
|
||||||
|
", newPhotoStream=" + newPhotoStream +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,17 +31,22 @@ public class SendVideo extends PartialBotApiMethod<Message> {
|
|||||||
public static final String WIDTH_FIELD = "width";
|
public static final String WIDTH_FIELD = "width";
|
||||||
public static final String HEIGHT_FIELD = "height";
|
public static final String HEIGHT_FIELD = "height";
|
||||||
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
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 REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
||||||
public static final String REPLYMARKUP_FIELD = "reply_markup";
|
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 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 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 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 String caption; ///< OptionaL. Video caption (may also be used when resending videos by file_id).
|
||||||
private Integer width; ///< Optional. Video width
|
private Integer width; ///< Optional. Video width
|
||||||
private Integer height; ///< OptionaL. Video height
|
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 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 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 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 boolean isNewVideo; ///< True to upload a new video, false to use a fileId
|
||||||
private String videoName; ///< Name of the video
|
private String videoName; ///< Name of the video
|
||||||
@ -176,6 +181,24 @@ public class SendVideo extends PartialBotApiMethod<Message> {
|
|||||||
return this;
|
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
|
@Override
|
||||||
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||||
try {
|
try {
|
||||||
|
@ -17,10 +17,9 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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).
|
* (other formats may be sent as Audio or Document).
|
||||||
* @date 16 of July of 2015
|
|
||||||
*/
|
*/
|
||||||
public class SendVoice extends PartialBotApiMethod<Message> {
|
public class SendVoice extends PartialBotApiMethod<Message> {
|
||||||
public static final String PATH = "sendvoice";
|
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 REPLYMARKUP_FIELD = "reply_markup";
|
||||||
public static final String DURATION_FIELD = "duration";
|
public static final String DURATION_FIELD = "duration";
|
||||||
public static final String CAPTION_FIELD = "caption";
|
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 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.
|
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 ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
||||||
private Integer duration; ///< Optional. Duration of sent audio in seconds
|
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 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 boolean isNewVoice; ///< True to upload a new voice note, false to use a fileId
|
||||||
private String voiceName; ///< Name of the voice note
|
private String voiceName; ///< Name of the voice note
|
||||||
@ -156,6 +157,15 @@ public class SendVoice extends PartialBotApiMethod<Message> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendVoice setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
|
||||||
try {
|
try {
|
||||||
@ -203,6 +213,7 @@ public class SendVoice extends PartialBotApiMethod<Message> {
|
|||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", duration=" + duration +
|
", duration=" + duration +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
", isNewVoice=" + isNewVoice +
|
", isNewVoice=" + isNewVoice +
|
||||||
", voiceName='" + voiceName + '\'' +
|
", voiceName='" + voiceName + '\'' +
|
||||||
", newVoiceFile=" + newVoiceFile +
|
", newVoiceFile=" + newVoiceFile +
|
||||||
|
@ -16,9 +16,8 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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.
|
* 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 class EditMessageCaption extends BotApiMethod<Serializable> {
|
||||||
public static final String PATH = "editmessagecaption";
|
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 INLINE_MESSAGE_ID_FIELD = "inline_message_id";
|
||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
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
|
* 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
|
private String caption; ///< Optional. New caption of the message
|
||||||
@JsonProperty(REPLYMARKUP_FIELD)
|
@JsonProperty(REPLYMARKUP_FIELD)
|
||||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
|
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() {
|
public EditMessageCaption() {
|
||||||
super();
|
super();
|
||||||
@ -99,6 +101,15 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditMessageCaption setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMethod() {
|
public String getMethod() {
|
||||||
return PATH;
|
return PATH;
|
||||||
@ -155,11 +166,12 @@ public class EditMessageCaption extends BotApiMethod<Serializable> {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "EditMessageCaption{" +
|
return "EditMessageCaption{" +
|
||||||
"chatId=" + chatId +
|
"chatId='" + chatId + '\'' +
|
||||||
", messageId=" + messageId +
|
", messageId=" + messageId +
|
||||||
", inlineMessageId=" + inlineMessageId +
|
", inlineMessageId='" + inlineMessageId + '\'' +
|
||||||
", caption=" + caption +
|
", caption='" + caption + '\'' +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ public class Message implements BotApiObject {
|
|||||||
private static final String AUTHORSIGNATURE_FIELD = "author_signature";
|
private static final String AUTHORSIGNATURE_FIELD = "author_signature";
|
||||||
private static final String FORWARDSIGNATURE_FIELD = "forward_signature";
|
private static final String FORWARDSIGNATURE_FIELD = "forward_signature";
|
||||||
private static final String MEDIAGROUPID_FIELD = "media_group_id";
|
private static final String MEDIAGROUPID_FIELD = "media_group_id";
|
||||||
|
private static final String CONNECTEDWEBSITE_FIELD = "connected_website";
|
||||||
|
|
||||||
@JsonProperty(MESSAGEID_FIELD)
|
@JsonProperty(MESSAGEID_FIELD)
|
||||||
private Integer messageId; ///< Integer Unique message identifier
|
private Integer messageId; ///< Integer Unique message identifier
|
||||||
@ -174,7 +175,9 @@ public class Message implements BotApiObject {
|
|||||||
@JsonProperty(FORWARDSIGNATURE_FIELD)
|
@JsonProperty(FORWARDSIGNATURE_FIELD)
|
||||||
private String forwardSignature; ///< Optional. Post author signature for messages forwarded from channel chats
|
private String forwardSignature; ///< Optional. Post author signature for messages forwarded from channel chats
|
||||||
@JsonProperty(MEDIAGROUPID_FIELD)
|
@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() {
|
public Message() {
|
||||||
super();
|
super();
|
||||||
@ -418,6 +421,10 @@ public class Message implements BotApiObject {
|
|||||||
return mediaGroupId;
|
return mediaGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getConnectedWebsite() {
|
||||||
|
return connectedWebsite;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Message{" +
|
return "Message{" +
|
||||||
@ -462,6 +469,7 @@ public class Message implements BotApiObject {
|
|||||||
", authorSignature='" + authorSignature + '\'' +
|
", authorSignature='" + authorSignature + '\'' +
|
||||||
", forwardSignature='" + forwardSignature + '\'' +
|
", forwardSignature='" + forwardSignature + '\'' +
|
||||||
", mediaGroupId='" + mediaGroupId + '\'' +
|
", mediaGroupId='" + mediaGroupId + '\'' +
|
||||||
|
", connectedWebsite='" + connectedWebsite + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* user. Alternatively, you can use input_message_content to send a message with the specified
|
||||||
* content instead of the audio.
|
* content instead of the audio.
|
||||||
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
|
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
|
||||||
* ignore them.
|
* ignore them.
|
||||||
* @date 10 of April of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultAudio implements InlineQueryResult {
|
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 INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "audio"; ///< Type of the result, must be "audio"
|
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
|
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
||||||
@JsonProperty(CAPTION_FIELD)
|
@JsonProperty(CAPTION_FIELD)
|
||||||
private String caption; ///< Optional. Audio caption (may also be used when resending documents by file_id), 0-200 characters
|
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() {
|
public InlineQueryResultAudio() {
|
||||||
super();
|
super();
|
||||||
@ -127,6 +129,15 @@ public class InlineQueryResultAudio implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultAudio setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -146,7 +157,8 @@ public class InlineQueryResultAudio implements InlineQueryResult {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InlineQueryResultAudio{" +
|
return "InlineQueryResultAudio{" +
|
||||||
"id='" + id + '\'' +
|
"type='" + type + '\'' +
|
||||||
|
", id='" + id + '\'' +
|
||||||
", audioUrl='" + audioUrl + '\'' +
|
", audioUrl='" + audioUrl + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", performer='" + performer + '\'' +
|
", performer='" + performer + '\'' +
|
||||||
@ -154,6 +166,7 @@ public class InlineQueryResultAudio implements InlineQueryResult {
|
|||||||
", inputMessageContent=" + inputMessageContent +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,12 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* optional caption. Alternatively, you can use input_message_content to send a message with the
|
||||||
* specified content instead of the file.
|
* specified content instead of the file.
|
||||||
* @note Currently, only .PDF and .ZIP files can be sent using this method.
|
* @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
|
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
|
||||||
* ignore them.
|
* ignore them.
|
||||||
* @date 01 of January of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultDocument implements InlineQueryResult {
|
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 THUMBURL_FIELD = "thumb_url";
|
||||||
private static final String THUMBWIDTH_FIELD = "thumb_width";
|
private static final String THUMBWIDTH_FIELD = "thumb_width";
|
||||||
private static final String THUMBHEIGHT_FIELD = "thumb_height";
|
private static final String THUMBHEIGHT_FIELD = "thumb_height";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "document"; ///< Type of the result, must be "document"
|
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
|
private Integer thumbWidth; ///< Optional. Thumbnail width
|
||||||
@JsonProperty(THUMBHEIGHT_FIELD)
|
@JsonProperty(THUMBHEIGHT_FIELD)
|
||||||
private Integer thumbHeight; ///< Optional. Thumbnail height
|
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() {
|
public InlineQueryResultDocument() {
|
||||||
super();
|
super();
|
||||||
@ -164,6 +166,15 @@ public class InlineQueryResultDocument implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultDocument setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -191,16 +202,17 @@ public class InlineQueryResultDocument implements InlineQueryResult {
|
|||||||
return "InlineQueryResultDocument{" +
|
return "InlineQueryResultDocument{" +
|
||||||
"type='" + type + '\'' +
|
"type='" + type + '\'' +
|
||||||
", id='" + id + '\'' +
|
", id='" + id + '\'' +
|
||||||
", mimeType='" + mimeType + '\'' +
|
|
||||||
", documentUrl='" + documentUrl + '\'' +
|
|
||||||
", thumbHeight=" + thumbHeight +
|
|
||||||
", thumbWidth=" + thumbWidth +
|
|
||||||
", thumbUrl='" + thumbUrl + '\'' +
|
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
|
", documentUrl='" + documentUrl + '\'' +
|
||||||
|
", mimeType='" + mimeType + '\'' +
|
||||||
", description='" + description + '\'' +
|
", description='" + description + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", inputMessageContent='" + inputMessageContent + '\'' +
|
", replyMarkup=" + replyMarkup +
|
||||||
", replyMarkup='" + replyMarkup + '\'' +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
|
", thumbUrl='" + thumbUrl + '\'' +
|
||||||
|
", thumbWidth=" + thumbWidth +
|
||||||
|
", thumbHeight=" + thumbHeight +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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.
|
* message with the specified content instead of the animation.
|
||||||
* @date 01 of January of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultGif implements InlineQueryResult {
|
public class InlineQueryResultGif implements InlineQueryResult {
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String GIFURL_FIELD = "gif_url";
|
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 INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String GIF_DURATION_FIELD = "gif_duration";
|
private static final String GIF_DURATION_FIELD = "gif_duration";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "gif"; ///< Type of the result, must be "gif"
|
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
|
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
||||||
@JsonProperty(GIF_DURATION_FIELD)
|
@JsonProperty(GIF_DURATION_FIELD)
|
||||||
private Integer gifDuration; ///< Optional. Duration of the GIF
|
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() {
|
public InlineQueryResultGif() {
|
||||||
super();
|
super();
|
||||||
@ -144,8 +145,18 @@ public class InlineQueryResultGif implements InlineQueryResult {
|
|||||||
return gifDuration;
|
return gifDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGifDuration(Integer gifDuration) {
|
public InlineQueryResultGif setGifDuration(Integer gifDuration) {
|
||||||
this.gifDuration = gifDuration;
|
this.gifDuration = gifDuration;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultGif setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -178,6 +189,7 @@ public class InlineQueryResultGif implements InlineQueryResult {
|
|||||||
", inputMessageContent=" + inputMessageContent +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", gifDuration=" + gifDuration +
|
", gifDuration=" + gifDuration +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
|
|||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String MPEG4_DURATION_FIELD = "mpeg4_duration";
|
private static final String MPEG4_DURATION_FIELD = "mpeg4_duration";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
|
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
|
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
||||||
@JsonProperty(MPEG4_DURATION_FIELD)
|
@JsonProperty(MPEG4_DURATION_FIELD)
|
||||||
private Integer mpeg4Duration; ///< Optional. Video duration
|
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() {
|
public InlineQueryResultMpeg4Gif() {
|
||||||
super();
|
super();
|
||||||
@ -144,8 +147,18 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
|
|||||||
return mpeg4Duration;
|
return mpeg4Duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMpeg4Duration(Integer mpeg4Duration) {
|
public InlineQueryResultMpeg4Gif setMpeg4Duration(Integer mpeg4Duration) {
|
||||||
this.mpeg4Duration = mpeg4Duration;
|
this.mpeg4Duration = mpeg4Duration;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultMpeg4Gif setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -178,6 +191,7 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
|
|||||||
", inputMessageContent=" + inputMessageContent +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", mpeg4Duration=" + mpeg4Duration +
|
", mpeg4Duration=" + mpeg4Duration +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* optional caption. Alternatively, you can use input_message_content to send a message with the
|
||||||
* specified content instead of the photo.
|
* specified content instead of the photo.
|
||||||
* @date 01 of January of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultPhoto implements InlineQueryResult {
|
public class InlineQueryResultPhoto implements InlineQueryResult {
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String PHOTOURL_FIELD = "photo_url";
|
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 CAPTION_FIELD = "caption";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "photo"; ///< Type of the result, must be “photo”
|
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
|
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
|
||||||
@JsonProperty(REPLY_MARKUP_FIELD)
|
@JsonProperty(REPLY_MARKUP_FIELD)
|
||||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
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() {
|
public InlineQueryResultPhoto() {
|
||||||
super();
|
super();
|
||||||
@ -161,6 +162,15 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultPhoto setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -190,8 +200,9 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
|
|||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", description='" + description + '\'' +
|
", description='" + description + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", inputMessageContent='" + inputMessageContent + '\'' +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup='" + replyMarkup + '\'' +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* Alternatively, you can use input_message_content to send a message with the specified content
|
||||||
* instead of the video.
|
* instead of the video.
|
||||||
* @date 01 of January of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultVideo implements InlineQueryResult {
|
public class InlineQueryResultVideo implements InlineQueryResult {
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String MIMETYPE_FIELD = "mime_type";
|
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 CAPTION_FIELD = "caption";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "video"; ///< Type of the result, must be "video"
|
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
|
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
|
||||||
@JsonProperty(REPLY_MARKUP_FIELD)
|
@JsonProperty(REPLY_MARKUP_FIELD)
|
||||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
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() {
|
public InlineQueryResultVideo() {
|
||||||
super();
|
super();
|
||||||
@ -173,6 +174,15 @@ public class InlineQueryResultVideo implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultVideo setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -203,8 +213,9 @@ public class InlineQueryResultVideo implements InlineQueryResult {
|
|||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", description='" + description + '\'' +
|
", description='" + description + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", inputMessageContent='" + inputMessageContent + '\'' +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup='" + replyMarkup + '\'' +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,13 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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.
|
* 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
|
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
|
||||||
* ignore them.
|
* ignore them.
|
||||||
* @date 10 of April of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultVoice implements InlineQueryResult {
|
public class InlineQueryResultVoice implements InlineQueryResult {
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String VOICEURL_FIELD = "voice_url";
|
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 INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "voice"; ///< Type of the result, must be "voice"
|
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
|
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
||||||
@JsonProperty(CAPTION_FIELD)
|
@JsonProperty(CAPTION_FIELD)
|
||||||
private String caption; ///< Optional. Voice caption (may also be used when resending documents by file_id), 0-200 characters
|
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() {
|
public InlineQueryResultVoice() {
|
||||||
super();
|
super();
|
||||||
@ -134,13 +135,15 @@ public class InlineQueryResultVoice implements InlineQueryResult {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InlineQueryResultVoice{" +
|
return "InlineQueryResultVoice{" +
|
||||||
"id='" + id + '\'' +
|
"type='" + type + '\'' +
|
||||||
|
", id='" + id + '\'' +
|
||||||
", voiceUrl='" + voiceUrl + '\'' +
|
", voiceUrl='" + voiceUrl + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", voiceDuration=" + voiceDuration +
|
", voiceDuration=" + voiceDuration +
|
||||||
", inputMessageContent=" + inputMessageContent +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ public class InlineQueryResultCachedAudio implements InlineQueryResult {
|
|||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "audio"; ///< Type of the result, must be "audio"
|
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
|
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
||||||
@JsonProperty(CAPTION_FIELD)
|
@JsonProperty(CAPTION_FIELD)
|
||||||
private String caption; ///< Optional. Audio caption (may also be used when resending documents by file_id), 0-200 characters
|
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() {
|
public InlineQueryResultCachedAudio() {
|
||||||
super();
|
super();
|
||||||
@ -92,6 +95,15 @@ public class InlineQueryResultCachedAudio implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedAudio setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -111,11 +123,13 @@ public class InlineQueryResultCachedAudio implements InlineQueryResult {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InlineQueryResultCachedAudio{" +
|
return "InlineQueryResultCachedAudio{" +
|
||||||
"id='" + id + '\'' +
|
"type='" + type + '\'' +
|
||||||
|
", id='" + id + '\'' +
|
||||||
", audioFileId='" + audioFileId + '\'' +
|
", audioFileId='" + audioFileId + '\'' +
|
||||||
", inputMessageContent=" + inputMessageContent +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,12 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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.
|
* 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 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
|
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
|
||||||
* ignore them.
|
* ignore them.
|
||||||
* @date 10 of April of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultCachedDocument implements InlineQueryResult {
|
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 CAPTION_FIELD = "caption";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "document"; ///< Type of the result, must be "document"
|
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
|
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
||||||
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
|
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
|
||||||
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the file
|
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() {
|
public InlineQueryResultCachedDocument() {
|
||||||
super();
|
super();
|
||||||
@ -117,6 +119,15 @@ public class InlineQueryResultCachedDocument implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedDocument setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -141,12 +152,13 @@ public class InlineQueryResultCachedDocument implements InlineQueryResult {
|
|||||||
return "InlineQueryResultCachedDocument{" +
|
return "InlineQueryResultCachedDocument{" +
|
||||||
"type='" + type + '\'' +
|
"type='" + type + '\'' +
|
||||||
", id='" + id + '\'' +
|
", id='" + id + '\'' +
|
||||||
", documentFileId='" + documentFileId + '\'' +
|
|
||||||
", caption='" + caption + '\'' +
|
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
|
", documentFileId='" + documentFileId + '\'' +
|
||||||
", description='" + description + '\'' +
|
", description='" + description + '\'' +
|
||||||
", inputMessageContent='" + inputMessageContent + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", replyMarkup='" + replyMarkup + '\'' +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", inputMessageContent=" + inputMessageContent +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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.
|
* 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 {
|
public class InlineQueryResultCachedGif implements InlineQueryResult {
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String GIF_FILE_ID_FIELD = "gif_file_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 CAPTION_FIELD = "caption";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "gif"; ///< Type of the result, must be "gif"
|
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
|
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the GIF animation
|
||||||
@JsonProperty(REPLY_MARKUP_FIELD)
|
@JsonProperty(REPLY_MARKUP_FIELD)
|
||||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
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() {
|
public InlineQueryResultCachedGif() {
|
||||||
super();
|
super();
|
||||||
@ -102,6 +103,15 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedGif setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -123,11 +133,12 @@ public class InlineQueryResultCachedGif implements InlineQueryResult {
|
|||||||
return "InlineQueryResultCachedGif{" +
|
return "InlineQueryResultCachedGif{" +
|
||||||
"type='" + type + '\'' +
|
"type='" + type + '\'' +
|
||||||
", id='" + id + '\'' +
|
", id='" + id + '\'' +
|
||||||
", gifUrl='" + gifFileId + '\'' +
|
", gifFileId='" + gifFileId + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", inputMessageContent='" + inputMessageContent + '\'' +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup='" + replyMarkup + '\'' +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
|
|||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
|
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
|
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
|
||||||
@JsonProperty(REPLY_MARKUP_FIELD)
|
@JsonProperty(REPLY_MARKUP_FIELD)
|
||||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
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() {
|
public InlineQueryResultCachedMpeg4Gif() {
|
||||||
super();
|
super();
|
||||||
@ -102,6 +105,15 @@ public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedMpeg4Gif setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -123,11 +135,12 @@ public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
|
|||||||
return "InlineQueryResultCachedMpeg4Gif{" +
|
return "InlineQueryResultCachedMpeg4Gif{" +
|
||||||
"type='" + type + '\'' +
|
"type='" + type + '\'' +
|
||||||
", id='" + id + '\'' +
|
", id='" + id + '\'' +
|
||||||
", mpeg4Url='" + mpeg4FileId + '\'' +
|
", mpeg4FileId='" + mpeg4FileId + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", inputMessageContent='" + inputMessageContent + '\'' +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup='" + replyMarkup + '\'' +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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.
|
* send a message with the specified content instead of the photo.
|
||||||
* @date 10 of April of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultCachedPhoto implements InlineQueryResult {
|
public class InlineQueryResultCachedPhoto implements InlineQueryResult {
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String PHOTOFILEID_FIELD = "photo_file_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 CAPTION_FIELD = "caption";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "photo"; ///< Type of the result, must be “photo”
|
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
|
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
|
||||||
@JsonProperty(REPLY_MARKUP_FIELD)
|
@JsonProperty(REPLY_MARKUP_FIELD)
|
||||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
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() {
|
public InlineQueryResultCachedPhoto() {
|
||||||
super();
|
super();
|
||||||
@ -114,6 +115,15 @@ public class InlineQueryResultCachedPhoto implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedPhoto setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -139,8 +149,9 @@ public class InlineQueryResultCachedPhoto implements InlineQueryResult {
|
|||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", description='" + description + '\'' +
|
", description='" + description + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", inputMessageContent='" + inputMessageContent + '\'' +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup='" + replyMarkup + '\'' +
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,11 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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.
|
* 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 {
|
public class InlineQueryResultCachedVideo implements InlineQueryResult {
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String VIDEO_FILE_ID_FIELD = "video_file_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 CAPTION_FIELD = "caption";
|
||||||
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "video"; ///< Type of the result, must be "video"
|
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
|
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
|
||||||
@JsonProperty(REPLY_MARKUP_FIELD)
|
@JsonProperty(REPLY_MARKUP_FIELD)
|
||||||
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
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() {
|
public InlineQueryResultCachedVideo() {
|
||||||
super();
|
super();
|
||||||
@ -114,6 +115,15 @@ public class InlineQueryResultCachedVideo implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedVideo setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -135,12 +145,13 @@ public class InlineQueryResultCachedVideo implements InlineQueryResult {
|
|||||||
return "InlineQueryResultCachedVideo{" +
|
return "InlineQueryResultCachedVideo{" +
|
||||||
"type='" + type + '\'' +
|
"type='" + type + '\'' +
|
||||||
", id='" + id + '\'' +
|
", id='" + id + '\'' +
|
||||||
", caption='" + caption + '\'' +
|
|
||||||
", videoFileId='" + videoFileId + '\'' +
|
", videoFileId='" + videoFileId + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", description='" + description + '\'' +
|
", description='" + description + '\'' +
|
||||||
", inputMessageContent='" + inputMessageContent + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
", replyMarkup='" + replyMarkup + '\'' +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
|
", replyMarkup=" + replyMarkup +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,13 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
* 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.
|
* 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
|
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
|
||||||
* ignore them.
|
* ignore them.
|
||||||
* @date 10 of April of 2016
|
|
||||||
*/
|
*/
|
||||||
public class InlineQueryResultCachedVoice implements InlineQueryResult {
|
public class InlineQueryResultCachedVoice implements InlineQueryResult {
|
||||||
|
|
||||||
private static final String TYPE_FIELD = "type";
|
private static final String TYPE_FIELD = "type";
|
||||||
private static final String ID_FIELD = "id";
|
private static final String ID_FIELD = "id";
|
||||||
private static final String VOICE_FILE_ID_FIELD = "voice_file_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 INPUTMESSAGECONTENT_FIELD = "input_message_content";
|
||||||
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
private static final String REPLY_MARKUP_FIELD = "reply_markup";
|
||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(TYPE_FIELD)
|
@JsonProperty(TYPE_FIELD)
|
||||||
private final String type = "voice"; ///< Type of the result, must be "voice"
|
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
|
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
|
||||||
@JsonProperty(CAPTION_FIELD)
|
@JsonProperty(CAPTION_FIELD)
|
||||||
private String caption; ///< Optional. Voice caption (may also be used when resending documents by file_id), 0-200 characters
|
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() {
|
public InlineQueryResultCachedVoice() {
|
||||||
super();
|
super();
|
||||||
@ -104,6 +105,15 @@ public class InlineQueryResultCachedVoice implements InlineQueryResult {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineQueryResultCachedVoice setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (id == null || id.isEmpty()) {
|
if (id == null || id.isEmpty()) {
|
||||||
@ -123,12 +133,14 @@ public class InlineQueryResultCachedVoice implements InlineQueryResult {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InlineQueryResultCachedVoice{" +
|
return "InlineQueryResultCachedVoice{" +
|
||||||
"id='" + id + '\'' +
|
"type='" + type + '\'' +
|
||||||
|
", id='" + id + '\'' +
|
||||||
", voiceFileId='" + voiceFileId + '\'' +
|
", voiceFileId='" + voiceFileId + '\'' +
|
||||||
", title='" + title + '\'' +
|
", title='" + title + '\'' +
|
||||||
", inputMessageContent=" + inputMessageContent +
|
", inputMessageContent=" + inputMessageContent +
|
||||||
", replyMarkup=" + replyMarkup +
|
", replyMarkup=" + replyMarkup +
|
||||||
", caption='" + caption + '\'' +
|
", caption='" + caption + '\'' +
|
||||||
|
", parseMode='" + parseMode + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public abstract class InputMedia<T> implements InputBotApiObject, Validable {
|
|||||||
protected static final String TYPE_FIELD = "type";
|
protected static final String TYPE_FIELD = "type";
|
||||||
private static final String MEDIA_FIELD = "media";
|
private static final String MEDIA_FIELD = "media";
|
||||||
private static final String CAPTION_FIELD = "caption";
|
private static final String CAPTION_FIELD = "caption";
|
||||||
|
private static final String PARSEMODE_FIELD = "parse_mode";
|
||||||
|
|
||||||
@JsonProperty(MEDIA_FIELD)
|
@JsonProperty(MEDIA_FIELD)
|
||||||
/**
|
/**
|
||||||
@ -27,7 +28,8 @@ public abstract class InputMedia<T> implements InputBotApiObject, Validable {
|
|||||||
private String media;
|
private String media;
|
||||||
@JsonProperty(CAPTION_FIELD)
|
@JsonProperty(CAPTION_FIELD)
|
||||||
private String caption; ///< Optional. Caption of the media to be sent, 0-200 characters
|
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
|
@JsonIgnore
|
||||||
private boolean isNewMedia; ///< True to upload a new media, false to use a fileId or URL
|
private boolean isNewMedia; ///< True to upload a new media, false to use a fileId or URL
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ -113,6 +115,15 @@ public abstract class InputMedia<T> implements InputBotApiObject, Validable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParseMode() {
|
||||||
|
return parseMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputMedia<T> setParseMode(String parseMode) {
|
||||||
|
this.parseMode = parseMode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws TelegramApiValidationException {
|
public void validate() throws TelegramApiValidationException {
|
||||||
if (isNewMedia) {
|
if (isNewMedia) {
|
||||||
|
@ -16,6 +16,7 @@ public class InputMediaVideo extends InputMedia<InputMediaVideo> {
|
|||||||
private static final String WIDTH_FIELD = "width";
|
private static final String WIDTH_FIELD = "width";
|
||||||
private static final String HEIGHT_FIELD = "height";
|
private static final String HEIGHT_FIELD = "height";
|
||||||
private static final String DURATION_FIELD = "duration";
|
private static final String DURATION_FIELD = "duration";
|
||||||
|
private static final String SUPPORTSSTREAMING_FIELD = "supports_streaming";
|
||||||
|
|
||||||
@JsonProperty(WIDTH_FIELD)
|
@JsonProperty(WIDTH_FIELD)
|
||||||
private int width; ///< Optional. Video width
|
private int width; ///< Optional. Video width
|
||||||
@ -23,6 +24,8 @@ public class InputMediaVideo extends InputMedia<InputMediaVideo> {
|
|||||||
private int height; ///< Optional. Video height
|
private int height; ///< Optional. Video height
|
||||||
@JsonProperty(DURATION_FIELD)
|
@JsonProperty(DURATION_FIELD)
|
||||||
private int duration; ///< Optional. Video duration
|
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() {
|
public InputMediaVideo() {
|
||||||
super();
|
super();
|
||||||
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ForceReplyKeyboard{" +
|
return "ForceReplyKeyboard{" +
|
||||||
|
@ -7,6 +7,7 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InlineKeyboardMarkup{" +
|
return "InlineKeyboardMarkup{" +
|
||||||
|
@ -7,6 +7,7 @@ import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ReplyKeyboardMarkup{" +
|
return "ReplyKeyboardMarkup{" +
|
||||||
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ReplyKeyboardRemove{" +
|
return "ReplyKeyboardRemove{" +
|
||||||
|
@ -6,6 +6,8 @@ import org.telegram.telegrambots.api.interfaces.Validable;
|
|||||||
import org.telegram.telegrambots.api.objects.games.CallbackGame;
|
import org.telegram.telegrambots.api.objects.games.CallbackGame;
|
||||||
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "InlineKeyboardButton{" +
|
return "InlineKeyboardButton{" +
|
||||||
|
@ -6,6 +6,8 @@ import org.telegram.telegrambots.api.interfaces.InputBotApiObject;
|
|||||||
import org.telegram.telegrambots.api.interfaces.Validable;
|
import org.telegram.telegrambots.api.interfaces.Validable;
|
||||||
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
import org.telegram.telegrambots.exceptions.TelegramApiValidationException;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "KeyboardButton{" +
|
return "KeyboardButton{" +
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Telegram Bots</name>
|
<name>Telegram Bots</name>
|
||||||
@ -66,7 +66,7 @@
|
|||||||
<jackson.version>2.8.7</jackson.version>
|
<jackson.version>2.8.7</jackson.version>
|
||||||
<jacksonanotation.version>2.8.0</jacksonanotation.version>
|
<jacksonanotation.version>2.8.0</jacksonanotation.version>
|
||||||
<commonio.version>2.5</commonio.version>
|
<commonio.version>2.5</commonio.version>
|
||||||
<bots.version>3.5</bots.version>
|
<bots.version>3.6</bots.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -51,7 +51,7 @@ import static org.telegram.telegrambots.Constants.SOCKET_TIMEOUT;
|
|||||||
public abstract class DefaultAbsSender extends AbsSender {
|
public abstract class DefaultAbsSender extends AbsSender {
|
||||||
private static final ContentType TEXT_PLAIN_CONTENT_TYPE = ContentType.create("text/plain", StandardCharsets.UTF_8);
|
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 ObjectMapper objectMapper = new ObjectMapper();
|
||||||
private final DefaultBotOptions options;
|
private final DefaultBotOptions options;
|
||||||
private volatile CloseableHttpClient httpclient;
|
private volatile CloseableHttpClient httpclient;
|
||||||
@ -157,6 +157,9 @@ public abstract class DefaultAbsSender extends AbsSender {
|
|||||||
}
|
}
|
||||||
if (sendDocument.getCaption() != null) {
|
if (sendDocument.getCaption() != null) {
|
||||||
builder.addTextBody(SendDocument.CAPTION_FIELD, sendDocument.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
|
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) {
|
if (sendDocument.getDisableNotification() != null) {
|
||||||
builder.addTextBody(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
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) {
|
if (sendPhoto.getCaption() != null) {
|
||||||
builder.addTextBody(SendPhoto.CAPTION_FIELD, sendPhoto.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
|
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) {
|
if (sendPhoto.getDisableNotification() != null) {
|
||||||
builder.addTextBody(SendPhoto.DISABLENOTIFICATION_FIELD, sendPhoto.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
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) {
|
if (sendVideo.getCaption() != null) {
|
||||||
builder.addTextBody(SendVideo.CAPTION_FIELD, sendVideo.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
|
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) {
|
if (sendVideo.getDuration() != null) {
|
||||||
builder.addTextBody(SendVideo.DURATION_FIELD, sendVideo.getDuration().toString(), TEXT_PLAIN_CONTENT_TYPE);
|
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) {
|
if (sendAudio.getCaption() != null) {
|
||||||
builder.addTextBody(SendAudio.CAPTION_FIELD, sendAudio.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
|
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();
|
HttpEntity multipart = builder.build();
|
||||||
httppost.setEntity(multipart);
|
httppost.setEntity(multipart);
|
||||||
@ -462,6 +477,9 @@ public abstract class DefaultAbsSender extends AbsSender {
|
|||||||
}
|
}
|
||||||
if (sendVoice.getCaption() != null) {
|
if (sendVoice.getCaption() != null) {
|
||||||
builder.addTextBody(SendVoice.CAPTION_FIELD, sendVoice.getCaption(), TEXT_PLAIN_CONTENT_TYPE);
|
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();
|
HttpEntity multipart = builder.build();
|
||||||
httppost.setEntity(multipart);
|
httppost.setEntity(multipart);
|
||||||
|
@ -55,4 +55,10 @@ public abstract class TelegramLongPollingBot extends DefaultAbsSender implements
|
|||||||
throw new TelegramApiRequestException("Error executing setWebook method", e);
|
throw new TelegramApiRequestException("Error executing setWebook method", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClosing() {
|
||||||
|
exe.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class DefaultBotSession implements BotSession {
|
|||||||
|
|
||||||
lastReceivedUpdate = 0;
|
lastReceivedUpdate = 0;
|
||||||
|
|
||||||
readerThread = new ReaderThread(updatesSupplier);
|
readerThread = new ReaderThread(updatesSupplier, this);
|
||||||
readerThread.setName(callback.getBotUsername() + " Telegram Connection");
|
readerThread.setName(callback.getBotUsername() + " Telegram Connection");
|
||||||
readerThread.start();
|
readerThread.start();
|
||||||
|
|
||||||
@ -135,12 +135,14 @@ public class DefaultBotSession implements BotSession {
|
|||||||
private class ReaderThread extends Thread implements UpdatesReader {
|
private class ReaderThread extends Thread implements UpdatesReader {
|
||||||
|
|
||||||
private final UpdatesSupplier updatesSupplier;
|
private final UpdatesSupplier updatesSupplier;
|
||||||
|
private final Object lock;
|
||||||
private CloseableHttpClient httpclient;
|
private CloseableHttpClient httpclient;
|
||||||
private ExponentialBackOff exponentialBackOff;
|
private ExponentialBackOff exponentialBackOff;
|
||||||
private RequestConfig requestConfig;
|
private RequestConfig requestConfig;
|
||||||
|
|
||||||
public ReaderThread(UpdatesSupplier updatesSupplier) {
|
public ReaderThread(UpdatesSupplier updatesSupplier, Object lock) {
|
||||||
this.updatesSupplier = Optional.ofNullable(updatesSupplier).orElse(this::getUpdatesFromServer);
|
this.updatesSupplier = Optional.ofNullable(updatesSupplier).orElse(this::getUpdatesFromServer);
|
||||||
|
this.lock = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -183,48 +185,52 @@ public class DefaultBotSession implements BotSession {
|
|||||||
public void run() {
|
public void run() {
|
||||||
setPriority(Thread.MIN_PRIORITY);
|
setPriority(Thread.MIN_PRIORITY);
|
||||||
while (running) {
|
while (running) {
|
||||||
try {
|
synchronized (lock) {
|
||||||
List<Update> updates = updatesSupplier.getUpdates();
|
if (running) {
|
||||||
if (updates.isEmpty()) {
|
try {
|
||||||
synchronized (this) {
|
List<Update> updates = updatesSupplier.getUpdates();
|
||||||
this.wait(500);
|
if (updates.isEmpty()) {
|
||||||
}
|
lock.wait(500);
|
||||||
} else {
|
} else {
|
||||||
updates.removeIf(x -> x.getUpdateId() < lastReceivedUpdate);
|
updates.removeIf(x -> x.getUpdateId() < lastReceivedUpdate);
|
||||||
lastReceivedUpdate = updates.parallelStream()
|
lastReceivedUpdate = updates.parallelStream()
|
||||||
.map(
|
.map(
|
||||||
Update::getUpdateId)
|
Update::getUpdateId)
|
||||||
.max(Integer::compareTo)
|
.max(Integer::compareTo)
|
||||||
.orElse(0);
|
.orElse(0);
|
||||||
receivedUpdates.addAll(updates);
|
receivedUpdates.addAll(updates);
|
||||||
|
|
||||||
synchronized (receivedUpdates) {
|
synchronized (receivedUpdates) {
|
||||||
receivedUpdates.notifyAll();
|
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");
|
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()
|
GetUpdates request = new GetUpdates()
|
||||||
.setLimit(100)
|
.setLimit(100)
|
||||||
.setTimeout(ApiConstants.GETUPDATES_TIMEOUT)
|
.setTimeout(ApiConstants.GETUPDATES_TIMEOUT)
|
||||||
@ -248,8 +254,8 @@ public class DefaultBotSession implements BotSession {
|
|||||||
|
|
||||||
if (response.getStatusLine().getStatusCode() >= 500) {
|
if (response.getStatusLine().getStatusCode() >= 500) {
|
||||||
BotLogger.warn(LOGTAG, responseContent);
|
BotLogger.warn(LOGTAG, responseContent);
|
||||||
synchronized (this) {
|
synchronized (lock) {
|
||||||
this.wait(500);
|
lock.wait(500);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -260,14 +266,13 @@ public class DefaultBotSession implements BotSession {
|
|||||||
BotLogger.severe(responseContent, LOGTAG, e);
|
BotLogger.severe(responseContent, LOGTAG, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SocketException e) {
|
} catch (SocketException | InvalidObjectException | TelegramApiRequestException e) {
|
||||||
if (!e.getMessage().equals("Socket Closed")) {
|
BotLogger.severe(LOGTAG, e);
|
||||||
BotLogger.severe(LOGTAG, e);
|
|
||||||
}
|
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
BotLogger.fine(LOGTAG, e);
|
BotLogger.fine(LOGTAG, e);
|
||||||
} catch (InvalidObjectException | TelegramApiRequestException e) {
|
} catch (InterruptedException e) {
|
||||||
BotLogger.severe(LOGTAG, e);
|
BotLogger.fine(LOGTAG, e);
|
||||||
|
interrupt();
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -275,7 +280,7 @@ public class DefaultBotSession implements BotSession {
|
|||||||
|
|
||||||
public interface UpdatesSupplier {
|
public interface UpdatesSupplier {
|
||||||
|
|
||||||
List<Update> getUpdates() throws InterruptedException, Exception;
|
List<Update> getUpdates() throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Update> getUpdateList() {
|
private List<Update> getUpdateList() {
|
||||||
@ -306,6 +311,7 @@ public class DefaultBotSession implements BotSession {
|
|||||||
callback.onUpdatesReceived(updates);
|
callback.onUpdatesReceived(updates);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
BotLogger.debug(LOGTAG, e);
|
BotLogger.debug(LOGTAG, e);
|
||||||
|
interrupt();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BotLogger.severe(LOGTAG, e);
|
BotLogger.severe(LOGTAG, e);
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,17 @@ package org.telegram.telegrambots.test;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.telegram.telegrambots.api.objects.Update;
|
import org.telegram.telegrambots.api.objects.Update;
|
||||||
|
import org.telegram.telegrambots.bots.DefaultBotOptions;
|
||||||
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
|
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
|
||||||
|
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
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.any;
|
||||||
import static org.mockito.Matchers.anyList;
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class TelegramLongPollingBotTest {
|
public class TelegramLongPollingBotTest {
|
||||||
|
|
||||||
@ -21,4 +27,41 @@ public class TelegramLongPollingBotTest {
|
|||||||
Mockito.verify(bot).onUpdateReceived(update1);
|
Mockito.verify(bot).onUpdateReceived(update1);
|
||||||
Mockito.verify(bot).onUpdateReceived(update2);
|
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 "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user