Merge pull request #25 from rubenlagus/dev

Bots API 2.0
This commit is contained in:
Ruben Bermudez 2016-04-12 04:28:28 +02:00
commit c25367e2d6
106 changed files with 5901 additions and 854 deletions

View File

@ -24,9 +24,17 @@
<processorPath useClasspath="true" /> <processorPath useClasspath="true" />
<module name="BotAPi" /> <module name="BotAPi" />
</profile> </profile>
<profile default="false" name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="TelegramBots" />
</profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel target="1.8"> <bytecodeTargetLevel target="1.8">
<module name="BotAPi" target="1.8" /> <module name="BotAPi" target="1.8" />
<module name="TelegramBots" target="1.8" />
</bytecodeTargetLevel> </bytecodeTargetLevel>
</component> </component>
</project> </project>

View File

@ -35,7 +35,7 @@
<option name="IGNORE_JAVADOC_PERIOD" value="true" /> <option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" /> <option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" /> <option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date,brief" /> <option name="myAdditionalJavadocTags" value="date,brief,note" />
</inspection_tool> </inspection_tool>
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false"> <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" /> <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: com.sun.jersey:jersey-core:1.19"> <library name="Maven: com.sun.jersey:jersey-bundle:1.19.1">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-core/1.19/jersey-core-1.19.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-bundle/1.19.1/jersey-bundle-1.19.1.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-core/1.19/jersey-core-1.19-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-bundle/1.19.1/jersey-bundle-1.19.1-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-core/1.19/jersey-core-1.19-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-bundle/1.19.1/jersey-bundle-1.19.1-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: com.sun.jersey:jersey-bundle:1.19"> <library name="Maven: com.sun.jersey:jersey-core:1.19.1">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-bundle/1.19/jersey-bundle-1.19.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-bundle/1.19/jersey-bundle-1.19-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-bundle/1.19/jersey-bundle-1.19-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.sun.jersey:jersey-grizzly2:1.19.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2/1.19.1/jersey-grizzly2-1.19.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2/1.19.1/jersey-grizzly2-1.19.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2/1.19.1/jersey-grizzly2-1.19.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: com.sun.jersey:jersey-grizzly2-servlet:1.19"> <library name="Maven: com.sun.jersey:jersey-grizzly2-servlet:1.19.1">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2-servlet/1.19/jersey-grizzly2-servlet-1.19.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2-servlet/1.19.1/jersey-grizzly2-servlet-1.19.1.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2-servlet/1.19/jersey-grizzly2-servlet-1.19-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2-servlet/1.19.1/jersey-grizzly2-servlet-1.19.1-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2-servlet/1.19/jersey-grizzly2-servlet-1.19-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2-servlet/1.19.1/jersey-grizzly2-servlet-1.19.1-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: com.sun.jersey:jersey-grizzly2:1.19"> <library name="Maven: com.sun.jersey:jersey-server:1.19.1">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2/1.19/jersey-grizzly2-1.19.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-server/1.19.1/jersey-server-1.19.1.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2/1.19/jersey-grizzly2-1.19-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-server/1.19.1/jersey-server-1.19.1-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-grizzly2/1.19/jersey-grizzly2-1.19-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-server/1.19.1/jersey-server-1.19.1-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: com.sun.jersey:jersey-servlet:1.19">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-servlet/1.19/jersey-servlet-1.19.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-servlet/1.19/jersey-servlet-1.19-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-servlet/1.19/jersey-servlet-1.19-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: com.sun.jersey:jersey-server:1.19"> <library name="Maven: com.sun.jersey:jersey-servlet:1.19.1">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-server/1.19/jersey-server-1.19.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-servlet/1.19.1/jersey-servlet-1.19.1.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-server/1.19/jersey-server-1.19-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-servlet/1.19.1/jersey-servlet-1.19.1-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-server/1.19/jersey-server-1.19-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/com/sun/jersey/jersey-servlet/1.19.1/jersey-servlet-1.19.1-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b31"> <library name="Maven: org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/aopalliance-repackaged/2.4.0-b31/aopalliance-repackaged-2.4.0-b31.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/aopalliance-repackaged/2.4.0-b34/aopalliance-repackaged-2.4.0-b34.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/aopalliance-repackaged/2.4.0-b31/aopalliance-repackaged-2.4.0-b31-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/aopalliance-repackaged/2.4.0-b34/aopalliance-repackaged-2.4.0-b34-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/aopalliance-repackaged/2.4.0-b31/aopalliance-repackaged-2.4.0-b31-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/aopalliance-repackaged/2.4.0-b34/aopalliance-repackaged-2.4.0-b34-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.hk2.external:javax.inject:2.4.0-b31"> <library name="Maven: org.glassfish.hk2.external:javax.inject:2.4.0-b34">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/javax.inject/2.4.0-b31/javax.inject-2.4.0-b31.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/javax.inject/2.4.0-b34/javax.inject-2.4.0-b34.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/javax.inject/2.4.0-b31/javax.inject-2.4.0-b31-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/javax.inject/2.4.0-b34/javax.inject-2.4.0-b34-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/javax.inject/2.4.0-b31/javax.inject-2.4.0-b31-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/external/javax.inject/2.4.0-b34/javax.inject-2.4.0-b34-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.hk2:hk2-api:2.4.0-b31"> <library name="Maven: org.glassfish.hk2:hk2-api:2.4.0-b34">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-api/2.4.0-b31/hk2-api-2.4.0-b31.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-api/2.4.0-b34/hk2-api-2.4.0-b34.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-api/2.4.0-b31/hk2-api-2.4.0-b31-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-api/2.4.0-b34/hk2-api-2.4.0-b34-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-api/2.4.0-b31/hk2-api-2.4.0-b31-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-api/2.4.0-b34/hk2-api-2.4.0-b34-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.hk2:hk2-locator:2.4.0-b31"> <library name="Maven: org.glassfish.hk2:hk2-locator:2.4.0-b34">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-locator/2.4.0-b31/hk2-locator-2.4.0-b31.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-locator/2.4.0-b34/hk2-locator-2.4.0-b34.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-locator/2.4.0-b31/hk2-locator-2.4.0-b31-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-locator/2.4.0-b34/hk2-locator-2.4.0-b34-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-locator/2.4.0-b31/hk2-locator-2.4.0-b31-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-locator/2.4.0-b34/hk2-locator-2.4.0-b34-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.hk2:hk2-utils:2.4.0-b31"> <library name="Maven: org.glassfish.hk2:hk2-utils:2.4.0-b34">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-utils/2.4.0-b31/hk2-utils-2.4.0-b31.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-utils/2.4.0-b34/hk2-utils-2.4.0-b34.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-utils/2.4.0-b31/hk2-utils-2.4.0-b31-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-utils/2.4.0-b34/hk2-utils-2.4.0-b34-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-utils/2.4.0-b31/hk2-utils-2.4.0-b31-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-utils/2.4.0-b34/hk2-utils-2.4.0-b34-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.1"> <library name="Maven: org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/bundles/repackaged/jersey-guava/2.22.1/jersey-guava-2.22.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/bundles/repackaged/jersey-guava/2.22.2/jersey-guava-2.22.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/bundles/repackaged/jersey-guava/2.22.1/jersey-guava-2.22.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/bundles/repackaged/jersey-guava/2.22.2/jersey-guava-2.22.2-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/bundles/repackaged/jersey-guava/2.22.1/jersey-guava-2.22.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/bundles/repackaged/jersey-guava/2.22.2/jersey-guava-2.22.2-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.1"> <library name="Maven: org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/containers/jersey-container-grizzly2-http/2.22.1/jersey-container-grizzly2-http-2.22.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/containers/jersey-container-grizzly2-http/2.22.2/jersey-container-grizzly2-http-2.22.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/containers/jersey-container-grizzly2-http/2.22.1/jersey-container-grizzly2-http-2.22.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/containers/jersey-container-grizzly2-http/2.22.2/jersey-container-grizzly2-http-2.22.2-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/containers/jersey-container-grizzly2-http/2.22.1/jersey-container-grizzly2-http-2.22.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/containers/jersey-container-grizzly2-http/2.22.2/jersey-container-grizzly2-http-2.22.2-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.jersey.core:jersey-client:2.22.1"> <library name="Maven: org.glassfish.jersey.core:jersey-client:2.22.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-client/2.22.1/jersey-client-2.22.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-client/2.22.2/jersey-client-2.22.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-client/2.22.1/jersey-client-2.22.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-client/2.22.2/jersey-client-2.22.2-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-client/2.22.1/jersey-client-2.22.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-client/2.22.2/jersey-client-2.22.2-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.jersey.core:jersey-common:2.22.1"> <library name="Maven: org.glassfish.jersey.core:jersey-common:2.22.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-common/2.22.1/jersey-common-2.22.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-common/2.22.2/jersey-common-2.22.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-common/2.22.1/jersey-common-2.22.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-common/2.22.2/jersey-common-2.22.2-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-common/2.22.1/jersey-common-2.22.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-common/2.22.2/jersey-common-2.22.2-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.jersey.core:jersey-server:2.22.1"> <library name="Maven: org.glassfish.jersey.core:jersey-server:2.22.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-server/2.22.1/jersey-server-2.22.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-server/2.22.2/jersey-server-2.22.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-server/2.22.1/jersey-server-2.22.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-server/2.22.2/jersey-server-2.22.2-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-server/2.22.1/jersey-server-2.22.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-server/2.22.2/jersey-server-2.22.2-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.jersey.ext:jersey-entity-filtering:2.22.1"> <library name="Maven: org.glassfish.jersey.ext:jersey-entity-filtering:2.22.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/ext/jersey-entity-filtering/2.22.1/jersey-entity-filtering-2.22.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/ext/jersey-entity-filtering/2.22.2/jersey-entity-filtering-2.22.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/ext/jersey-entity-filtering/2.22.1/jersey-entity-filtering-2.22.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/ext/jersey-entity-filtering/2.22.2/jersey-entity-filtering-2.22.2-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/ext/jersey-entity-filtering/2.22.1/jersey-entity-filtering-2.22.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/ext/jersey-entity-filtering/2.22.2/jersey-entity-filtering-2.22.2-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.jersey.media:jersey-media-jaxb:2.22.1"> <library name="Maven: org.glassfish.jersey.media:jersey-media-jaxb:2.22.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-jaxb/2.22.1/jersey-media-jaxb-2.22.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-jaxb/2.22.2/jersey-media-jaxb-2.22.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-jaxb/2.22.1/jersey-media-jaxb-2.22.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-jaxb/2.22.2/jersey-media-jaxb-2.22.2-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-jaxb/2.22.1/jersey-media-jaxb-2.22.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-jaxb/2.22.2/jersey-media-jaxb-2.22.2-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: org.glassfish.jersey.media:jersey-media-json-jackson:2.22.1"> <library name="Maven: org.glassfish.jersey.media:jersey-media-json-jackson:2.22.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-json-jackson/2.22.1/jersey-media-json-jackson-2.22.1.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-json-jackson/2.22.2/jersey-media-json-jackson-2.22.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-json-jackson/2.22.1/jersey-media-json-jackson-2.22.1-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-json-jackson/2.22.2/jersey-media-json-jackson-2.22.2-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-json-jackson/2.22.1/jersey-media-json-jackson-2.22.1-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-json-jackson/2.22.2/jersey-media-json-jackson-2.22.2-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: org.json:json:20151123">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20151123/json-20151123.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20151123/json-20151123-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20151123/json-20151123-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.json:json:20160212">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20160212/json-20160212.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20160212/json-20160212-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20160212/json-20160212-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -11,43 +11,43 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.2" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2.external:javax.inject:2.4.0-b31" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.hk2.external:javax.inject:2.4.0-b34" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-http-server:2.3.23" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-http-server:2.3.23" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-http:2.3.23" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-http:2.3.23" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-framework:2.3.23" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-framework:2.3.23" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-common:2.22.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-common:2.22.2" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.2" level="project" /> <orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.2" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.jersey.bundles.repackaged:jersey-guava:2.22.2" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-api:2.4.0-b31" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-api:2.4.0-b34" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-utils:2.4.0-b31" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-utils:2.4.0-b34" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b31" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.hk2.external:aopalliance-repackaged:2.4.0-b34" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-locator:2.4.0-b31" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-locator:2.4.0-b34" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.18.1-GA" level="project" /> <orderEntry type="library" name="Maven: org.javassist:javassist:3.18.1-GA" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2:osgi-resource-locator:1.0.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.hk2:osgi-resource-locator:1.0.1" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-server:2.22.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-server:2.22.2" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-client:2.22.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-client:2.22.2" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-jaxb:2.22.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-jaxb:2.22.2" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" /> <orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: javax.ws.rs:javax.ws.rs-api:2.0.1" level="project" /> <orderEntry type="library" name="Maven: javax.ws.rs:javax.ws.rs-api:2.0.1" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-json-jackson:2.22.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-json-jackson:2.22.2" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.ext:jersey-entity-filtering:2.22.1" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.jersey.ext:jersey-entity-filtering:2.22.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.5.4" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.5.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.5.4" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.5.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.5.4" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.5.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.5.4" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.5.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.5.4" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.5.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.5.4" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.5.4" level="project" />
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-bundle:1.19" level="project" /> <orderEntry type="library" name="Maven: com.sun.jersey:jersey-bundle:1.19.1" level="project" />
<orderEntry type="library" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" /> <orderEntry type="library" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" />
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-grizzly2-servlet:1.19" level="project" /> <orderEntry type="library" name="Maven: com.sun.jersey:jersey-grizzly2-servlet:1.19.1" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-http-servlet:2.2.16" level="project" /> <orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-http-servlet:2.2.16" level="project" />
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-grizzly2:1.19" level="project" /> <orderEntry type="library" name="Maven: com.sun.jersey:jersey-grizzly2:1.19.1" level="project" />
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-server:1.19" level="project" /> <orderEntry type="library" name="Maven: com.sun.jersey:jersey-server:1.19.1" level="project" />
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-core:1.19" level="project" /> <orderEntry type="library" name="Maven: com.sun.jersey:jersey-core:1.19.1" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.0.1" level="project" /> <orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.0.1" level="project" />
<orderEntry type="library" name="Maven: com.sun.jersey:jersey-servlet:1.19" level="project" /> <orderEntry type="library" name="Maven: com.sun.jersey:jersey-servlet:1.19.1" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20151123" level="project" /> <orderEntry type="library" name="Maven: org.json:json:20160212" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" /> <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" /> <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" /> <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />

12
pom.xml
View File

@ -6,7 +6,7 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<groupId>org.telegram</groupId> <groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId> <artifactId>telegrambots</artifactId>
<version>1.1</version> <version>2.0</version>
<name>Telegram Bots</name> <name>Telegram Bots</name>
<description>Easy to use library to create Telegram Bots</description> <description>Easy to use library to create Telegram Bots</description>
@ -21,8 +21,10 @@
<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>
<jersey.version>2.22.1</jersey.version> <jersey.version>2.22.2</jersey.version>
<jerseybundle.version>1.19.1</jerseybundle.version>
<httpcompontents.version>4.5.2</httpcompontents.version> <httpcompontents.version>4.5.2</httpcompontents.version>
<json.version>20160212</json.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
@ -50,17 +52,17 @@
<dependency> <dependency>
<groupId>com.sun.jersey</groupId> <groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId> <artifactId>jersey-bundle</artifactId>
<version>1.19</version> <version>${jerseybundle.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.jersey</groupId> <groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2-servlet</artifactId> <artifactId>jersey-grizzly2-servlet</artifactId>
<version>1.19</version> <version>${jerseybundle.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20151123</version> <version>${json.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>

View File

@ -3,7 +3,7 @@ package org.telegram.telegrambots;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief TODO * @brief Exception thrown when something goes wrong in the api
* @date 14 of January of 2016 * @date 14 of January of 2016
*/ */
public class TelegramApiException extends Exception { public class TelegramApiException extends Exception {

View File

@ -13,7 +13,7 @@ import org.apache.http.util.EntityUtils;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.Constants; import org.telegram.telegrambots.api.Constants;
import org.telegram.telegrambots.api.methods.SetWebhook; import org.telegram.telegrambots.api.methods.updates.SetWebhook;
import org.telegram.telegrambots.bots.TelegramLongPollingBot; import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.bots.TelegramWebhookBot; import org.telegram.telegrambots.bots.TelegramWebhookBot;
import org.telegram.telegrambots.updatesreceivers.UpdatesThread; import org.telegram.telegrambots.updatesreceivers.UpdatesThread;
@ -25,7 +25,7 @@ import java.io.IOException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief TODO * @brief Bots manager
* @date 14 of January of 2016 * @date 14 of January of 2016
*/ */
public class TelegramBotsApi { public class TelegramBotsApi {

View File

@ -3,10 +3,9 @@ package org.telegram.telegrambots.api;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief TODO * @brief Constants needed for Telegram Bots API
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class Constants { public class Constants {
public static final String BASEURL = "https://api.telegram.org/bot"; public static final String BASEURL = "https://api.telegram.org/bot";
public static final int SOCKET_TIMEOUT = 30 * 1000;
} }

View File

@ -0,0 +1,89 @@
package org.telegram.telegrambots.api.methods;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to send answers to callback queries sent from inline keyboards. The answer
* will be displayed to the user as a notification at the top of the chat screen or as an alert. On
* success, True is returned.
* @date 10 of April of 2016
*/
public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
public static final String PATH = "answercallbackquery";
private static final String CALLBACKQUERYID_FIELD = "callback_query_id";
private static final String TEXT_FIELD = "text";
private static final String SHOWALERT_FIELD = "show_alert";
private String callbackQueryId; ///< Unique identifier for the query to be answered
private String text; ///< Text of the notification. If not specified, nothing will be shown to the user
private Boolean showAlert; ///< Optional. If true, an alert will be shown by the client instead of a notificaiton at the top of the chat screen. Defaults to false.
public AnswerCallbackQuery() {
super();
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CALLBACKQUERYID_FIELD, callbackQueryId);
if (text != null) {
jsonObject.put(TEXT_FIELD, text);
}
if (showAlert != null) {
jsonObject.put(SHOWALERT_FIELD, showAlert);
}
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Boolean deserializeResponse(JSONObject answer) {
if (answer.getBoolean("ok")) {
return answer.getBoolean("result");
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CALLBACKQUERYID_FIELD, callbackQueryId);
if (text != null) {
gen.writeStringField(TEXT_FIELD, text);
}
if (showAlert != null) {
gen.writeBooleanField(SHOWALERT_FIELD, showAlert);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "AnswerInlineQuery{" +
"callbackQueryId='" + callbackQueryId + '\'' +
", text=" + text +
", showAlert=" + showAlert + '\'' +
'}';
}
}

View File

@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.InlineQueryResult; import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -20,16 +20,20 @@ import java.util.List;
public class AnswerInlineQuery extends BotApiMethod<Boolean> { public class AnswerInlineQuery extends BotApiMethod<Boolean> {
public static final String PATH = "answerInlineQuery"; public static final String PATH = "answerInlineQuery";
public static final String INLINEQUERYID_FIELD = "inline_query_id"; private static final String INLINEQUERYID_FIELD = "inline_query_id";
public static final String RESULTS_FIELD = "results"; private static final String RESULTS_FIELD = "results";
public static final String CACHETIME_FIELD = "cache_time"; private static final String CACHETIME_FIELD = "cache_time";
public static final String ISPERSONAL_FIELD = "is_personal"; private static final String ISPERSONAL_FIELD = "is_personal";
public static final String NEXTOFFSET_FIELD = "next_offset"; private static final String NEXTOFFSET_FIELD = "next_offset";
private static final String SWITCH_PM_TEXT_FIELD = "switch_pm_text";
private static final String SWITCH_PM_PARAMETER_FIELD = "switch_pm_parameter";
private String inlineQueryId; ///< Unique identifier for answered query private String inlineQueryId; ///< Unique identifier for answered query
private List<InlineQueryResult> results; ///< A JSON-serialized array of results for the inline query private List<InlineQueryResult> results; ///< A JSON-serialized array of results for the inline query
private Integer cacheTime; ///< Optional The maximum amount of time the result of the inline query may be cached on the server private Integer cacheTime; ///< Optional The maximum amount of time the result of the inline query may be cached on the server
private Boolean isPersonal; ///< Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query private Boolean isPersonal; ///< Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
private String nextOffset; ///< Optional Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you dont support pagination. Offset length cant exceed 64 bytes. private String nextOffset; ///< Optional. Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you dont support pagination. Offset length cant exceed 64 bytes.
private String switchPmText; ///< Optional. If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
private String switchPmParameter; ///< Optional. Parameter for the start message sent to the bot when user presses the switch button
public AnswerInlineQuery() { public AnswerInlineQuery() {
super(); super();
@ -75,6 +79,22 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
this.nextOffset = nextOffset; this.nextOffset = nextOffset;
} }
public String getSwitchPmText() {
return switchPmText;
}
public void setSwitchPmText(String switchPmText) {
this.switchPmText = switchPmText;
}
public String getSwitchPmParameter() {
return switchPmParameter;
}
public void setSwitchPmParameter(String switchPmParameter) {
this.switchPmParameter = switchPmParameter;
}
@Override @Override
public JSONObject toJson() { public JSONObject toJson() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
@ -93,6 +113,12 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
if (nextOffset != null) { if (nextOffset != null) {
jsonObject.put(NEXTOFFSET_FIELD, nextOffset); jsonObject.put(NEXTOFFSET_FIELD, nextOffset);
} }
if (switchPmText != null) {
jsonObject.put(SWITCH_PM_TEXT_FIELD, switchPmText);
}
if (switchPmParameter != null) {
jsonObject.put(SWITCH_PM_PARAMETER_FIELD, switchPmParameter);
}
return jsonObject; return jsonObject;
} }
@ -127,6 +153,12 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
if (nextOffset != null) { if (nextOffset != null) {
gen.writeStringField(NEXTOFFSET_FIELD, nextOffset); gen.writeStringField(NEXTOFFSET_FIELD, nextOffset);
} }
if (switchPmText != null) {
gen.writeStringField(SWITCH_PM_TEXT_FIELD, switchPmText);
}
if (switchPmParameter != null) {
gen.writeStringField(SWITCH_PM_PARAMETER_FIELD, switchPmParameter);
}
gen.writeEndObject(); gen.writeEndObject();
gen.flush(); gen.flush();
@ -144,6 +176,8 @@ public class AnswerInlineQuery extends BotApiMethod<Boolean> {
", results=" + results + ", results=" + results +
", cacheTime=" + cacheTime + ", cacheTime=" + cacheTime +
", isPersonal=" + isPersonal + ", isPersonal=" + isPersonal +
", switchPmText=" + switchPmText +
", switchPmParameter=" + switchPmParameter +
", nextOffset='" + nextOffset + '\'' + ", nextOffset='" + nextOffset + '\'' +
'}'; '}';
} }

View File

@ -18,9 +18,9 @@ import java.io.IOException;
public class GetUserProfilePhotos extends BotApiMethod<UserProfilePhotos> { public class GetUserProfilePhotos extends BotApiMethod<UserProfilePhotos> {
public static final String PATH = "getuserprofilephotos"; public static final String PATH = "getuserprofilephotos";
public static final String USERID_FIELD = "user_id"; private static final String USERID_FIELD = "user_id";
public static final String OFFSET_FIELD = "offset"; private static final String OFFSET_FIELD = "offset";
public static final String LIMIT_FIELD = "limit"; private static final String LIMIT_FIELD = "limit";
private Integer userId; ///< Unique identifier of the target user private Integer userId; ///< Unique identifier of the target user
/** /**
* Sequential number of the first photo to be returned. By default, all photos are returned. * Sequential number of the first photo to be returned. By default, all photos are returned.

View File

@ -0,0 +1,12 @@
package org.telegram.telegrambots.api.methods;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Type of parse modes for text in messages
* @date 10 of April of 2016
*/
public class ParseMode {
public static final String MARKDOWN = "Markdown";
public static final String HTML = "html";
}

View File

@ -0,0 +1,95 @@
package org.telegram.telegrambots.api.methods.groupadministration;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to kick a user from a group or a supergroup. In the case of supergroups,
* the user will not be able to return to the group on their own using invite links, etc., unless
* unbanned first. The bot must be an administrator in the group for this to work. Returns True on
* success.
* @note This will method only work if the All Members Are Admins setting is off in the target
* group. Otherwise members may only be removed by the group's creator or by the member that added
* them.
* @date 10 of April of 2016
*/
public class KickChatMember extends BotApiMethod<Boolean> {
public static final String PATH = "kickchatmember";
private static final String CHATID_FIELD = "chat_id";
private static final String USER_ID_FIELD = "user_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
private Integer userId; ///< Unique identifier of the target user
public KickChatMember() {
super();
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
jsonObject.put(USER_ID_FIELD, userId);
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Boolean deserializeResponse(JSONObject answer) {
if (answer.getBoolean("ok")) {
return answer.getBoolean("result");
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeNumberField(USER_ID_FIELD, userId);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "SendMessage{" +
"chatId='" + chatId + '\'' +
", userId='" + userId +
'}';
}
}

View File

@ -0,0 +1,91 @@
package org.telegram.telegrambots.api.methods.groupadministration;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to unban a previously kicked user in a supergroup. The user will not
* return to the group automatically, but will be able to join via link, etc. The bot must be an
* administrator in the group for this to work. Returns True on success.
* @date 10 of April of 2016
*/
public class UnbanChatMember extends BotApiMethod<Boolean> {
public static final String PATH = "unbanchatmember";
private static final String CHATID_FIELD = "chat_id";
private static final String USER_ID_FIELD = "user_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
private Integer userId; ///< Unique identifier of the target user
public UnbanChatMember() {
super();
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
jsonObject.put(USER_ID_FIELD, userId);
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Boolean deserializeResponse(JSONObject answer) {
if (answer.getBoolean("ok")) {
return answer.getBoolean("result");
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeNumberField(USER_ID_FIELD, userId);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "SendMessage{" +
"chatId='" + chatId + '\'' +
", userId='" + userId +
'}';
}
}

View File

@ -1,17 +1,15 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import org.telegram.telegrambots.api.objects.ReplyKeyboard; import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief Use this method to send audio files, * @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, if you want Telegram clients to display them in the music player. * Telegram clients to display them in the music player. Your audio must be in an .mp3 format. On
* Your audio must be in an .mp3 format. On success, the sent Message is returned. * success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in
* 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 * @date 16 of July of 2015
*/ */
public class SendAudio { public class SendAudio {
@ -25,15 +23,14 @@ public class SendAudio {
public static final String REPLYMARKUP_FIELD = "reply_markup"; public static final String REPLYMARKUP_FIELD = "reply_markup";
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";
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)
private String audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers private String audio; ///< Audio file to send. file_id as String to resend an audio that is already on the Telegram servers
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
/** /**
* Optional. Sends the message silently. * Optional. Sends the message silently. iOS users will not receive a notification, Android
* iOS users will not receive a notification, * users will receive a notification with no sound. Other apps coming soon
* Android users will receive a notification with no sound.
* Other apps coming soon
*/ */
private Boolean disableNotification; private Boolean disableNotification;
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
@ -68,8 +65,8 @@ public class SendAudio {
/** /**
* Use this method to set the audio to an audio existing in Telegram system * Use this method to set the audio to an audio existing in Telegram system
* @param audio File_id of the audio to send
* *
* @param audio File_id of the audio to send
* @note The file_id must have already been received or sent by your bot * @note The file_id must have already been received or sent by your bot
*/ */
public void setAudio(String audio) { public void setAudio(String audio) {
@ -79,6 +76,7 @@ public class SendAudio {
/** /**
* Use this method to set the audio to a new file * Use this method to set the audio to a new file
*
* @param audio Path to the new file in your server * @param audio Path to the new file in your server
* @param audioName Name of the file itself * @param audioName Name of the file itself
*/ */

View File

@ -1,19 +1,20 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import java.io.IOException; import java.io.IOException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief Use this method when you need to tell the user that something is happening on the bot's side. * @brief Use this method when you need to tell the user that something is happening on the bot's
* The status is set for 5 seconds or less (when a message arrives from your bot, * side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram
* Telegram clients clear its typing status). * clients clear its typing status).
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class SendChatAction extends BotApiMethod<Boolean> { public class SendChatAction extends BotApiMethod<Boolean> {
@ -24,13 +25,9 @@ public class SendChatAction extends BotApiMethod<Boolean>{
public static final String ACTION_FIELD = "action"; public static final String ACTION_FIELD = "action";
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)
/** /**
* Type of action to broadcast. * Type of action to broadcast. Choose one, depending on what the user is about to receive:
* Choose one, depending on what the user is about to receive: * 'typing' for text messages 'upload_photo' for photos 'record_video' or 'upload_video' for
* 'typing' for text messages * videos 'record_audio' or 'upload_audio' for audio files 'upload_document' for general files,
* 'upload_photo' for photos
* 'record_video' or 'upload_video' for videos
* 'record_audio' or 'upload_audio' for audio files
* 'upload_document' for general files,
* 'find_location' for location data. * 'find_location' for location data.
*/ */
private String action; private String action;

View File

@ -0,0 +1,178 @@
package org.telegram.telegrambots.api.methods.send;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to send information about user contact. On success, the sent Message is
* returned.
* @date 10 of April of 2016
*/
public class SendContact extends BotApiMethod<Message> {
public static final String PATH = "sendContact";
public static final String CHATID_FIELD = "chat_id";
public static final String PHONE_NUMBER_FIELD = "phone_number";
public static final String FIRST_NAME_FIELD = "first_name";
public static final String LAST_NAME_FIELD = "last_name";
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
public static final String REPLYMARKUP_FIELD = "reply_markup";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
private String phoneNumber; ///< User's phone number
private String firstName; ///< User's first name
private String lastName; ///< Optional. User's last name
/**
* Optional. Sends the message silently. iOS users will not receive a notification, Android
* users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public Integer getReplayToMessageId() {
return replayToMessageId;
}
public void setReplayToMessageId(Integer replayToMessageId) {
this.replayToMessageId = replayToMessageId;
}
public ReplyKeyboard getReplayMarkup() {
return replayMarkup;
}
public void setReplayMarkup(ReplyKeyboard replayMarkup) {
this.replayMarkup = replayMarkup;
}
public Boolean getDisableNotification() {
return disableNotification;
}
public void enableNotification() {
this.disableNotification = false;
}
public void disableNotification() {
this.disableNotification = true;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Message deserializeResponse(JSONObject answer) {
if (answer.getBoolean("ok")) {
return new Message(answer.getJSONObject("result"));
}
return null;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
jsonObject.put(PHONE_NUMBER_FIELD, phoneNumber);
jsonObject.put(FIRST_NAME_FIELD, firstName);
if (lastName != null) {
jsonObject.put(LAST_NAME_FIELD, lastName);
}
if (disableNotification != null) {
jsonObject.put(DISABLENOTIFICATION_FIELD, disableNotification);
}
if (replayToMessageId != null) {
jsonObject.put(REPLYTOMESSAGEID_FIELD, replayToMessageId);
}
if (replayMarkup != null) {
jsonObject.put(REPLYMARKUP_FIELD, replayMarkup.toJson());
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeStringField(PHONE_NUMBER_FIELD, phoneNumber);
gen.writeStringField(FIRST_NAME_FIELD, firstName);
if (lastName != null) {
gen.writeStringField(LAST_NAME_FIELD, lastName);
}
if (disableNotification != null) {
gen.writeBooleanField(DISABLENOTIFICATION_FIELD, disableNotification);
}
if (replayToMessageId != null) {
gen.writeNumberField(REPLYTOMESSAGEID_FIELD, replayToMessageId);
}
if (replayMarkup != null) {
gen.writeObjectField(REPLYMARKUP_FIELD, replayMarkup);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "SendLocation{" +
"chatId='" + chatId + '\'' +
", phoneNumber=" + phoneNumber +
", firstName=" + firstName +
", lastName=" + lastName +
", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup +
'}';
}
}

View File

@ -1,6 +1,6 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import org.telegram.telegrambots.api.objects.ReplyKeyboard; import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
@ -12,22 +12,20 @@ public class SendDocument {
public static final String PATH = "senddocument"; public static final String PATH = "senddocument";
public static final String CHATID_FIELD = "chat_id"; public static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat to send the message to or Username for the channel to send the message to
public static final String DOCUMENT_FIELD = "document"; public static final String DOCUMENT_FIELD = "document";
private String document; ///< File file to send. file_id as String to resend a file that is already on the Telegram servers
public static final String CAPTION_FIELD = "caption"; public static final String CAPTION_FIELD = "caption";
private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters
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 REPLYMARKUP_FIELD = "reply_markup";
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
private String caption; ///< Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters
/** /**
* Optional. Sends the message silently. * Optional. Sends the message silently. iOS users will not receive a notification, Android
* iOS users will not receive a notification, * users will receive a notification with no sound. Other apps coming soon
* Android users will receive a notification with no sound.
* Other apps coming soon
*/ */
private Boolean disableNotification; private Boolean disableNotification;
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private boolean isNewDocument; private boolean isNewDocument;

View File

@ -1,12 +1,13 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.Message; import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.ReplyKeyboard; import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
import java.io.IOException; import java.io.IOException;
@ -19,23 +20,21 @@ import java.io.IOException;
public class SendLocation extends BotApiMethod<Message> { public class SendLocation extends BotApiMethod<Message> {
public static final String PATH = "sendlocation"; public static final String PATH = "sendlocation";
public static final String CHATID_FIELD = "chat_id"; private static final String CHATID_FIELD = "chat_id";
private static final String LATITUDE_FIELD = "latitude";
private static final String LONGITUDE_FIELD = "longitude";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
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)
public static final String LATITUDE_FIELD = "latitude";
private Float latitude; ///< Latitude of location private Float latitude; ///< Latitude of location
public static final String LONGITUDE_FIELD = "longitude";
private Float longitude; ///< Longitude of location private Float longitude; ///< Longitude of location
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
/** /**
* Optional. Sends the message silently. * Optional. Sends the message silently. iOS users will not receive a notification, Android
* iOS users will not receive a notification, * users will receive a notification with no sound. Other apps coming soon
* Android users will receive a notification with no sound.
* Other apps coming soon
*/ */
private Boolean disableNotification; private Boolean disableNotification;
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
public String getChatId() { public String getChatId() {

View File

@ -1,12 +1,14 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.methods.ParseMode;
import org.telegram.telegrambots.api.objects.Message; import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.ReplyKeyboard; import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
import java.io.IOException; import java.io.IOException;
@ -19,25 +21,23 @@ import java.io.IOException;
public class SendMessage extends BotApiMethod<Message> { public class SendMessage extends BotApiMethod<Message> {
public static final String PATH = "sendmessage"; public static final String PATH = "sendmessage";
public static final String CHATID_FIELD = "chat_id"; private static final String CHATID_FIELD = "chat_id";
private static final String TEXT_FIELD = "text";
private static final String PARSEMODE_FIELD = "parse_mode";
private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
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)
public static final String TEXT_FIELD = "text";
private String text; ///< Text of the message to be sent private String text; ///< Text of the message to be sent
public static final String PARSEMODE_FIELD = "parse_mode";
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and URL text in your bot's message. private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and URL text in your bot's message.
public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in this message private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in this message
public static final String DISABLENOTIFICATION_FIELD = "disable_notification";
/** /**
* Optional. Sends the message silently. * Optional. Sends the message silently. iOS users will not receive a notification, Android
* iOS users will not receive a notification, * users will receive a notification with no sound. Other apps coming soon
* Android users will receive a notification with no sound.
* Other apps coming soon
*/ */
private Boolean disableNotification; private Boolean disableNotification;
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
public SendMessage() { public SendMessage() {
@ -80,16 +80,20 @@ public class SendMessage extends BotApiMethod<Message> {
return disableWebPagePreview; return disableWebPagePreview;
} }
public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
this.disableWebPagePreview = disableWebPagePreview;
}
public Boolean getDisableNotification() { public Boolean getDisableNotification() {
return disableNotification; return disableNotification;
} }
public void disableWebPagePreview() {
disableWebPagePreview = true;
}
public void enableWebPagePreview() {
disableWebPagePreview = null;
}
public void enableNotification() { public void enableNotification() {
this.disableNotification = false; this.disableNotification = null;
} }
public void disableNotification() { public void disableNotification() {
@ -98,7 +102,7 @@ public class SendMessage extends BotApiMethod<Message> {
public void enableMarkdown(boolean enable) { public void enableMarkdown(boolean enable) {
if (enable) { if (enable) {
this.parseMode = "Markdown"; this.parseMode = ParseMode.MARKDOWN;
} else { } else {
this.parseMode = null; this.parseMode = null;
} }
@ -106,7 +110,7 @@ public class SendMessage extends BotApiMethod<Message> {
public void enableHtml(boolean enable) { public void enableHtml(boolean enable) {
if (enable) { if (enable) {
this.parseMode = "html"; this.parseMode = ParseMode.HTML;
} else { } else {
this.parseMode = null; this.parseMode = null;
} }

View File

@ -1,6 +1,6 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import org.telegram.telegrambots.api.objects.ReplyKeyboard; import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
@ -12,22 +12,20 @@ public class SendPhoto {
public static final String PATH = "sendphoto"; public static final String PATH = "sendphoto";
public static final String CHATID_FIELD = "chat_id"; public static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public static final String PHOTO_FIELD = "photo"; public static final String PHOTO_FIELD = "photo";
private String photo; ///< Photo to send. file_id as String to resend a photo that is already on the Telegram servers
public static final String CAPTION_FIELD = "photo"; public static final String CAPTION_FIELD = "photo";
private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id).
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 REPLYMARKUP_FIELD = "reply_markup";
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
private String caption; ///< Optional Photo caption (may also be used when resending photos by file_id).
/** /**
* Optional. Sends the message silently. * Optional. Sends the message silently. iOS users will not receive a notification, Android
* iOS users will not receive a notification, * users will receive a notification with no sound. Other apps coming soon
* Android users will receive a notification with no sound.
* Other apps coming soon
*/ */
private Boolean disableNotification; private Boolean disableNotification;
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
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
@ -50,6 +48,11 @@ public class SendPhoto {
return photo; return photo;
} }
public void setPhoto(String photo) {
this.photo = photo;
this.isNewPhoto = false;
}
public String getCaption() { public String getCaption() {
return caption; return caption;
} }
@ -94,11 +97,6 @@ public class SendPhoto {
this.disableNotification = true; this.disableNotification = true;
} }
public void setPhoto(String photo) {
this.photo = photo;
this.isNewPhoto = false;
}
public void setNewPhoto(String photo, String photoName) { public void setNewPhoto(String photo, String photoName) {
this.photo = photo; this.photo = photo;
this.isNewPhoto = true; this.isNewPhoto = true;

View File

@ -1,31 +1,29 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import org.telegram.telegrambots.api.objects.ReplyKeyboard; import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief TODO * @brief Use this method to send .webp stickers. On success, the sent Message is returned.
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class SendSticker { public class SendSticker {
public static final String PATH = "sendsticker"; public static final String PATH = "sendsticker";
public static final String CHATID_FIELD = "chat_id"; public static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public static final String STICKER_FIELD = "sticker"; public static final String STICKER_FIELD = "sticker";
private String sticker; ///< Sticker file to send. file_id as String to resend a sticker that is already on the Telegram servers
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 REPLYMARKUP_FIELD = "reply_markup";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
private String sticker; ///< Sticker file to send. file_id as String to resend a sticker that is already on the Telegram servers
/** /**
* Optional. Sends the message silently. * Optional. Sends the message silently. iOS users will not receive a notification, Android
* iOS users will not receive a notification, * users will receive a notification with no sound. Other apps coming soon
* Android users will receive a notification with no sound.
* Other apps coming soon
*/ */
private Boolean disableNotification; private Boolean disableNotification;
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
private boolean isNewSticker; private boolean isNewSticker;
@ -47,6 +45,11 @@ public class SendSticker {
return sticker; return sticker;
} }
public void setSticker(String sticker) {
this.sticker = sticker;
this.isNewSticker = false;
}
public Integer getReplayToMessageId() { public Integer getReplayToMessageId() {
return replayToMessageId; return replayToMessageId;
} }
@ -63,11 +66,6 @@ public class SendSticker {
this.replayMarkup = replayMarkup; this.replayMarkup = replayMarkup;
} }
public void setSticker(String sticker) {
this.sticker = sticker;
this.isNewSticker = false;
}
public void setSticker(String sticker, String stickerName) { public void setSticker(String sticker, String stickerName) {
this.sticker = sticker; this.sticker = sticker;
this.isNewSticker = true; this.isNewSticker = true;

View File

@ -0,0 +1,204 @@
package org.telegram.telegrambots.api.methods.send;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to send information about a venue. On success, the sent Message is
* returned.
* @date 10 of April of 2016
*/
public class SendVenue extends BotApiMethod<Message> {
public static final String PATH = "sendVenue";
private static final String CHATID_FIELD = "chat_id";
private static final String LATITUDE_FIELD = "latitude";
private static final String LONGITUDE_FIELD = "longitude";
private static final String TITLE_FIELD = "title";
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
private static final String ADDRESS_FIELD = "address";
private static final String FOURSQUARE_ID_FIELD = "foursquare_id";
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
private Float latitude; ///< Latitude of venue location
private Float longitude; ///< Longitude of venue location
private String title; ///< Title of the venue
/**
* Optional. Sends the message silently. iOS users will not receive a notification, Android
* users will receive a notification with no sound. Other apps coming soon
*/
private Boolean disableNotification;
private String address; ///< Address of the venue
private String foursquareId; ///< Optional. Foursquare identifier of the venue
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public Float getLatitude() {
return latitude;
}
public void setLatitude(Float latitude) {
this.latitude = latitude;
}
public Float getLongitude() {
return longitude;
}
public void setLongitude(Float longitude) {
this.longitude = longitude;
}
public Integer getReplayToMessageId() {
return replayToMessageId;
}
public void setReplayToMessageId(Integer replayToMessageId) {
this.replayToMessageId = replayToMessageId;
}
public ReplyKeyboard getReplayMarkup() {
return replayMarkup;
}
public void setReplayMarkup(ReplyKeyboard replayMarkup) {
this.replayMarkup = replayMarkup;
}
public Boolean getDisableNotification() {
return disableNotification;
}
public void enableNotification() {
this.disableNotification = false;
}
public void disableNotification() {
this.disableNotification = true;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getFoursquareId() {
return foursquareId;
}
public void setFoursquareId(String foursquareId) {
this.foursquareId = foursquareId;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Message deserializeResponse(JSONObject answer) {
if (answer.getBoolean("ok")) {
return new Message(answer.getJSONObject("result"));
}
return null;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(CHATID_FIELD, chatId);
jsonObject.put(LATITUDE_FIELD, latitude);
jsonObject.put(LONGITUDE_FIELD, longitude);
jsonObject.put(TITLE_FIELD, title);
jsonObject.put(ADDRESS_FIELD, address);
if (foursquareId != null) {
jsonObject.put(FOURSQUARE_ID_FIELD, foursquareId);
}
if (disableNotification != null) {
jsonObject.put(DISABLENOTIFICATION_FIELD, disableNotification);
}
if (replayToMessageId != null) {
jsonObject.put(REPLYTOMESSAGEID_FIELD, replayToMessageId);
}
if (replayMarkup != null) {
jsonObject.put(REPLYMARKUP_FIELD, replayMarkup.toJson());
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeNumberField(LATITUDE_FIELD, latitude);
gen.writeNumberField(LONGITUDE_FIELD, longitude);
gen.writeStringField(TITLE_FIELD, title);
gen.writeStringField(ADDRESS_FIELD, address);
if (foursquareId != null) {
gen.writeStringField(FOURSQUARE_ID_FIELD, foursquareId);
}
if (disableNotification != null) {
gen.writeBooleanField(DISABLENOTIFICATION_FIELD, disableNotification);
}
if (replayToMessageId != null) {
gen.writeNumberField(REPLYTOMESSAGEID_FIELD, replayToMessageId);
}
if (replayMarkup != null) {
gen.writeObjectField(REPLYMARKUP_FIELD, replayMarkup);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "SendLocation{" +
"chatId='" + chatId + '\'' +
", latitude=" + latitude +
", longitude=" + longitude +
", title=" + title +
", address=" + address +
", foursquareId=" + foursquareId +
", replayToMessageId=" + replayToMessageId +
", replayMarkup=" + replayMarkup +
'}';
}
}

View File

@ -1,41 +1,38 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import org.telegram.telegrambots.api.objects.ReplyKeyboard; import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief Use this method to send video files, * @brief Use this method to send video files, Telegram clients support mp4 videos (other formats
* Telegram clients support mp4 videos (other formats may be sent as Document). * may be sent as Document). On success, the sent Message is returned.
* On success, the sent Message is returned.
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class SendVideo { public class SendVideo {
public static final String PATH = "sendvideo"; public static final String PATH = "sendvideo";
public static final String CHATID_FIELD = "chat_id"; public static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
public static final String VIDEO_FIELD = "video"; public static final String VIDEO_FIELD = "video";
private String video; ///< Video to send. file_id as String to resend a video that is already on the Telegram servers
public static final String DURATION_FIELD = "duration"; public static final String DURATION_FIELD = "duration";
private Integer duration; ///< Optional. Duration of sent video in seconds
public static final String CAPTION_FIELD = "caption"; public static final String CAPTION_FIELD = "caption";
private String caption; ///< OptionaL. Video caption (may also be used when resending videos by file_id).
public static final String WIDTH_FIELD = "width"; public static final String WIDTH_FIELD = "width";
private Integer width; ///< Optional. Video width
public static final String HEIGHT_FIELD = "height"; public static final String HEIGHT_FIELD = "height";
private Integer height; ///< OptionaL. Video height
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 REPLYMARKUP_FIELD = "reply_markup";
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
private Integer duration; ///< Optional. Duration of sent video in seconds
private String caption; ///< OptionaL. Video caption (may also be used when resending videos by file_id).
private Integer width; ///< Optional. Video width
private Integer height; ///< OptionaL. Video height
/** /**
* Optional. Sends the message silently. * Optional. Sends the message silently. iOS users will not receive a notification, Android
* iOS users will not receive a notification, * users will receive a notification with no sound. Other apps coming soon
* Android users will receive a notification with no sound.
* Other apps coming soon
*/ */
private Boolean disableNotification; private Boolean disableNotification;
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
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
@ -57,6 +54,11 @@ public class SendVideo {
return video; return video;
} }
public void setVideo(String video) {
this.video = video;
this.isNewVideo = false;
}
public Integer getDuration() { public Integer getDuration() {
return duration; return duration;
} }
@ -125,11 +127,6 @@ public class SendVideo {
this.height = height; this.height = height;
} }
public void setVideo(String video) {
this.video = video;
this.isNewVideo = false;
}
public void setNewVideo(String video, String videoName) { public void setNewVideo(String video, String videoName) {
this.video = video; this.video = video;
this.isNewVideo = true; this.isNewVideo = true;

View File

@ -1,13 +1,12 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.send;
import org.telegram.telegrambots.api.objects.ReplyKeyboard; import org.telegram.telegrambots.api.objects.replykeyboard.ReplyKeyboard;
/** /**
* @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 * @brief Use this method to send voice notes, if you want Telegram clients to display the file as a
* the file as a playable voice message. * playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS
* 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 * @date 16 of July of 2015
*/ */
@ -15,22 +14,20 @@ public class SendVoice {
public static final String PATH = "sendvoice"; public static final String PATH = "sendvoice";
public static final String CHATID_FIELD = "chat_id"; public static final String CHATID_FIELD = "chat_id";
private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
public static final String AUDIO_FIELD = "audio"; public static final String AUDIO_FIELD = "audio";
private String audio; ///< 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.
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 REPLYMARKUP_FIELD = "reply_markup";
public static final String DURATION_FIELD = "duration";
private String chatId; ///< Unique identifier for the chat sent message to (Or username for channels)
private String audio; ///< 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.
/** /**
* Optional. Sends the message silently. * Optional. Sends the message silently. iOS users will not receive a notification, Android
* iOS users will not receive a notification, * users will receive a notification with no sound. Other apps coming soon
* Android users will receive a notification with no sound.
* Other apps coming soon
*/ */
private Boolean disableNotification; private Boolean disableNotification;
public static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message private Integer replayToMessageId; ///< Optional. If the message is a reply, ID of the original message
public static final String REPLYMARKUP_FIELD = "reply_markup";
private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard private ReplyKeyboard replayMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
public static final String DURATION_FIELD = "duration";
private Integer duration; ///< Optional. Duration of sent audio in seconds private Integer duration; ///< Optional. Duration of sent audio in seconds
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

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.updates;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IToJson; import org.telegram.telegrambots.api.interfaces.IToJson;
@ -6,31 +6,30 @@ import org.telegram.telegrambots.api.interfaces.IToJson;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief Use this method to receive incoming updates using long polling (wiki). * @brief Use this method to receive incoming updates using long polling (wiki). An Array of Update
* An Array of Update objects is returned. * objects is returned.
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class GetUpdates implements IToJson { public class GetUpdates implements IToJson {
public static final String PATH = "getupdates"; public static final String PATH = "getupdates";
public static final String OFFSET_FIELD = "offset"; private static final String OFFSET_FIELD = "offset";
private static final String LIMIT_FIELD = "limit";
private static final String TIMEOUT_FIELD = "timeout";
/** /**
* Optional. Identifier of the first update to be returned. * Optional. Identifier of the first update to be returned. Must be greater by one than the
* Must be greater by one than the highest among the identifiers * highest among the identifiers of previously received updates. By default, updates starting
* of previously received updates. By default, updates starting with the * with the earliest unconfirmed update are returned. An update is considered confirmed as soon
* earliest unconfirmed update are returned. An update is considered confirmed as soon as * as getUpdates is called with an offset higher than its update_id. The negative offset can be
* getUpdates is called with an offset higher than its update_id. The negative offset can * specified to retrieve updates starting from -offset update from the end of the updates queue.
* be specified to retrieve updates starting from -offset update from the end of * All previous updates will forgotten.
* the updates queue. All previous updates will forgotten.
*/ */
private Integer offset; private Integer offset;
public static final String LIMIT_FIELD = "limit";
/** /**
* Optional Limits the number of updates to be retrieved. * Optional Limits the number of updates to be retrieved. Values between 1100 are accepted.
* Values between 1100 are accepted. Defaults to 100 * Defaults to 100
*/ */
private Integer limit; private Integer limit;
public static final String TIMEOUT_FIELD = "timeout";
/** /**
* Optional Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling * Optional Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling
*/ */

View File

@ -1,20 +1,20 @@
package org.telegram.telegrambots.api.methods; package org.telegram.telegrambots.api.methods.updates;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief Use this method to specify a url and receive incoming updates via an outgoing webhook. * @brief Use this method to specify a url and receive incoming updates via an outgoing webhook.
* Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url,
* containing a JSON-serialized Update. In case of an unsuccessful request, * containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a
* we will give up after a reasonable amount of attempts. * reasonable amount of attempts.
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class SetWebhook { public class SetWebhook {
public static final String PATH = "setwebhook"; public static final String PATH = "setwebhook";
public static final String URL_FIELD = "url"; public static final String URL_FIELD = "url";
private String url; ///< Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration
public static final String CERTIFICATE_FIELD = "certificate"; public static final String CERTIFICATE_FIELD = "certificate";
private String url; ///< Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration
private String certificateFile; ///< Optional. Upload your public key certificate so that the root certificate in use can be checked private String certificateFile; ///< Optional. Upload your public key certificate so that the root certificate in use can be checked
public SetWebhook() { public SetWebhook() {

View File

@ -0,0 +1,156 @@
package org.telegram.telegrambots.api.methods.updatingmessages;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to edit captions of messages sent by the bot or via the bot (for inline
* bots). On success, the edited Message is returned
* @date 10 of April of 2016
*/
public class EditMessageCaption extends BotApiMethod<Message> {
public static final String PATH = "editmessagecaption";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGEID_FIELD = "message_id";
private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
private static final String CAPTION_FIELD = "caption";
private static final String REPLYMARKUP_FIELD = "reply_markup";
/**
* Required if inline_message_id is not specified. Unique identifier for the chat to send the
* message to (Or username for channels)
*/
private String chatId;
/**
* Required if inline_message_id is not specified. Unique identifier of the sent message
*/
private Integer messageId;
/**
* Required if chat_id and message_id are not specified. Identifier of the inline message
*/
private String inlineMessageId;
private String caption; ///< Optional. New caption of the message
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
public EditMessageCaption() {
super();
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public Integer getMessageId() {
return messageId;
}
public void setMessageId(Integer messageId) {
this.messageId = messageId;
}
public String getInlineMessageId() {
return inlineMessageId;
}
public void setInlineMessageId(String inlineMessageId) {
this.inlineMessageId = inlineMessageId;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
if (inlineMessageId == null) {
jsonObject.put(CHATID_FIELD, chatId);
jsonObject.put(MESSAGEID_FIELD, messageId);
} else {
jsonObject.put(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
}
if (caption != null) {
jsonObject.put(CAPTION_FIELD, caption);
}
if (replyMarkup != null) {
jsonObject.put(REPLYMARKUP_FIELD, replyMarkup.toJson());
}
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Message deserializeResponse(JSONObject answer) {
if (answer.getBoolean("ok")) {
return new Message(answer.getJSONObject("result"));
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
if (inlineMessageId == null) {
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeNumberField(MESSAGEID_FIELD, messageId);
} else {
gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
}
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, caption);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLYMARKUP_FIELD, replyMarkup);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "EditMessageCaption{" +
"chatId=" + chatId +
", messageId=" + messageId +
", inlineMessageId=" + inlineMessageId +
", caption=" + caption +
", replyMarkup=" + replyMarkup +
'}';
}
}

View File

@ -0,0 +1,139 @@
package org.telegram.telegrambots.api.methods.updatingmessages;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to edit only the reply markup of messages sent by the bot or via the bot
* (for inline bots). On success, the edited Message is returned.
* @date 10 of April of 2016
*/
public class EditMessageReplyMarkup extends BotApiMethod<Message> {
public static final String PATH = "editmessagereplymarkup";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGEID_FIELD = "message_id";
private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
private static final String REPLYMARKUP_FIELD = "reply_markup";
/**
* Required if inline_message_id is not specified. Unique identifier for the chat to send the
* message to (Or username for channels)
*/
private String chatId;
/**
* Required if inline_message_id is not specified. Unique identifier of the sent message
*/
private Integer messageId;
/**
* Required if chat_id and message_id are not specified. Identifier of the inline message
*/
private String inlineMessageId;
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
public EditMessageReplyMarkup() {
super();
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public Integer getMessageId() {
return messageId;
}
public void setMessageId(Integer messageId) {
this.messageId = messageId;
}
public String getInlineMessageId() {
return inlineMessageId;
}
public void setInlineMessageId(String inlineMessageId) {
this.inlineMessageId = inlineMessageId;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
if (inlineMessageId == null) {
jsonObject.put(CHATID_FIELD, chatId);
jsonObject.put(MESSAGEID_FIELD, messageId);
} else {
jsonObject.put(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
}
if (replyMarkup != null) {
jsonObject.put(REPLYMARKUP_FIELD, replyMarkup.toJson());
}
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Message deserializeResponse(JSONObject answer) {
if (answer.getBoolean("ok")) {
return new Message(answer.getJSONObject("result"));
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
if (inlineMessageId == null) {
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeNumberField(MESSAGEID_FIELD, messageId);
} else {
gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLYMARKUP_FIELD, replyMarkup);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "EditMessageReplyMarkup{" +
"chatId=" + chatId +
", messageId=" + messageId +
", inlineMessageId=" + inlineMessageId +
", replyMarkup=" + replyMarkup +
'}';
}
}

View File

@ -0,0 +1,202 @@
package org.telegram.telegrambots.api.methods.updatingmessages;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.BotApiMethod;
import org.telegram.telegrambots.api.methods.ParseMode;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Use this method to edit text messages sent by the bot or via the bot (for inline bots). On
* success, the edited Message is returned.
* @date 10 of April of 2016
*/
public class EditMessageText extends BotApiMethod<Message> {
public static final String PATH = "editmessagetext";
private static final String CHATID_FIELD = "chat_id";
private static final String MESSAGEID_FIELD = "message_id";
private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
private static final String TEXT_FIELD = "text";
private static final String PARSE_MODE_FIELD = "parse_mode";
private static final String DISABLE_WEB_PREVIEW_FIELD = "disable_web_page_preview";
private static final String REPLYMARKUP_FIELD = "reply_markup";
/**
* Required if inline_message_id is not specified. Unique identifier for the chat to send the
* message to (Or username for channels)
*/
private String chatId;
/**
* Required if inline_message_id is not specified. Unique identifier of the sent message
*/
private Integer messageId;
/**
* Required if chat_id and message_id are not specified. Identifier of the inline message
*/
private String inlineMessageId;
/**
* New text of the message
*/
private String text;
/**
* Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width
* text or inline URLs in your bot's message.
*/
private String parseMode;
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in this message
private InlineKeyboardMarkup replyMarkup; ///< Optional. A JSON-serialized object for an inline keyboard.
public EditMessageText() {
super();
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public Integer getMessageId() {
return messageId;
}
public void setMessageId(Integer messageId) {
this.messageId = messageId;
}
public String getInlineMessageId() {
return inlineMessageId;
}
public void setInlineMessageId(String inlineMessageId) {
this.inlineMessageId = inlineMessageId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public void disableWebPagePreview() {
disableWebPagePreview = true;
}
public void enableWebPagePreview() {
disableWebPagePreview = null;
}
public void enableMarkdown(boolean enable) {
if (enable) {
this.parseMode = ParseMode.MARKDOWN;
} else {
this.parseMode = null;
}
}
public void enableHtml(boolean enable) {
if (enable) {
this.parseMode = ParseMode.HTML;
} else {
this.parseMode = null;
}
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
if (inlineMessageId == null) {
jsonObject.put(CHATID_FIELD, chatId);
jsonObject.put(MESSAGEID_FIELD, messageId);
} else {
jsonObject.put(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
}
jsonObject.put(TEXT_FIELD, text);
if (parseMode != null) {
jsonObject.put(PARSE_MODE_FIELD, parseMode);
}
if (disableWebPagePreview != null) {
jsonObject.put(DISABLE_WEB_PREVIEW_FIELD, disableWebPagePreview);
}
if (replyMarkup != null) {
jsonObject.put(REPLYMARKUP_FIELD, replyMarkup.toJson());
}
return jsonObject;
}
@Override
public String getPath() {
return PATH;
}
@Override
public Message deserializeResponse(JSONObject answer) {
if (answer.getBoolean("ok")) {
return new Message(answer.getJSONObject("result"));
}
return null;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(METHOD_FIELD, PATH);
if (inlineMessageId == null) {
gen.writeStringField(CHATID_FIELD, chatId);
gen.writeNumberField(MESSAGEID_FIELD, messageId);
} else {
gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
}
gen.writeStringField(TEXT_FIELD, text);
if (parseMode != null) {
gen.writeStringField(PARSE_MODE_FIELD, parseMode);
}
if (disableWebPagePreview != null) {
gen.writeBooleanField(DISABLE_WEB_PREVIEW_FIELD, disableWebPagePreview);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLYMARKUP_FIELD, replyMarkup);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "EditMessageText{" +
"chatId=" + chatId +
", messageId=" + messageId +
", inlineMessageId=" + inlineMessageId +
", text=" + text +
", parseMode=" + parseMode +
", disableWebPagePreview=" + disableWebPagePreview +
", replyMarkup=" + replyMarkup +
'}';
}
}

View File

@ -18,12 +18,12 @@ import java.io.IOException;
*/ */
public class Audio implements IBotApiObject { public class Audio implements IBotApiObject {
public static final String FILEID_FIELD = "file_id"; private static final String FILEID_FIELD = "file_id";
public static final String DURATION_FIELD = "duration"; private static final String DURATION_FIELD = "duration";
public static final String MIMETYPE_FIELD = "mime_type"; private static final String MIMETYPE_FIELD = "mime_type";
public static final String FILESIZE_FIELD = "file_size"; private static final String FILESIZE_FIELD = "file_size";
public static final String TITLE_FIELD = "title"; private static final String TITLE_FIELD = "title";
public static final String PERFORMER_FIELD = "performer"; private static final String PERFORMER_FIELD = "performer";
@JsonProperty(FILEID_FIELD) @JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file private String fileId; ///< Unique identifier for this file
@JsonProperty(DURATION_FIELD) @JsonProperty(DURATION_FIELD)

View File

@ -0,0 +1,98 @@
package org.telegram.telegrambots.api.objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief This object represents an incoming callback query from a callback button in an inline
* keyboard. If the button that originated the query was attached to a message sent by the bot, the
* field message will be presented. If the button was attached to a message sent via the bot (in
* inline mode), the field inline_message_id will be presented.
* @date 10 of April of 2016
*/
public class CallbackQuery implements IBotApiObject {
private static final String ID_FIELD = "id";
private static final String FROM_FIELD = "from";
private static final String MESSAGE_FIELD = "message";
private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
private static final String DATA_FIELD = "data";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier for this query
@JsonProperty(FROM_FIELD)
private User from; ///< Sender
@JsonProperty(MESSAGE_FIELD)
/**
* Optional.
* Message with the callback button that originated the query.
*
* @note The message content and message date will not be available if the message is too old
*/
private Message message;
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
private String inlineMessageId; ///< Optional. Identifier of the message sent via the bot in inline mode, that originated the query
@JsonProperty(DATA_FIELD)
/**
* Data associated with the callback button.
* @note Be aware that a bad client can send arbitrary data in this field
*/
private String data;
public CallbackQuery() {
super();
}
public CallbackQuery(JSONObject jsonObject) {
super();
this.id = jsonObject.getString(ID_FIELD);
this.from = new User(jsonObject.getJSONObject(FROM_FIELD));
if (jsonObject.has(MESSAGE_FIELD)) {
this.message = new Message(jsonObject.getJSONObject(MESSAGE_FIELD));
}
if (jsonObject.has(INLINE_MESSAGE_ID_FIELD)) {
this.inlineMessageId = jsonObject.getString(INLINE_MESSAGE_ID_FIELD);
}
data = jsonObject.getString(DATA_FIELD);
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(ID_FIELD, id);
gen.writeObjectField(FROM_FIELD, from);
if (message != null) {
gen.writeObjectField(MESSAGE_FIELD, message);
}
if (inlineMessageId != null) {
gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
}
gen.writeStringField(DATA_FIELD, data);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "Contact{" +
"id='" + id + '\'' +
", from='" + from + '\'' +
", message='" + message + '\'' +
", inlineMessageId='" + inlineMessageId + '\'' +
", data=" + data +
'}';
}
}

View File

@ -17,12 +17,12 @@ import java.io.IOException;
* @date 24 of June of 2015 * @date 24 of June of 2015
*/ */
public class Chat implements IBotApiObject { public class Chat implements IBotApiObject {
public static final String ID_FIELD = "id"; private static final String ID_FIELD = "id";
public static final String TYPE_FIELD = "type"; private static final String TYPE_FIELD = "type";
public static final String TITLE_FIELD = "title"; private static final String TITLE_FIELD = "title";
public static final String FIRSTNAME_FIELD = "first_name"; private static final String FIRSTNAME_FIELD = "first_name";
public static final String LASTNAME_FIELD = "last_name"; private static final String LASTNAME_FIELD = "last_name";
public static final String USERNAME_FIELD = "username"; private static final String USERNAME_FIELD = "username";
private static final String USERCHATTYPE = "private"; private static final String USERCHATTYPE = "private";
private static final String GROUPCHATTYPE = "group"; private static final String GROUPCHATTYPE = "group";
private static final String CHANNELCHATTYPE = "channel"; private static final String CHANNELCHATTYPE = "channel";

View File

@ -18,10 +18,10 @@ import java.io.IOException;
*/ */
public class Contact implements IBotApiObject { public class Contact implements IBotApiObject {
public static final String PHONENUMBER_FIELD = "phone_number"; private static final String PHONENUMBER_FIELD = "phone_number";
public static final String FIRSTNAME_FIELD = "first_name"; private static final String FIRSTNAME_FIELD = "first_name";
public static final String LASTNAME_FIELD = "last_name"; private static final String LASTNAME_FIELD = "last_name";
public static final String USERID_FIELD = "user_id"; private static final String USERID_FIELD = "user_id";
@JsonProperty(PHONENUMBER_FIELD) @JsonProperty(PHONENUMBER_FIELD)
private String phoneNumber; ///< Contact's phone number private String phoneNumber; ///< Contact's phone number
@JsonProperty(FIRSTNAME_FIELD) @JsonProperty(FIRSTNAME_FIELD)

View File

@ -19,11 +19,11 @@ import java.io.IOException;
*/ */
public class Document implements IBotApiObject { public class Document implements IBotApiObject {
public static final String FILEID_FIELD = "file_id"; private static final String FILEID_FIELD = "file_id";
public static final String THUMB_FIELD = "thumb"; private static final String THUMB_FIELD = "thumb";
public static final String FILENAME_FIELD = "file_name"; private static final String FILENAME_FIELD = "file_name";
public static final String MIMETYPE_FIELD = "mime_type"; private static final String MIMETYPE_FIELD = "mime_type";
public static final String FILESIZE_FIELD = "file_size"; private static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILEID_FIELD) @JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file private String fileId; ///< Unique identifier for this file
@JsonProperty(THUMB_FIELD) @JsonProperty(THUMB_FIELD)

View File

@ -0,0 +1,24 @@
package org.telegram.telegrambots.api.objects;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Types of messages entities
* @date 10 of April of 2016
*/
public class EntityType {
public static final String MENTION = "mention"; ///< @username
public static final String HASHTAG = "hashtag"; ///< #hashtag
public static final String BOTCOMMAND = "bot_command"; ///< /botcommand
public static final String URL = "url"; ///< http://url.url
public static final String EMAIL = "email"; ///< email@email.com
public static final String BOLD = "bold"; ///< Bold text
public static final String ITALIC = "italic"; ///< Italic text
public static final String CODE = "code"; ///< Monowidth string
public static final String PRE = "pre"; ///< Monowidth block
public static final String TEXTLINK = "text_link"; ///< Clickable urls
private EntityType() {
}
}

View File

@ -17,9 +17,9 @@ import java.io.IOException;
* @date 24 of June of 2015 * @date 24 of June of 2015
*/ */
public class File implements IBotApiObject { public class File implements IBotApiObject {
public static final String FILE_ID = "file_id"; private static final String FILE_ID = "file_id";
public static final String FILE_SIZE_FIELD = "file_size"; private static final String FILE_SIZE_FIELD = "file_size";
public static final String FILE_PATH_FIELD = "file_path"; private static final String FILE_PATH_FIELD = "file_path";
@JsonProperty(FILE_ID) @JsonProperty(FILE_ID)
private String fileId; ///< Unique identifier for this file private String fileId; ///< Unique identifier for this file
@JsonProperty(FILE_SIZE_FIELD) @JsonProperty(FILE_SIZE_FIELD)

View File

@ -18,8 +18,8 @@ import java.io.IOException;
*/ */
public class Location implements IBotApiObject { public class Location implements IBotApiObject {
public static final String LONGITUDE_FIELD = "longitude"; private static final String LONGITUDE_FIELD = "longitude";
public static final String LATITUDE_FIELD = "latitude"; private static final String LATITUDE_FIELD = "latitude";
@JsonProperty(LONGITUDE_FIELD) @JsonProperty(LONGITUDE_FIELD)
private Double longitude; ///< Longitude as defined by sender private Double longitude; ///< Longitude as defined by sender
@JsonProperty(LATITUDE_FIELD) @JsonProperty(LATITUDE_FIELD)

View File

@ -20,38 +20,41 @@ import java.util.List;
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class Message implements IBotApiObject { public class Message implements IBotApiObject {
public static final String MESSAGEID_FIELD = "message_id"; private static final String MESSAGEID_FIELD = "message_id";
public static final String FROM_FIELD = "from"; private static final String FROM_FIELD = "from";
public static final String DATE_FIELD = "date"; private static final String DATE_FIELD = "date";
public static final String CHAT_FIELD = "chat"; private static final String CHAT_FIELD = "chat";
public static final String FORWARDFROM_FIELD = "forward_from"; private static final String FORWARDFROM_FIELD = "forward_from";
public static final String FORWARDDATE_FIELD = "forward_date"; private static final String FORWARDDATE_FIELD = "forward_date";
public static final String TEXT_FIELD = "text"; private static final String TEXT_FIELD = "text";
public static final String AUDIO_FIELD = "audio"; private static final String ENTITIES_FIELD = "entities";
public static final String DOCUMENT_FIELD = "document"; private static final String AUDIO_FIELD = "audio";
public static final String PHOTO_FIELD = "photo"; private static final String DOCUMENT_FIELD = "document";
public static final String STICKER_FIELD = "sticker"; private static final String PHOTO_FIELD = "photo";
public static final String VIDEO_FIELD = "video"; private static final String STICKER_FIELD = "sticker";
public static final String CONTACT_FIELD = "contact"; private static final String VIDEO_FIELD = "video";
public static final String LOCATION_FIELD = "location"; private static final String CONTACT_FIELD = "contact";
public static final String NEWCHATPARTICIPANT_FIELD = "new_chat_participant"; private static final String LOCATION_FIELD = "location";
public static final String LEFTCHATPARTICIPANT_FIELD = "left_chat_participant"; private static final String VENUE_FIELD = "venue";
public static final String NEWCHATTITLE_FIELD = "new_chat_title"; private static final String PINNED_MESSAGE_FIELD = "pinned_message";
public static final String NEWCHATPHOTO_FIELD = "new_chat_photo"; private static final String NEWCHATMEMBER_FIELD = "new_chat_member";
public static final String DELETECHATPHOTO_FIELD = "delete_chat_photo"; private static final String LEFTCHATMEMBER_FIELD = "left_chat_member";
public static final String GROUPCHATCREATED_FIELD = "group_chat_created"; private static final String NEWCHATTITLE_FIELD = "new_chat_title";
public static final String REPLYTOMESSAGE_FIELD = "reply_to_message"; private static final String NEWCHATPHOTO_FIELD = "new_chat_photo";
public static final String VOICE_FIELD = "voice"; private static final String DELETECHATPHOTO_FIELD = "delete_chat_photo";
public static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created"; private static final String GROUPCHATCREATED_FIELD = "group_chat_created";
public static final String CHANNELCHATCREATED_FIELD = "channel_chat_created"; private static final String REPLYTOMESSAGE_FIELD = "reply_to_message";
public static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id"; private static final String VOICE_FIELD = "voice";
public static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id"; private static final String SUPERGROUPCREATED_FIELD = "supergroup_chat_created";
private static final String CHANNELCHATCREATED_FIELD = "channel_chat_created";
private static final String MIGRATETOCHAT_FIELD = "migrate_to_chat_id";
private static final String MIGRATEFROMCHAT_FIELD = "migrate_from_chat_id";
@JsonProperty(MESSAGEID_FIELD) @JsonProperty(MESSAGEID_FIELD)
private Integer messageId; ///< Integer Unique message identifier private Integer messageId; ///< Integer Unique message identifier
@JsonProperty(FROM_FIELD) @JsonProperty(FROM_FIELD)
private User from; ///< Optional. Sender, can be empty for messages sent to channels private User from; ///< Optional. Sender, can be empty for messages sent to channels
@JsonProperty(DATE_FIELD) @JsonProperty(DATE_FIELD)
private Integer date; ///< Date the message was sent in Unix time private Integer date; ///< Optional. Date the message was sent in Unix time
@JsonProperty(CHAT_FIELD) @JsonProperty(CHAT_FIELD)
private Chat chat; ///< Conversation the message belongs to private Chat chat; ///< Conversation the message belongs to
@JsonProperty(FORWARDFROM_FIELD) @JsonProperty(FORWARDFROM_FIELD)
@ -60,6 +63,12 @@ public class Message implements IBotApiObject {
private Integer forwardDate; ///< Optional. For forwarded messages, date the original message was sent private Integer forwardDate; ///< Optional. For forwarded messages, date the original message was sent
@JsonProperty(TEXT_FIELD) @JsonProperty(TEXT_FIELD)
private String text; ///< Optional. For text messages, the actual UTF-8 text of the message private String text; ///< Optional. For text messages, the actual UTF-8 text of the message
@JsonProperty(ENTITIES_FIELD)
/**
* Optional. For text messages, special entities like usernames, URLs,
* bot commands, etc. that appear in the text
*/
private List<MessageEntity> entities;
@JsonProperty(AUDIO_FIELD) @JsonProperty(AUDIO_FIELD)
private Audio audio; ///< Optional. Message is an audio file, information about the file private Audio audio; ///< Optional. Message is an audio file, information about the file
@JsonProperty(DOCUMENT_FIELD) @JsonProperty(DOCUMENT_FIELD)
@ -74,10 +83,14 @@ public class Message implements IBotApiObject {
private Contact contact; ///< Optional. Message is a shared contact, information about the contact private Contact contact; ///< Optional. Message is a shared contact, information about the contact
@JsonProperty(LOCATION_FIELD) @JsonProperty(LOCATION_FIELD)
private Location location; ///< Optional. Message is a shared location, information about the location private Location location; ///< Optional. Message is a shared location, information about the location
@JsonProperty(NEWCHATPARTICIPANT_FIELD) @JsonProperty(VENUE_FIELD)
private User newChatParticipant; ///< Optional. A new member was added to the group, information about them (this member may be bot itself) private Venue venue; ///< Optional. Message is a venue, information about the venue
@JsonProperty(LEFTCHATPARTICIPANT_FIELD) @JsonProperty(PINNED_MESSAGE_FIELD)
private User leftChatParticipant; ///< Optional. A member was removed from the group, information about them (this member may be bot itself) private Message pinnedMessage; ///< Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
@JsonProperty(NEWCHATMEMBER_FIELD)
private User newChatMember; ///< Optional. A new member was added to the group, information about them (this member may be bot itself)
@JsonProperty(LEFTCHATMEMBER_FIELD)
private User leftChatMember; ///< Optional. A member was removed from the group, information about them (this member may be bot itself)
@JsonProperty(NEWCHATTITLE_FIELD) @JsonProperty(NEWCHATTITLE_FIELD)
private String newChatTitle; ///< Optional. A chat title was changed to this value private String newChatTitle; ///< Optional. A chat title was changed to this value
@JsonProperty(NEWCHATPHOTO_FIELD) @JsonProperty(NEWCHATPHOTO_FIELD)
@ -109,7 +122,9 @@ public class Message implements IBotApiObject {
if (jsonObject.has(FROM_FIELD)) { if (jsonObject.has(FROM_FIELD)) {
this.from = new User(jsonObject.getJSONObject(FROM_FIELD)); this.from = new User(jsonObject.getJSONObject(FROM_FIELD));
} }
if (jsonObject.has(DATE_FIELD)) {
this.date = jsonObject.getInt(DATE_FIELD); this.date = jsonObject.getInt(DATE_FIELD);
}
this.chat = new Chat(jsonObject.getJSONObject(CHAT_FIELD)); this.chat = new Chat(jsonObject.getJSONObject(CHAT_FIELD));
if (jsonObject.has(FORWARDFROM_FIELD)) { if (jsonObject.has(FORWARDFROM_FIELD)) {
this.forwardFrom = new User(jsonObject.getJSONObject(FORWARDFROM_FIELD)); this.forwardFrom = new User(jsonObject.getJSONObject(FORWARDFROM_FIELD));
@ -120,6 +135,13 @@ public class Message implements IBotApiObject {
if (jsonObject.has(TEXT_FIELD)) { if (jsonObject.has(TEXT_FIELD)) {
this.text = jsonObject.getString(TEXT_FIELD); this.text = jsonObject.getString(TEXT_FIELD);
} }
if (jsonObject.has(ENTITIES_FIELD)) {
this.entities = new ArrayList<>();
JSONArray entities = jsonObject.getJSONArray(ENTITIES_FIELD);
for (int i = 0; i < entities.length(); i++) {
this.entities.add(new MessageEntity(entities.getJSONObject(i)));
}
}
if (jsonObject.has(AUDIO_FIELD)) { if (jsonObject.has(AUDIO_FIELD)) {
this.audio = new Audio(jsonObject.getJSONObject(AUDIO_FIELD)); this.audio = new Audio(jsonObject.getJSONObject(AUDIO_FIELD));
} }
@ -145,14 +167,20 @@ public class Message implements IBotApiObject {
if (jsonObject.has(LOCATION_FIELD)) { if (jsonObject.has(LOCATION_FIELD)) {
this.location = new Location(jsonObject.getJSONObject(LOCATION_FIELD)); this.location = new Location(jsonObject.getJSONObject(LOCATION_FIELD));
} }
if (jsonObject.has(VENUE_FIELD)) {
venue = new Venue(jsonObject.getJSONObject(VENUE_FIELD));
}
if (jsonObject.has(PINNED_MESSAGE_FIELD)) {
pinnedMessage = new Message(jsonObject.getJSONObject(PINNED_MESSAGE_FIELD));
}
if (jsonObject.has(VOICE_FIELD)) { if (jsonObject.has(VOICE_FIELD)) {
this.voice = new Voice(jsonObject.getJSONObject(VOICE_FIELD)); this.voice = new Voice(jsonObject.getJSONObject(VOICE_FIELD));
} }
if (jsonObject.has(NEWCHATPARTICIPANT_FIELD)) { if (jsonObject.has(NEWCHATMEMBER_FIELD)) {
this.newChatParticipant = new User(jsonObject.getJSONObject(NEWCHATPARTICIPANT_FIELD)); this.newChatMember = new User(jsonObject.getJSONObject(NEWCHATMEMBER_FIELD));
} }
if (jsonObject.has(LEFTCHATPARTICIPANT_FIELD)) { if (jsonObject.has(LEFTCHATMEMBER_FIELD)) {
this.leftChatParticipant = new User(jsonObject.getJSONObject(LEFTCHATPARTICIPANT_FIELD)); this.leftChatMember = new User(jsonObject.getJSONObject(LEFTCHATMEMBER_FIELD));
} }
if (jsonObject.has(REPLYTOMESSAGE_FIELD)) { if (jsonObject.has(REPLYTOMESSAGE_FIELD)) {
this.replyToMessage = new Message(jsonObject.getJSONObject(REPLYTOMESSAGE_FIELD)); this.replyToMessage = new Message(jsonObject.getJSONObject(REPLYTOMESSAGE_FIELD));
@ -327,20 +355,20 @@ public class Message implements IBotApiObject {
this.location = location; this.location = location;
} }
public User getNewChatParticipant() { public User getNewChatMember() {
return newChatParticipant; return newChatMember;
} }
public void setNewChatParticipant(User newChatParticipant) { public void setNewChatMember(User newChatMember) {
this.newChatParticipant = newChatParticipant; this.newChatMember = newChatMember;
} }
public User getLeftChatParticipant() { public User getLeftChatMember() {
return leftChatParticipant; return leftChatMember;
} }
public void setLeftChatParticipant(User leftChatParticipant) { public void setLeftChatMember(User leftChatMember) {
this.leftChatParticipant = leftChatParticipant; this.leftChatMember = leftChatMember;
} }
public String getNewChatTitle() { public String getNewChatTitle() {
@ -438,12 +466,14 @@ public class Message implements IBotApiObject {
@Override @Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException { public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject(); gen.writeStartObject();
gen.writeNumberField(MESSAGEID_FIELD, messageId); gen.writeNumberField(MESSAGEID_FIELD, messageId);
if (from != null) {
gen.writeObjectField(FROM_FIELD, from); gen.writeObjectField(FROM_FIELD, from);
}
if (date != null) {
gen.writeNumberField(DATE_FIELD, date); gen.writeNumberField(DATE_FIELD, date);
}
gen.writeObjectField(CHAT_FIELD, chat); gen.writeObjectField(CHAT_FIELD, chat);
if (forwardFrom != null) { if (forwardFrom != null) {
gen.writeObjectField(FORWARDFROM_FIELD, forwardFrom); gen.writeObjectField(FORWARDFROM_FIELD, forwardFrom);
} }
@ -478,14 +508,17 @@ public class Message implements IBotApiObject {
if (location != null) { if (location != null) {
gen.writeObjectField(LOCATION_FIELD, location); gen.writeObjectField(LOCATION_FIELD, location);
} }
if (venue != null) {
gen.writeObjectField(VENUE_FIELD, venue);
}
if (voice != null) { if (voice != null) {
gen.writeObjectField(VOICE_FIELD, voice); gen.writeObjectField(VOICE_FIELD, voice);
} }
if (newChatParticipant != null) { if (newChatMember != null) {
gen.writeObjectField(NEWCHATPARTICIPANT_FIELD, newChatParticipant); gen.writeObjectField(NEWCHATMEMBER_FIELD, newChatMember);
} }
if (leftChatParticipant != null) { if (leftChatMember != null) {
gen.writeObjectField(LEFTCHATPARTICIPANT_FIELD, leftChatParticipant); gen.writeObjectField(LEFTCHATMEMBER_FIELD, leftChatMember);
} }
if (replyToMessage != null) { if (replyToMessage != null) {
gen.writeObjectField(REPLYTOMESSAGE_FIELD, replyToMessage); gen.writeObjectField(REPLYTOMESSAGE_FIELD, replyToMessage);
@ -544,8 +577,9 @@ public class Message implements IBotApiObject {
", video=" + video + ", video=" + video +
", contact=" + contact + ", contact=" + contact +
", location=" + location + ", location=" + location +
", newChatParticipant=" + newChatParticipant + ", venue=" + venue +
", leftChatParticipant=" + leftChatParticipant + ", newChatMember=" + newChatMember +
", leftChatMember=" + leftChatMember +
", newChatTitle='" + newChatTitle + '\'' + ", newChatTitle='" + newChatTitle + '\'' +
", newChatPhoto=" + newChatPhoto + ", newChatPhoto=" + newChatPhoto +
", deleteChatPhoto=" + deleteChatPhoto + ", deleteChatPhoto=" + deleteChatPhoto +

View File

@ -0,0 +1,105 @@
package org.telegram.telegrambots.api.objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief This object represents one special entity in a text message. For example, hashtags,
* usernames, URL.
* @date 20 of June of 2015
*/
public class MessageEntity implements IBotApiObject {
private static final String TYPE_FIELD = "type";
private static final String OFFSET_FIELD = "offset";
private static final String LENGTH_FIELD = "length";
private static final String URL_FIELD = "url";
@JsonProperty(TYPE_FIELD)
/**
* Type of the entity. One of
* mention (@username),
* hashtag,
* bot_command,
* url,
* email,
* bold (bold text),
* italic (italic text),
* code (monowidth string),
* pre (monowidth block),
* text_link (for clickable text URLs)
*/
private String type;
@JsonProperty(OFFSET_FIELD)
private Integer offset; ///< Offset in UTF-16 code units to the start of the entity
@JsonProperty(LENGTH_FIELD)
private Integer length; ///< Length of the entity in UTF-16 code units
@JsonProperty(URL_FIELD)
private String url; ///< Optional. For text_link only, url that will be opened after user taps on the text
public MessageEntity() {
super();
}
public MessageEntity(JSONObject jsonObject) {
super();
this.type = jsonObject.getString(TYPE_FIELD);
this.offset = jsonObject.getInt(OFFSET_FIELD);
this.length = jsonObject.getInt(LENGTH_FIELD);
if (EntityType.TEXTLINK.equals(type)) {
this.url = jsonObject.getString(URL_FIELD);
}
}
public String getType() {
return type;
}
public Integer getOffset() {
return offset;
}
public Integer getLength() {
return length;
}
public String getUrl() {
return url;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeNumberField(OFFSET_FIELD, offset);
gen.writeNumberField(LENGTH_FIELD, length);
if (url != null && EntityType.TEXTLINK.equals(type)) {
gen.writeStringField(URL_FIELD, url);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "PhotoSize{" +
"type='" + type + '\'' +
", offset=" + offset +
", length=" + length +
", url=" + url +
'}';
}
}

View File

@ -18,19 +18,19 @@ import java.io.IOException;
*/ */
public class PhotoSize implements IBotApiObject { public class PhotoSize implements IBotApiObject {
public static final String FILEID_FIELD = "file_id"; private static final String FILEID_FIELD = "file_id";
private static final String WIDTH_FIELD = "width";
private static final String HEIGHT_FIELD = "height";
private static final String FILESIZE_FIELD = "file_size";
private static final String FILEPATH_FIELD = "file_path";
@JsonProperty(FILEID_FIELD) @JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file private String fileId; ///< Unique identifier for this file
public static final String WIDTH_FIELD = "width";
@JsonProperty(WIDTH_FIELD) @JsonProperty(WIDTH_FIELD)
private Integer width; ///< Photo width private Integer width; ///< Photo width
public static final String HEIGHT_FIELD = "height";
@JsonProperty(HEIGHT_FIELD) @JsonProperty(HEIGHT_FIELD)
private Integer height; ///< Photo height private Integer height; ///< Photo height
public static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILESIZE_FIELD) @JsonProperty(FILESIZE_FIELD)
private Integer fileSize; ///< Optional. File size private Integer fileSize; ///< Optional. File size
private static final String FILEPATH_FIELD = "file_path";
@JsonProperty(FILEPATH_FIELD) @JsonProperty(FILEPATH_FIELD)
private String filePath; ///< Undocumented field. Optional. Can contain the path to download the file direclty without calling to getFile private String filePath; ///< Undocumented field. Optional. Can contain the path to download the file direclty without calling to getFile

View File

@ -18,11 +18,11 @@ import java.io.IOException;
*/ */
public class Sticker implements IBotApiObject { public class Sticker implements IBotApiObject {
public static final String FILEID_FIELD = "file_id"; private static final String FILEID_FIELD = "file_id";
public static final String WIDTH_FIELD = "width"; private static final String WIDTH_FIELD = "width";
public static final String HEIGHT_FIELD = "height"; private static final String HEIGHT_FIELD = "height";
public static final String THUMB_FIELD = "thumb"; private static final String THUMB_FIELD = "thumb";
public static final String FILESIZE_FIELD = "file_size"; private static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILEID_FIELD) @JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file private String fileId; ///< Unique identifier for this file
@JsonProperty(WIDTH_FIELD) @JsonProperty(WIDTH_FIELD)

View File

@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject; import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import org.telegram.telegrambots.api.objects.inlinequery.ChosenInlineQuery;
import org.telegram.telegrambots.api.objects.inlinequery.InlineQuery;
import java.io.IOException; import java.io.IOException;
@ -18,10 +20,11 @@ import java.io.IOException;
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class Update implements IBotApiObject { public class Update implements IBotApiObject {
public static final String UPDATEID_FIELD = "update_id"; private static final String UPDATEID_FIELD = "update_id";
public static final String MESSAGE_FIELD = "message"; private static final String MESSAGE_FIELD = "message";
public static final String INLINEQUERY_FIELD = "inline_query"; private static final String INLINEQUERY_FIELD = "inline_query";
public static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result"; private static final String CHOSENINLINEQUERY_FIELD = "chosen_inline_result";
private static final String CALLBACKQUERY_FIELD = "callback_query";
@JsonProperty(UPDATEID_FIELD) @JsonProperty(UPDATEID_FIELD)
private Integer updateId; private Integer updateId;
@JsonProperty(MESSAGE_FIELD) @JsonProperty(MESSAGE_FIELD)
@ -30,10 +33,8 @@ public class Update implements IBotApiObject {
private InlineQuery inlineQuery; ///< Optional. New incoming inline query private InlineQuery inlineQuery; ///< Optional. New incoming inline query
@JsonProperty(CHOSENINLINEQUERY_FIELD) @JsonProperty(CHOSENINLINEQUERY_FIELD)
private ChosenInlineQuery chosenInlineQuery; ///< Optional. The result of a inline query that was chosen by a user and sent to their chat partner private ChosenInlineQuery chosenInlineQuery; ///< Optional. The result of a inline query that was chosen by a user and sent to their chat partner
@JsonProperty(CALLBACKQUERY_FIELD)
/* private CallbackQuery callbackQuery; ///< Optional. New incoming callback query
ChosenInlineResult
*/
public Update() { public Update() {
super(); super();
@ -51,6 +52,9 @@ public class Update implements IBotApiObject {
if (jsonObject.has(CHOSENINLINEQUERY_FIELD)) { if (jsonObject.has(CHOSENINLINEQUERY_FIELD)) {
this.chosenInlineQuery = new ChosenInlineQuery(jsonObject.getJSONObject(CHOSENINLINEQUERY_FIELD)); this.chosenInlineQuery = new ChosenInlineQuery(jsonObject.getJSONObject(CHOSENINLINEQUERY_FIELD));
} }
if (jsonObject.has(CALLBACKQUERY_FIELD)) {
callbackQuery = new CallbackQuery(jsonObject.getJSONObject(CALLBACKQUERY_FIELD));
}
} }
public Integer getUpdateId() { public Integer getUpdateId() {
@ -69,6 +73,10 @@ public class Update implements IBotApiObject {
return chosenInlineQuery; return chosenInlineQuery;
} }
public CallbackQuery getCallbackQuery() {
return callbackQuery;
}
public boolean hasMessage() { public boolean hasMessage() {
return message != null; return message != null;
} }
@ -81,6 +89,10 @@ public class Update implements IBotApiObject {
return chosenInlineQuery != null; return chosenInlineQuery != null;
} }
public boolean hasCallbackQuery() {
return callbackQuery != null;
}
@Override @Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException { public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject(); gen.writeStartObject();
@ -94,6 +106,9 @@ public class Update implements IBotApiObject {
if (chosenInlineQuery != null) { if (chosenInlineQuery != null) {
gen.writeObjectField(CHOSENINLINEQUERY_FIELD, chosenInlineQuery); gen.writeObjectField(CHOSENINLINEQUERY_FIELD, chosenInlineQuery);
} }
if (callbackQuery != null) {
gen.writeObjectField(CALLBACKQUERY_FIELD, callbackQuery);
}
gen.writeEndObject(); gen.writeEndObject();
gen.flush(); gen.flush();
} }

View File

@ -18,10 +18,10 @@ import java.io.IOException;
*/ */
public class User implements IBotApiObject { public class User implements IBotApiObject {
public static final String ID_FIELD = "id"; private static final String ID_FIELD = "id";
public static final String FIRSTNAME_FIELD = "first_name"; private static final String FIRSTNAME_FIELD = "first_name";
public static final String LASTNAME_FIELD = "last_name"; private static final String LASTNAME_FIELD = "last_name";
public static final String USERNAME_FIELD = "username"; private static final String USERNAME_FIELD = "username";
@JsonProperty(ID_FIELD) @JsonProperty(ID_FIELD)
private Integer id; ///< Unique identifier for this user or bot private Integer id; ///< Unique identifier for this user or bot
@JsonProperty(FIRSTNAME_FIELD) @JsonProperty(FIRSTNAME_FIELD)

View File

@ -21,8 +21,8 @@ import java.util.List;
*/ */
public class UserProfilePhotos implements IBotApiObject { public class UserProfilePhotos implements IBotApiObject {
public static final String TOTALCOUNT_FIELD = "total_count"; private static final String TOTALCOUNT_FIELD = "total_count";
public static final String PHOTOS_FIELD = "photos"; private static final String PHOTOS_FIELD = "photos";
@JsonProperty(TOTALCOUNT_FIELD) @JsonProperty(TOTALCOUNT_FIELD)
private Integer totalCount; ///< Total number of profile pictures the target user has private Integer totalCount; ///< Total number of profile pictures the target user has
@JsonProperty(PHOTOS_FIELD) @JsonProperty(PHOTOS_FIELD)

View File

@ -0,0 +1,92 @@
package org.telegram.telegrambots.api.objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief This object represents a venue.
* @date 10 of April of 2016
*/
public class Venue implements IBotApiObject {
private static final String LOCATION_FIELD = "location";
private static final String TITLE_FIELD = "title";
private static final String ADDRESS_FIELD = "address";
private static final String FOURSQUARE_ID_FIELD = "foursquare_id";
@JsonProperty(LOCATION_FIELD)
private Location location; ///< Venue location
@JsonProperty(TITLE_FIELD)
private String title; ///< Name of the venue
@JsonProperty(ADDRESS_FIELD)
private String address; ///< Address of the venue
@JsonProperty(FOURSQUARE_ID_FIELD)
private String foursquareId; ///< Optional. Foursquare identifier of the venue
public Venue() {
super();
}
public Venue(JSONObject jsonObject) {
super();
location = new Location(jsonObject.getJSONObject(LOCATION_FIELD));
title = jsonObject.getString(TITLE_FIELD);
address = jsonObject.getString(ADDRESS_FIELD);
if (jsonObject.has(FOURSQUARE_ID_FIELD)) {
foursquareId = jsonObject.getString(FOURSQUARE_ID_FIELD);
}
}
public Location getLocation() {
return location;
}
public String getTitle() {
return title;
}
public String getAddress() {
return address;
}
public String getFoursquareId() {
return foursquareId;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeObjectField(LOCATION_FIELD, location);
gen.writeStringField(TITLE_FIELD, title);
gen.writeStringField(ADDRESS_FIELD, address);
if (foursquareId != null) {
gen.writeStringField(FOURSQUARE_ID_FIELD, foursquareId);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "Venue{" +
"location=" + location +
", title=" + title +
", address=" + address +
", foursquareId=" + foursquareId +
'}';
}
}

View File

@ -18,13 +18,13 @@ import java.io.IOException;
*/ */
public class Video implements IBotApiObject { public class Video implements IBotApiObject {
public static final String FILEID_FIELD = "file_id"; private static final String FILEID_FIELD = "file_id";
public static final String WIDTH_FIELD = "width"; private static final String WIDTH_FIELD = "width";
public static final String HEIGHT_FIELD = "height"; private static final String HEIGHT_FIELD = "height";
public static final String DURATION_FIELD = "duration"; private static final String DURATION_FIELD = "duration";
public static final String THUMB_FIELD = "thumb"; private static final String THUMB_FIELD = "thumb";
public static final String MIMETYPE_FIELD = "mime_type"; private static final String MIMETYPE_FIELD = "mime_type";
public static final String FILESIZE_FIELD = "file_size"; private static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILEID_FIELD) @JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file private String fileId; ///< Unique identifier for this file
@JsonProperty(WIDTH_FIELD) @JsonProperty(WIDTH_FIELD)

View File

@ -17,10 +17,10 @@ import java.io.IOException;
* @date 16 of July of 2015 * @date 16 of July of 2015
*/ */
public class Voice implements IBotApiObject { public class Voice implements IBotApiObject {
public static final String FILEID_FIELD = "file_id"; private static final String FILEID_FIELD = "file_id";
public static final String DURATION_FIELD = "duration"; private static final String DURATION_FIELD = "duration";
public static final String MIMETYPE_FIELD = "mime_type"; private static final String MIMETYPE_FIELD = "mime_type";
public static final String FILESIZE_FIELD = "file_size"; private static final String FILESIZE_FIELD = "file_size";
@JsonProperty(FILEID_FIELD) @JsonProperty(FILEID_FIELD)
private String fileId; ///< Unique identifier for this file private String fileId; ///< Unique identifier for this file
@JsonProperty(DURATION_FIELD) @JsonProperty(DURATION_FIELD)

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.inlinequery;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -7,24 +7,39 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject; import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import org.telegram.telegrambots.api.objects.Location;
import org.telegram.telegrambots.api.objects.User;
import java.io.IOException; import java.io.IOException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief This object represents a result of an inline query that was chosen by the user and sent to their chat partner. * @brief Represents a result of an inline query that was chosen by the user and sent to their chat
* partner.
* @date 01 of January of 2016 * @date 01 of January of 2016
*/ */
public class ChosenInlineQuery implements IBotApiObject { public class ChosenInlineQuery implements IBotApiObject {
public static final String RESULTID_FIELD = "result_id"; private static final String RESULTID_FIELD = "result_id";
public static final String FROM_FIELD = "from"; private static final String FROM_FIELD = "from";
public static final String QUERY_FIELD = "query"; private static final String LOCATION_FIELD = "location";
private static final String INLINE_MESSAGE_ID_FIELD = "inline_message_id";
private static final String QUERY_FIELD = "query";
@JsonProperty(RESULTID_FIELD) @JsonProperty(RESULTID_FIELD)
private String resultId; ///< The unique identifier for the result that was chosen. private String resultId; ///< The unique identifier for the result that was chosen.
@JsonProperty(FROM_FIELD) @JsonProperty(FROM_FIELD)
private User from; ///< The user that chose the result. private User from; ///< The user that chose the result.
@JsonProperty(LOCATION_FIELD)
private Location location; ///< Optional. Sender location, only for bots that require user location
@JsonProperty(INLINE_MESSAGE_ID_FIELD)
/**
* Optional.
* Identifier of the sent inline message.
* Available only if there is an inline keyboard attached to the message.
* Will be also received in callback queries and can be used to edit the message.
*/
private String inlineMessageId;
@JsonProperty(QUERY_FIELD) @JsonProperty(QUERY_FIELD)
private String query; ///< The query that was used to obtain the result. private String query; ///< The query that was used to obtain the result.
@ -36,6 +51,12 @@ public class ChosenInlineQuery implements IBotApiObject {
super(); super();
this.resultId = jsonObject.getString(RESULTID_FIELD); this.resultId = jsonObject.getString(RESULTID_FIELD);
this.from = new User(jsonObject.getJSONObject(FROM_FIELD)); this.from = new User(jsonObject.getJSONObject(FROM_FIELD));
if (jsonObject.has(LOCATION_FIELD)) {
location = new Location(jsonObject.getJSONObject(LOCATION_FIELD));
}
if (jsonObject.has(INLINE_MESSAGE_ID_FIELD)) {
inlineMessageId = jsonObject.getString(INLINE_MESSAGE_ID_FIELD);
}
this.query = jsonObject.getString(QUERY_FIELD); this.query = jsonObject.getString(QUERY_FIELD);
} }
@ -51,11 +72,25 @@ public class ChosenInlineQuery implements IBotApiObject {
return query; return query;
} }
public Location getLocation() {
return location;
}
public String getInlineMessageId() {
return inlineMessageId;
}
@Override @Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException { public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject(); gen.writeStartObject();
gen.writeStringField(RESULTID_FIELD, resultId); gen.writeStringField(RESULTID_FIELD, resultId);
gen.writeObjectField(FROM_FIELD, from); gen.writeObjectField(FROM_FIELD, from);
if (location != null) {
gen.writeObjectField(LOCATION_FIELD, location);
}
if (inlineMessageId != null) {
gen.writeStringField(INLINE_MESSAGE_ID_FIELD, inlineMessageId);
}
gen.writeStringField(QUERY_FIELD, query); gen.writeStringField(QUERY_FIELD, query);
gen.writeEndObject(); gen.writeEndObject();
gen.flush(); gen.flush();
@ -71,6 +106,8 @@ public class ChosenInlineQuery implements IBotApiObject {
return "ChosenInlineQuery{" + return "ChosenInlineQuery{" +
"resultId='" + resultId + '\'' + "resultId='" + resultId + '\'' +
", from=" + from + ", from=" + from +
", location=" + location +
", inlineMessageId=" + inlineMessageId +
", query='" + query + '\'' + ", query='" + query + '\'' +
'}'; '}';
} }

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.inlinequery;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -7,25 +7,30 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.interfaces.IBotApiObject; import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import org.telegram.telegrambots.api.objects.Location;
import org.telegram.telegrambots.api.objects.User;
import java.io.IOException; import java.io.IOException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief This object represents an incoming inline query. * @brief This object represents an incoming inline query. When the user sends an empty query, your
* When the user sends an empty query, your bot could return some default or trending results. * bot could return some default or trending results.
* @date 01 of January of 2016 * @date 01 of January of 2016
*/ */
public class InlineQuery implements IBotApiObject { public class InlineQuery implements IBotApiObject {
public static final String ID_FIELD = "id"; private static final String ID_FIELD = "id";
public static final String FROM_FIELD = "from"; private static final String FROM_FIELD = "from";
public static final String QUERY_FIELD = "query"; private static final String LOCATION_FIELD = "location";
public static final String OFFSET_FIELD = "offset"; private static final String QUERY_FIELD = "query";
private static final String OFFSET_FIELD = "offset";
@JsonProperty(ID_FIELD) @JsonProperty(ID_FIELD)
private String id; ///< Unique identifier for this query private String id; ///< Unique identifier for this query
@JsonProperty(FROM_FIELD) @JsonProperty(FROM_FIELD)
private User from; ///< Sender private User from; ///< Sender
@JsonProperty(LOCATION_FIELD)
private Location location; ///< Optional. Sender location, only for bots that request user location
@JsonProperty(QUERY_FIELD) @JsonProperty(QUERY_FIELD)
private String query; ///< Text of the query private String query; ///< Text of the query
@JsonProperty(OFFSET_FIELD) @JsonProperty(OFFSET_FIELD)
@ -39,6 +44,9 @@ public class InlineQuery implements IBotApiObject {
super(); super();
this.id = jsonObject.getString(ID_FIELD); this.id = jsonObject.getString(ID_FIELD);
this.from = new User(jsonObject.getJSONObject(FROM_FIELD)); this.from = new User(jsonObject.getJSONObject(FROM_FIELD));
if (jsonObject.has(LOCATION_FIELD)) {
location = new Location(jsonObject.getJSONObject(LOCATION_FIELD));
}
this.query = jsonObject.getString(QUERY_FIELD); this.query = jsonObject.getString(QUERY_FIELD);
this.offset = jsonObject.getString(OFFSET_FIELD); this.offset = jsonObject.getString(OFFSET_FIELD);
} }
@ -48,6 +56,9 @@ public class InlineQuery implements IBotApiObject {
gen.writeStartObject(); gen.writeStartObject();
gen.writeStringField(ID_FIELD, id); gen.writeStringField(ID_FIELD, id);
gen.writeObjectField(FROM_FIELD, from); gen.writeObjectField(FROM_FIELD, from);
if (location != null) {
gen.writeObjectField(LOCATION_FIELD, location);
}
gen.writeStringField(QUERY_FIELD, query); gen.writeStringField(QUERY_FIELD, query);
gen.writeStringField(OFFSET_FIELD, offset); gen.writeStringField(OFFSET_FIELD, offset);
gen.writeEndObject(); gen.writeEndObject();
@ -62,6 +73,10 @@ public class InlineQuery implements IBotApiObject {
return from; return from;
} }
public Location getLocation() {
return location;
}
public String getQuery() { public String getQuery() {
return query; return query;
} }
@ -80,6 +95,7 @@ public class InlineQuery implements IBotApiObject {
return "InlineQuery{" + return "InlineQuery{" +
"id='" + id + '\'' + "id='" + id + '\'' +
", from=" + from + ", from=" + from +
", location=" + location +
", query='" + query + '\'' + ", query='" + query + '\'' +
", offset='" + offset + '\'' + ", offset='" + offset + '\'' +
'}'; '}';

View File

@ -0,0 +1,96 @@
package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents the content of a contact message to be sent as the result of an inline query
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InputContactMessageContent implements InputMessageContent {
private static final String PHONE_NUMBER_FIELD = "phone_number";
private static final String FIRST_NAME_FIELD = "first_name";
private static final String LAST_NAME_FIELD = "last_name";
@JsonProperty(PHONE_NUMBER_FIELD)
private String phoneNumber; ///< Contact's phone number
@JsonProperty(FIRST_NAME_FIELD)
private String firstName; ///< Contact's first name
@JsonProperty(LAST_NAME_FIELD)
private String lastName; ///< Optional. Contact's last name
public InputContactMessageContent() {
super();
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(PHONE_NUMBER_FIELD, phoneNumber);
jsonObject.put(FIRST_NAME_FIELD, firstName);
if (lastName != null) {
jsonObject.put(LAST_NAME_FIELD, lastName);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(PHONE_NUMBER_FIELD, phoneNumber);
gen.writeStringField(FIRST_NAME_FIELD, firstName);
if (lastName != null) {
gen.writeStringField(LAST_NAME_FIELD, lastName);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InputContactMessageContent{" +
"phoneNumber='" + phoneNumber + '\'' +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
'}';
}
}

View File

@ -0,0 +1,78 @@
package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents the content of a location message to be sent as the result of an inline query.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InputLocationMessageContent implements InputMessageContent {
private static final String LATITUDE_FIELD = "latitude";
private static final String LONGITUDE_FIELD = "longitude";
@JsonProperty(LATITUDE_FIELD)
private Float latitude; ///< Latitude of the location in degrees
@JsonProperty(LONGITUDE_FIELD)
private Float longitude; ///< Longitude of the location in degrees
public InputLocationMessageContent() {
super();
}
public Float getLatitude() {
return latitude;
}
public void setLatitude(Float latitude) {
this.latitude = latitude;
}
public Float getLongitude() {
return longitude;
}
public void setLongitude(Float longitude) {
this.longitude = longitude;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(LATITUDE_FIELD, latitude);
jsonObject.put(LONGITUDE_FIELD, longitude);
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeNumberField(LATITUDE_FIELD, latitude);
gen.writeNumberField(LONGITUDE_FIELD, longitude);
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InputLocationMessageContent{" +
"latitude='" + latitude + '\'' +
", longitude='" + longitude + '\'' +
'}';
}
}

View File

@ -0,0 +1,14 @@
package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import org.telegram.telegrambots.api.interfaces.IToJson;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief This object represents the content of a message to be sent as a result of an inline
* query.
* @date 10 of April of 2016
*/
public interface InputMessageContent extends IBotApiObject, IToJson {
}

View File

@ -0,0 +1,116 @@
package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.methods.ParseMode;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents the content of a text message to be sent as the result of an inline query.
* @date 10 of April of 2016
*/
public class InputTextMessageContent implements InputMessageContent {
private static final String MESSAGETEXT_FIELD = "message_text";
private static final String PARSEMODE_FIELD = "parse_mode";
private static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
@JsonProperty(MESSAGETEXT_FIELD)
private String messageText; ///< Text of a message to be sent, 1-4096 characters
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
@JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
public InputTextMessageContent() {
super();
}
public String getMessageText() {
return messageText;
}
public void setMessageText(String messageText) {
this.messageText = messageText;
}
public String getParseMode() {
return parseMode;
}
public void enableMarkdown(boolean enable) {
if (enable) {
this.parseMode = ParseMode.MARKDOWN;
} else {
this.parseMode = null;
}
}
public void enableHtml(boolean enable) {
if (enable) {
this.parseMode = ParseMode.HTML;
} else {
this.parseMode = null;
}
}
public Boolean getDisableWebPagePreview() {
return disableWebPagePreview;
}
public void disableWebPagePreview() {
disableWebPagePreview = true;
}
public void enableWebPagePreview() {
disableWebPagePreview = null;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(MESSAGETEXT_FIELD, this.messageText);
if (parseMode != null) {
jsonObject.put(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(MESSAGETEXT_FIELD, messageText);
if (parseMode != null) {
gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InputTextMessageContent{" +
", messageText='" + messageText + '\'' +
", parseMode='" + parseMode + '\'' +
", disableWebPagePreview=" + disableWebPagePreview +
'}';
}
}

View File

@ -0,0 +1,124 @@
package org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents the content of a venue message to be sent as the result of an inline query.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InputVenueMessageContent implements InputMessageContent {
private static final String LATITUDE_FIELD = "latitude";
private static final String LONGITUDE_FIELD = "longitude";
private static final String TITLE_FIELD = "title";
private static final String ADDRESS_FIELD = "address";
private static final String FOURSQUARE_ID_FIELD = "foursquare_id";
@JsonProperty(LATITUDE_FIELD)
private Float latitude; ///< Latitude of the venue in degrees
@JsonProperty(LONGITUDE_FIELD)
private Float longitude; ///< Longitude of the venue in degrees
@JsonProperty(TITLE_FIELD)
private String title; ///< Name of the venue
@JsonProperty(ADDRESS_FIELD)
private String address; ///< Address of the venue
@JsonProperty(FOURSQUARE_ID_FIELD)
private String foursquareId; ///< Optional. Foursquare identifier of the venue, if known
public InputVenueMessageContent() {
super();
}
public Float getLatitude() {
return latitude;
}
public void setLatitude(Float latitude) {
this.latitude = latitude;
}
public Float getLongitude() {
return longitude;
}
public void setLongitude(Float longitude) {
this.longitude = longitude;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getFoursquareId() {
return foursquareId;
}
public void setFoursquareId(String foursquareId) {
this.foursquareId = foursquareId;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(LATITUDE_FIELD, latitude);
jsonObject.put(LONGITUDE_FIELD, longitude);
jsonObject.put(TITLE_FIELD, title);
jsonObject.put(ADDRESS_FIELD, address);
if (foursquareId != null) {
jsonObject.put(FOURSQUARE_ID_FIELD, foursquareId);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeNumberField(LATITUDE_FIELD, latitude);
gen.writeNumberField(LONGITUDE_FIELD, longitude);
gen.writeStringField(TITLE_FIELD, title);
gen.writeStringField(ADDRESS_FIELD, address);
if (foursquareId != null) {
gen.writeStringField(FOURSQUARE_ID_FIELD, foursquareId);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InputVenueMessageContent{" +
"latitude='" + latitude + '\'' +
", longitude='" + longitude + '\'' +
", title='" + title + '\'' +
", address='" + address + '\'' +
", foursquareId='" + foursquareId + '\'' +
'}';
}
}

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.inlinequery.result;
import org.telegram.telegrambots.api.interfaces.IBotApiObject; import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import org.telegram.telegrambots.api.interfaces.IToJson; import org.telegram.telegrambots.api.interfaces.IToJson;

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException; import java.io.IOException;
@ -17,40 +19,37 @@ import java.io.IOException;
*/ */
public class InlineQueryResultArticle implements InlineQueryResult { public class InlineQueryResultArticle implements InlineQueryResult {
public static final String TYPE_FIELD = "type"; private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD) @JsonProperty(TYPE_FIELD)
private final String type = "article"; ///< Type of the result, must be article private static final String type = "article"; ///< Type of the result, must be article
public static final String ID_FIELD = "id"; private static final String ID_FIELD = "id";
private static final String TITLE_FIELD = "title";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String URL_FIELD = "url";
private static final String HIDEURL_FIELD = "hide_url";
private static final String DESCRIPTION_FIELD = "description";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
@JsonProperty(ID_FIELD) @JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result private String id; ///< Unique identifier of this result, 1-64 bytes
public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD) @JsonProperty(TITLE_FIELD)
private String title; ///< Title of the result private String title; ///< Title of the result
public static final String MESSAGETEXT_FIELD = "message_text"; @JsonProperty(INPUTMESSAGECONTENT_FIELD)
@JsonProperty(MESSAGETEXT_FIELD) private InputMessageContent inputMessageContent; ///< Content of the message to be sent
private String messageText; ///< Text of a message to be sent, 1-4096 characters @JsonProperty(REPLY_MARKUP_FIELD)
public static final String PARSEMODE_FIELD = "parse_mode"; private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
@JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
public static final String URL_FIELD = "url";
@JsonProperty(URL_FIELD) @JsonProperty(URL_FIELD)
private String url; ///< Optional. URL of the result private String url; ///< Optional. URL of the result
public static final String HIDEURL_FIELD = "hide_url";
@JsonProperty(HIDEURL_FIELD) @JsonProperty(HIDEURL_FIELD)
private Boolean hideUrl; ///< Optional. Pass True, if you don't want the URL to be shown in the message private Boolean hideUrl; ///< Optional. Pass True, if you don't want the URL to be shown in the message
public static final String DESCRIPTION_FIELD = "description";
@JsonProperty(DESCRIPTION_FIELD) @JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result private String description; ///< Optional. Short description of the result
public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD) @JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. Url of the thumbnail for the result private String thumbUrl; ///< Optional. Url of the thumbnail for the result
public static final String THUMBWIDTH_FIELD = "thumb_width";
@JsonProperty(THUMBWIDTH_FIELD) @JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width private Integer thumbWidth; ///< Optional. Thumbnail width
public static final String THUMBHEIGHT_FIELD = "thumb_height";
@JsonProperty(THUMBHEIGHT_FIELD) @JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height private Integer thumbHeight; ///< Optional. Thumbnail height
@ -74,44 +73,20 @@ public class InlineQueryResultArticle implements InlineQueryResult {
this.title = title; this.title = title;
} }
public String getMessageText() { public InputMessageContent getInputMessageContent() {
return messageText; return inputMessageContent;
} }
public void setMessageText(String messageText) { public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.messageText = messageText; this.inputMessageContent = inputMessageContent;
} }
public String getParseMode() { public InlineKeyboardMarkup getReplyMarkup() {
return parseMode; return replyMarkup;
} }
public void setParseMode(String parseMode) { public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.parseMode = parseMode; this.replyMarkup = replyMarkup;
}
public void enableMarkdown(boolean enable) {
if (enable) {
this.parseMode = "Markdown";
} else {
this.parseMode = null;
}
}
public void enableHtml(boolean enable) {
if (enable) {
this.parseMode = "html";
} else {
this.parseMode = null;
}
}
public Boolean getDisableWebPagePreview() {
return disableWebPagePreview;
}
public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
this.disableWebPagePreview = disableWebPagePreview;
} }
public String getUrl() { public String getUrl() {
@ -169,12 +144,9 @@ public class InlineQueryResultArticle implements InlineQueryResult {
jsonObject.put(TYPE_FIELD, this.type); jsonObject.put(TYPE_FIELD, this.type);
jsonObject.put(ID_FIELD, this.id); jsonObject.put(ID_FIELD, this.id);
jsonObject.put(TITLE_FIELD, this.title); jsonObject.put(TITLE_FIELD, this.title);
jsonObject.put(MESSAGETEXT_FIELD, this.messageText); jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
if (parseMode != null) { if (replyMarkup != null) {
jsonObject.put(PARSEMODE_FIELD, this.parseMode); jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (disableWebPagePreview != null) {
jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
} }
if (url != null) { if (url != null) {
jsonObject.put(URL_FIELD, this.url); jsonObject.put(URL_FIELD, this.url);
@ -204,13 +176,9 @@ public class InlineQueryResultArticle implements InlineQueryResult {
gen.writeStringField(TYPE_FIELD, type); gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id); gen.writeStringField(ID_FIELD, id);
gen.writeStringField(TITLE_FIELD, title); gen.writeStringField(TITLE_FIELD, title);
gen.writeStringField(MESSAGETEXT_FIELD, messageText); gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
if (replyMarkup != null) {
if (parseMode != null) { gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
} }
if (url != null) { if (url != null) {
gen.writeStringField(URL_FIELD, this.url); gen.writeStringField(URL_FIELD, this.url);
@ -246,9 +214,8 @@ public class InlineQueryResultArticle implements InlineQueryResult {
"type='" + type + '\'' + "type='" + type + '\'' +
", id='" + id + '\'' + ", id='" + id + '\'' +
", title='" + title + '\'' + ", title='" + title + '\'' +
", messageText='" + messageText + '\'' + ", inputMessageContent='" + inputMessageContent + '\'' +
", parseMode='" + parseMode + '\'' + ", replyMarkup='" + replyMarkup + '\'' +
", disableWebPagePreview=" + disableWebPagePreview +
", url='" + url + '\'' + ", url='" + url + '\'' +
", hideUrl=" + hideUrl + ", hideUrl=" + hideUrl +
", description='" + description + '\'' + ", description='" + description + '\'' +

View File

@ -0,0 +1,180 @@
package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to an mp3 audio file. By default, this audio file will be sent by the
* user. Alternatively, you can use input_message_content to send a message with the specified
* content instead of the audio.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultAudio implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "audio"; ///< Type of the result, must be "audio"
private static final String ID_FIELD = "id";
private static final String AUDIOURL_FIELD = "audio_url";
private static final String TITLE_FIELD = "title";
private static final String PERFORMER_FIELD = "performer";
private static final String AUDIO_DURATION_FIELD = "audio_duration";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result
@JsonProperty(AUDIOURL_FIELD)
private String audioUrl; ///< A valid URL for the audio file
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(PERFORMER_FIELD)
private String performer; ///< Optional. Performer
@JsonProperty(AUDIO_DURATION_FIELD)
private Integer audioDuration; ///< Optional. Audio duration in seconds
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the audio
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getAudioUrl() {
return audioUrl;
}
public void setAudioUrl(String audioUrl) {
this.audioUrl = audioUrl;
}
public String getPerformer() {
return performer;
}
public void setPerformer(String performer) {
this.performer = performer;
}
public Integer getAudioDuration() {
return audioDuration;
}
public void setAudioDuration(Integer audioDuration) {
this.audioDuration = audioDuration;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, id);
jsonObject.put(AUDIOURL_FIELD, audioUrl);
if (title != null) {
jsonObject.put(TITLE_FIELD, title);
}
if (performer != null) {
jsonObject.put(PERFORMER_FIELD, performer);
}
if (audioDuration != null) {
jsonObject.put(AUDIO_DURATION_FIELD, audioDuration);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(AUDIOURL_FIELD, audioUrl);
if (title != null) {
gen.writeStringField(TITLE_FIELD, title);
}
if (performer != null) {
gen.writeStringField(PERFORMER_FIELD, performer);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (audioDuration != null) {
gen.writeNumberField(AUDIO_DURATION_FIELD, audioDuration);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultAudio{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", audioUrl='" + audioUrl + '\'' +
", title='" + title + '\'' +
", performer=" + performer +
", audioDuration=" + audioDuration +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,211 @@
package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a contact with a phone number. By default, this contact will be sent by the
* user. Alternatively, you can use input_message_content to send a message with the specified
* content instead of the contact.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultContact implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "contact"; ///< Type of the result, must be "contact"
private static final String ID_FIELD = "id";
private static final String PHONE_NUMBER_FIELD = "phone_number";
private static final String FIRST_NAME_FIELD = "first_name";
private static final String LAST_NAME_FIELD = "last_name";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(PHONE_NUMBER_FIELD)
private String phoneNumber; ///< Contact's phone number
@JsonProperty(FIRST_NAME_FIELD)
private String firstName; ///< Contact's first name
@JsonProperty(LAST_NAME_FIELD)
private String lastName; ///< Contact's last name
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public Integer getThumbWidth() {
return thumbWidth;
}
public void setThumbWidth(Integer thumbWidth) {
this.thumbWidth = thumbWidth;
}
public Integer getThumbHeight() {
return thumbHeight;
}
public void setThumbHeight(Integer thumbHeight) {
this.thumbHeight = thumbHeight;
}
public String getThumbUrl() {
return thumbUrl;
}
public void setThumbUrl(String thumbUrl) {
this.thumbUrl = thumbUrl;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, id);
jsonObject.put(PHONE_NUMBER_FIELD, phoneNumber);
jsonObject.put(FIRST_NAME_FIELD, firstName);
if (lastName != null) {
jsonObject.put(LAST_NAME_FIELD, lastName);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (thumbUrl != null) {
jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
}
if (thumbWidth != null) {
jsonObject.put(THUMBWIDTH_FIELD, this.thumbWidth);
}
if (thumbHeight != null) {
jsonObject.put(THUMBHEIGHT_FIELD, thumbHeight);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(PHONE_NUMBER_FIELD, phoneNumber);
gen.writeStringField(FIRST_NAME_FIELD, firstName);
if (lastName != null) {
gen.writeStringField(LAST_NAME_FIELD, lastName);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (thumbUrl != null) {
gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
}
if (thumbWidth != null) {
gen.writeNumberField(THUMBWIDTH_FIELD, thumbWidth);
}
if (thumbHeight != null) {
gen.writeNumberField(THUMBHEIGHT_FIELD, thumbHeight);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultContact{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", phoneNumber='" + phoneNumber + '\'' +
", firstName='" + firstName + '\'' +
", thumbHeight=" + thumbHeight +
", thumbWidth=" + thumbWidth +
", thumbUrl='" + thumbUrl + '\'' +
", lastName='" + lastName + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,244 @@
package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a file. By default, this file will be sent by the user with an
* optional caption. Alternatively, you can use input_message_content to send a message with the
* specified content instead of the file.
* @note Currently, only .PDF and .ZIP files can be sent using this method.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 01 of January of 2016
*/
public class InlineQueryResultDocument implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "document"; ///< Type of the result, must be "document"
private static final String ID_FIELD = "id";
private static final String TITLE_FIELD = "title";
private static final String DOCUMENTURL_FIELD = "document_url";
private static final String MIMETYPE_FIELD = "mime_type";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(DOCUMENTURL_FIELD)
private String documentUrl; ///< A valid URL for the file
@JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Mime type of the content of the file, either application/pdf or application/zip
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the document to be sent, 0-200 characters
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the file
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public String getDocumentUrl() {
return documentUrl;
}
public void setDocumentUrl(String documentUrl) {
this.documentUrl = documentUrl;
}
public Integer getThumbWidth() {
return thumbWidth;
}
public void setThumbWidth(Integer thumbWidth) {
this.thumbWidth = thumbWidth;
}
public Integer getThumbHeight() {
return thumbHeight;
}
public void setThumbHeight(Integer thumbHeight) {
this.thumbHeight = thumbHeight;
}
public String getThumbUrl() {
return thumbUrl;
}
public void setThumbUrl(String thumbUrl) {
this.thumbUrl = thumbUrl;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, id);
jsonObject.put(MIMETYPE_FIELD, mimeType);
jsonObject.put(TITLE_FIELD, title);
jsonObject.put(DOCUMENTURL_FIELD, documentUrl);
if (description != null) {
jsonObject.put(DESCRIPTION_FIELD, this.description);
}
if (caption != null) {
jsonObject.put(CAPTION_FIELD, caption);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (thumbUrl != null) {
jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
}
if (thumbWidth != null) {
jsonObject.put(THUMBWIDTH_FIELD, this.thumbWidth);
}
if (thumbHeight != null) {
jsonObject.put(THUMBHEIGHT_FIELD, thumbHeight);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(MIMETYPE_FIELD, mimeType);
gen.writeStringField(TITLE_FIELD, title);
gen.writeStringField(DOCUMENTURL_FIELD, documentUrl);
if (description != null) {
gen.writeStringField(DESCRIPTION_FIELD, description);
}
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, caption);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (thumbUrl != null) {
gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
}
if (thumbWidth != null) {
gen.writeNumberField(THUMBWIDTH_FIELD, thumbWidth);
}
if (thumbHeight != null) {
gen.writeNumberField(THUMBHEIGHT_FIELD, thumbHeight);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultDocument{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", mimeType='" + mimeType + '\'' +
", documentUrl='" + documentUrl + '\'' +
", thumbHeight=" + thumbHeight +
", thumbWidth=" + thumbWidth +
", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' +
", description='" + description + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -6,51 +6,51 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException; import java.io.IOException;
/** /**
* @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 by the user with optional caption. * @brief Represents a link to an animated GIF file. By default, this animated GIF file will be sent
* Alternatively, you can provide message_text to send it instead of the animation. * by the user with optional caption. Alternatively, you can use input_message_content to send a
* message with the specified content instead of the animation.
* @date 01 of January of 2016 * @date 01 of January of 2016
*/ */
public class InlineQueryResultGif implements InlineQueryResult { public class InlineQueryResultGif implements InlineQueryResult {
public static final String TYPE_FIELD = "type"; private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD) @JsonProperty(TYPE_FIELD)
private final String type = "gif"; ///< Type of the result, must be "gif" private static final String type = "gif"; ///< Type of the result, must be "gif"
public 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 GIFWIDTH_FIELD = "gif_width";
private static final String GIFHEIGHT_FIELD = "gif_height";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String TITLE_FIELD = "title";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD) @JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result private String id; ///< Unique identifier of this result, 1-64 bytes
public static final String GIFURL_FIELD = "gif_url";
@JsonProperty(GIFURL_FIELD) @JsonProperty(GIFURL_FIELD)
private String gifUrl; ///< A valid URL for the GIF file. File size must not exceed 1MB private String gifUrl; ///< A valid URL for the GIF file. File size must not exceed 1MB
public static final String GIFWIDTH_FIELD = "gif_width";
@JsonProperty(GIFWIDTH_FIELD) @JsonProperty(GIFWIDTH_FIELD)
private Integer gifWidth; ///< Optional. Width of the GIF private Integer gifWidth; ///< Optional. Width of the GIF
public static final String GIFHEIGHT_FIELD = "gif_height";
@JsonProperty(GIFHEIGHT_FIELD) @JsonProperty(GIFHEIGHT_FIELD)
private Integer gifHeight; ///< Optional. Height of the GIF private Integer gifHeight; ///< Optional. Height of the GIF
public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD) @JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of a static thumbnail for the result (jpeg or gif) private String thumbUrl; ///< Optional. URL of a static thumbnail for the result (jpeg or gif)
public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD) @JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result private String title; ///< Optional. Title for the result
public static final String CAPTION_FIELD = "caption";
@JsonProperty(CAPTION_FIELD) @JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the GIF file to be sent private String caption; ///< Optional. Caption of the GIF file to be sent
public static final String MESSAGETEXT_FIELD = "message_text"; @JsonProperty(INPUTMESSAGECONTENT_FIELD)
@JsonProperty(MESSAGETEXT_FIELD) private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the GIF animation
private String messageText; ///< Optional. Text of a message to be sent instead of the animation, 1-4096 characters @JsonProperty(REPLY_MARKUP_FIELD)
public static final String PARSEMODE_FIELD = "parse_mode"; private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
@JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
public String getType() { public String getType() {
return type; return type;
@ -72,40 +72,20 @@ public class InlineQueryResultGif implements InlineQueryResult {
this.title = title; this.title = title;
} }
public String getMessageText() { public InputMessageContent getInputMessageContent() {
return messageText; return inputMessageContent;
} }
public void setMessageText(String messageText) { public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.messageText = messageText; this.inputMessageContent = inputMessageContent;
} }
public String getParseMode() { public InlineKeyboardMarkup getReplyMarkup() {
return parseMode; return replyMarkup;
} }
public void enableMarkdown(boolean enable) { public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
if (enable) { this.replyMarkup = replyMarkup;
this.parseMode = "Markdown";
} else {
this.parseMode = null;
}
}
public void enableHtml(boolean enable) {
if (enable) {
this.parseMode = "html";
} else {
this.parseMode = null;
}
}
public Boolean getDisableWebPagePreview() {
return disableWebPagePreview;
}
public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
this.disableWebPagePreview = disableWebPagePreview;
} }
public String getGifUrl() { public String getGifUrl() {
@ -151,16 +131,9 @@ public class InlineQueryResultGif implements InlineQueryResult {
@Override @Override
public JSONObject toJson() { public JSONObject toJson() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, this.type); jsonObject.put(TYPE_FIELD, this.type);
jsonObject.put(ID_FIELD, this.id); jsonObject.put(ID_FIELD, this.id);
jsonObject.put(GIFURL_FIELD, this.gifUrl); jsonObject.put(GIFURL_FIELD, this.gifUrl);
if (parseMode != null) {
jsonObject.put(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
if (gifWidth != null) { if (gifWidth != null) {
jsonObject.put(GIFWIDTH_FIELD, this.gifWidth); jsonObject.put(GIFWIDTH_FIELD, this.gifWidth);
} }
@ -176,10 +149,12 @@ public class InlineQueryResultGif implements InlineQueryResult {
if (caption != null) { if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption); jsonObject.put(CAPTION_FIELD, this.caption);
} }
if (messageText != null) { if (replyMarkup != null) {
jsonObject.put(MESSAGETEXT_FIELD, this.messageText); jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
} }
return jsonObject; return jsonObject;
} }
@ -189,13 +164,6 @@ public class InlineQueryResultGif implements InlineQueryResult {
gen.writeStringField(TYPE_FIELD, type); gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id); gen.writeStringField(ID_FIELD, id);
gen.writeStringField(GIFURL_FIELD, this.gifUrl); gen.writeStringField(GIFURL_FIELD, this.gifUrl);
if (parseMode != null) {
gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
if (gifWidth != null) { if (gifWidth != null) {
gen.writeNumberField(GIFWIDTH_FIELD, this.gifWidth); gen.writeNumberField(GIFWIDTH_FIELD, this.gifWidth);
} }
@ -211,10 +179,12 @@ public class InlineQueryResultGif implements InlineQueryResult {
if (caption != null) { if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption); gen.writeStringField(CAPTION_FIELD, this.caption);
} }
if (messageText != null) { if (replyMarkup != null) {
gen.writeStringField(MESSAGETEXT_FIELD, this.messageText); gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
} }
gen.writeEndObject(); gen.writeEndObject();
gen.flush(); gen.flush();
} }
@ -235,9 +205,8 @@ public class InlineQueryResultGif implements InlineQueryResult {
", thumbUrl='" + thumbUrl + '\'' + ", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' + ", title='" + title + '\'' +
", caption='" + caption + '\'' + ", caption='" + caption + '\'' +
", messageText='" + messageText + '\'' + ", inputMessageContent='" + inputMessageContent + '\'' +
", parseMode='" + parseMode + '\'' + ", replyMarkup='" + replyMarkup + '\'' +
", disableWebPagePreview=" + disableWebPagePreview +
'}'; '}';
} }
} }

View File

@ -0,0 +1,207 @@
package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a location on a map. By default, the location will be sent by the user.
* Alternatively, you can use input_message_content to send a message with the specified content
* instead of the location.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultLocation implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "location"; ///< Type of the result, must be "location"
private static final String ID_FIELD = "id";
private static final String TITLE_FIELD = "title";
private static final String LATITUDE_FIELD = "latitude";
private static final String LONGITUDE_FIELD = "longitude";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Location title
@JsonProperty(LATITUDE_FIELD)
private String latitude; ///< Location latitude in degrees
@JsonProperty(LONGITUDE_FIELD)
private String longitude; ///< Location longitude in degrees
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public Integer getThumbWidth() {
return thumbWidth;
}
public void setThumbWidth(Integer thumbWidth) {
this.thumbWidth = thumbWidth;
}
public Integer getThumbHeight() {
return thumbHeight;
}
public void setThumbHeight(Integer thumbHeight) {
this.thumbHeight = thumbHeight;
}
public String getThumbUrl() {
return thumbUrl;
}
public void setThumbUrl(String thumbUrl) {
this.thumbUrl = thumbUrl;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, id);
jsonObject.put(LATITUDE_FIELD, latitude);
jsonObject.put(TITLE_FIELD, title);
jsonObject.put(LONGITUDE_FIELD, longitude);
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (thumbUrl != null) {
jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
}
if (thumbWidth != null) {
jsonObject.put(THUMBWIDTH_FIELD, this.thumbWidth);
}
if (thumbHeight != null) {
jsonObject.put(THUMBHEIGHT_FIELD, thumbHeight);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(LONGITUDE_FIELD, longitude);
gen.writeStringField(LATITUDE_FIELD, latitude);
gen.writeStringField(TITLE_FIELD, title);
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (thumbUrl != null) {
gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
}
if (thumbWidth != null) {
gen.writeNumberField(THUMBWIDTH_FIELD, thumbWidth);
}
if (thumbHeight != null) {
gen.writeNumberField(THUMBHEIGHT_FIELD, thumbHeight);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultLocation{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", mimeType='" + latitude + '\'' +
", documentUrl='" + longitude + '\'' +
", thumbHeight=" + thumbHeight +
", thumbWidth=" + thumbWidth +
", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -6,52 +6,51 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException; import java.io.IOException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). * @brief Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default,
* By default, this animated MPEG-4 file will be sent by the user with optional caption. * this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can
* Alternatively, you can provide message_text to send it instead of the animation. * use input_message_content to send a message with the specified content instead of the animation.
* @date 01 of January of 2016 * @date 01 of January of 2016
*/ */
public class InlineQueryResultMpeg4Gif implements InlineQueryResult { public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
public static final String TYPE_FIELD = "type"; private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD) @JsonProperty(TYPE_FIELD)
private final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif" private static final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
public static final String ID_FIELD = "id"; private static final String ID_FIELD = "id";
private static final String MPEG4URL_FIELD = "mpeg4_url";
private static final String MPEG4WIDTH_FIELD = "mpeg4_width";
private static final String MPEG4HEIGHT_FIELD = "mpeg4_height";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String TITLE_FIELD = "title";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD) @JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result private String id; ///< Unique identifier of this result, 1-64 bytes
public static final String MPEG4URL_FIELD = "mpeg4_url";
@JsonProperty(MPEG4URL_FIELD) @JsonProperty(MPEG4URL_FIELD)
private String mpeg4Url; ///< A valid URL for the MP4 file. File size must not exceed 1MB private String mpeg4Url; ///< A valid URL for the MP4 file. File size must not exceed 1MB
public static final String MPEG4WIDTH_FIELD = "mpeg4_width";
@JsonProperty(MPEG4WIDTH_FIELD) @JsonProperty(MPEG4WIDTH_FIELD)
private Integer mpeg4Width; ///< Optional. Video width private Integer mpeg4Width; ///< Optional. Video width
public static final String MPEG4HEIGHT_FIELD = "mpeg4_height";
@JsonProperty(MPEG4HEIGHT_FIELD) @JsonProperty(MPEG4HEIGHT_FIELD)
private Integer mpeg4Height; ///< Optional. Video height private Integer mpeg4Height; ///< Optional. Video height
public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD) @JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the static thumbnail (jpeg or gif) for the result private String thumbUrl; ///< Optional. URL of the static thumbnail (jpeg or gif) for the result
public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD) @JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result private String title; ///< Optional. Title for the result
public static final String CAPTION_FIELD = "caption";
@JsonProperty(CAPTION_FIELD) @JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the MPEG-4 file to be sent private String caption; ///< Optional. Caption of the MPEG-4 file to be sent
public static final String MESSAGETEXT_FIELD = "message_text"; @JsonProperty(INPUTMESSAGECONTENT_FIELD)
@JsonProperty(MESSAGETEXT_FIELD) private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
private String messageText; ///< Optional. Text of a message to be sent instead of the animation, 1-4096 characters @JsonProperty(REPLY_MARKUP_FIELD)
public static final String PARSEMODE_FIELD = "parse_mode"; private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
@JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
public String getType() { public String getType() {
return type; return type;
@ -73,40 +72,20 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
this.title = title; this.title = title;
} }
public String getMessageText() { public InputMessageContent getInputMessageContent() {
return messageText; return inputMessageContent;
} }
public void setMessageText(String messageText) { public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.messageText = messageText; this.inputMessageContent = inputMessageContent;
} }
public String getParseMode() { public InlineKeyboardMarkup getReplyMarkup() {
return parseMode; return replyMarkup;
} }
public void enableMarkdown(boolean enable) { public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
if (enable) { this.replyMarkup = replyMarkup;
this.parseMode = "Markdown";
} else {
this.parseMode = null;
}
}
public void enableHtml(boolean enable) {
if (enable) {
this.parseMode = "html";
} else {
this.parseMode = null;
}
}
public Boolean getDisableWebPagePreview() {
return disableWebPagePreview;
}
public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
this.disableWebPagePreview = disableWebPagePreview;
} }
public String getMpeg4Url() { public String getMpeg4Url() {
@ -156,12 +135,6 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
jsonObject.put(TYPE_FIELD, this.type); jsonObject.put(TYPE_FIELD, this.type);
jsonObject.put(ID_FIELD, this.id); jsonObject.put(ID_FIELD, this.id);
jsonObject.put(MPEG4URL_FIELD, this.mpeg4Url); jsonObject.put(MPEG4URL_FIELD, this.mpeg4Url);
if (parseMode != null) {
jsonObject.put(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
if (mpeg4Width != null) { if (mpeg4Width != null) {
jsonObject.put(MPEG4WIDTH_FIELD, this.mpeg4Width); jsonObject.put(MPEG4WIDTH_FIELD, this.mpeg4Width);
} }
@ -177,8 +150,11 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
if (caption != null) { if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption); jsonObject.put(CAPTION_FIELD, this.caption);
} }
if (messageText != null) { if (replyMarkup != null) {
jsonObject.put(MESSAGETEXT_FIELD, this.messageText); jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
} }
return jsonObject; return jsonObject;
@ -190,13 +166,6 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
gen.writeStringField(TYPE_FIELD, type); gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id); gen.writeStringField(ID_FIELD, id);
gen.writeStringField(MPEG4URL_FIELD, this.mpeg4Url); gen.writeStringField(MPEG4URL_FIELD, this.mpeg4Url);
if (parseMode != null) {
gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
if (mpeg4Width != null) { if (mpeg4Width != null) {
gen.writeNumberField(MPEG4WIDTH_FIELD, this.mpeg4Width); gen.writeNumberField(MPEG4WIDTH_FIELD, this.mpeg4Width);
} }
@ -212,10 +181,12 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
if (caption != null) { if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption); gen.writeStringField(CAPTION_FIELD, this.caption);
} }
if (messageText != null) { if (replyMarkup != null) {
gen.writeStringField(MESSAGETEXT_FIELD, this.messageText); gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
} }
gen.writeEndObject(); gen.writeEndObject();
gen.flush(); gen.flush();
} }
@ -236,9 +207,8 @@ public class InlineQueryResultMpeg4Gif implements InlineQueryResult {
", thumbUrl='" + thumbUrl + '\'' + ", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' + ", title='" + title + '\'' +
", caption='" + caption + '\'' + ", caption='" + caption + '\'' +
", messageText='" + messageText + '\'' + ", inputMessageContent='" + inputMessageContent + '\'' +
", parseMode='" + parseMode + '\'' + ", replyMarkup='" + replyMarkup + '\'' +
", disableWebPagePreview=" + disableWebPagePreview +
'}'; '}';
} }
} }

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -6,59 +6,59 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException; import java.io.IOException;
/** /**
* @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 optional caption. * @brief Represents a link to a photo. By default, this photo will be sent by the user with
* Alternatively, you can provide message_text to send it instead of photo. * optional caption. Alternatively, you can use input_message_content to send a message with the
* specified content instead of the photo.
* @date 01 of January of 2016 * @date 01 of January of 2016
*/ */
public class InlineQueryResultPhoto implements InlineQueryResult { public class InlineQueryResultPhoto implements InlineQueryResult {
public static final String TYPE_FIELD = "type"; private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD) @JsonProperty(TYPE_FIELD)
private final String type = "photo"; ///< Type of the result, must be photo private static final String type = "photo"; ///< Type of the result, must be photo
public 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 MIMETYPE_FIELD = "mime_type";
private static final String PHOTOWIDTH_FIELD = "photo_width";
private static final String PHOTOHEIGHT_FIELD = "photo_height";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String TITLE_FIELD = "title";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD) @JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result private String id; ///< Unique identifier of this result, 1-64 bytes
public static final String PHOTOURL_FIELD = "photo_url";
@JsonProperty(PHOTOURL_FIELD) @JsonProperty(PHOTOURL_FIELD)
private String photoUrl; ///< A valid URL of the photo. Photo size must not exceed 5MB private String photoUrl; ///< A valid URL of the photo. Photo size must not exceed 5MB
public static final String MIMETYPE_FIELD = "mime_type";
@JsonProperty(MIMETYPE_FIELD) @JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Optional. MIME type of the photo, defaults to image/jpeg private String mimeType; ///< Optional. MIME type of the photo, defaults to image/jpeg
public static final String PHOTOWIDTH_FIELD = "photo_width";
@JsonProperty(PHOTOWIDTH_FIELD) @JsonProperty(PHOTOWIDTH_FIELD)
private Integer photoWidth; ///< Optional. Width of the photo private Integer photoWidth; ///< Optional. Width of the photo
public static final String PHOTOHEIGHT_FIELD = "photo_height";
@JsonProperty(PHOTOHEIGHT_FIELD) @JsonProperty(PHOTOHEIGHT_FIELD)
private Integer photoHeight; ///< Optional. Height of the photo private Integer photoHeight; ///< Optional. Height of the photo
public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD) @JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail for the photo private String thumbUrl; ///< Optional. URL of the thumbnail for the photo
public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD) @JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result private String title; ///< Optional. Title for the result
public static final String DESCRIPTION_FIELD = "description";
@JsonProperty(DESCRIPTION_FIELD) @JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result private String description; ///< Optional. Short description of the result
public static final String CAPTION_FIELD = "caption";
@JsonProperty(CAPTION_FIELD) @JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the photo to be sent private String caption; ///< Optional. Caption of the photo to be sent
public static final String MESSAGETEXT_FIELD = "message_text"; @JsonProperty(INPUTMESSAGECONTENT_FIELD)
@JsonProperty(MESSAGETEXT_FIELD) private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
private String messageText; ///< Optional. Text of a message to be sent instead of the photo, 1-4096 characters @JsonProperty(REPLY_MARKUP_FIELD)
public static final String PARSEMODE_FIELD = "parse_mode"; private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(PARSEMODE_FIELD)
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
@JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
public String getType() { public static String getType() {
return type; return type;
} }
@ -78,40 +78,20 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
this.title = title; this.title = title;
} }
public String getMessageText() { public InputMessageContent getInputMessageContent() {
return messageText; return inputMessageContent;
} }
public void setMessageText(String messageText) { public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.messageText = messageText; this.inputMessageContent = inputMessageContent;
} }
public String getParseMode() { public InlineKeyboardMarkup getReplyMarkup() {
return parseMode; return replyMarkup;
} }
public void enableMarkdown(boolean enable) { public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
if (enable) { this.replyMarkup = replyMarkup;
this.parseMode = "Markdown";
} else {
this.parseMode = null;
}
}
public void enableHtml(boolean enable) {
if (enable) {
this.parseMode = "html";
} else {
this.parseMode = null;
}
}
public Boolean getDisableWebPagePreview() {
return disableWebPagePreview;
}
public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
this.disableWebPagePreview = disableWebPagePreview;
} }
public String getPhotoUrl() { public String getPhotoUrl() {
@ -174,15 +154,9 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
public JSONObject toJson() { public JSONObject toJson() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, this.type); jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id); jsonObject.put(ID_FIELD, this.id);
jsonObject.put(PHOTOURL_FIELD, this.photoUrl); jsonObject.put(PHOTOURL_FIELD, this.photoUrl);
if (parseMode != null) {
jsonObject.put(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
if (mimeType != null) { if (mimeType != null) {
jsonObject.put(MIMETYPE_FIELD, this.mimeType); jsonObject.put(MIMETYPE_FIELD, this.mimeType);
} }
@ -201,14 +175,14 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
if (title != null) { if (title != null) {
jsonObject.put(TITLE_FIELD, this.title); jsonObject.put(TITLE_FIELD, this.title);
} }
if (description != null) {
jsonObject.put(DESCRIPTION_FIELD, this.description);
}
if (caption != null) { if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption); jsonObject.put(CAPTION_FIELD, this.caption);
} }
if (messageText != null) { if (replyMarkup != null) {
jsonObject.put(MESSAGETEXT_FIELD, this.messageText); jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
} }
return jsonObject; return jsonObject;
@ -220,12 +194,6 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
gen.writeStringField(TYPE_FIELD, type); gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id); gen.writeStringField(ID_FIELD, id);
gen.writeStringField(PHOTOURL_FIELD, this.photoUrl); gen.writeStringField(PHOTOURL_FIELD, this.photoUrl);
if (parseMode != null) {
gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
if (mimeType != null) { if (mimeType != null) {
gen.writeStringField(MIMETYPE_FIELD, this.mimeType); gen.writeStringField(MIMETYPE_FIELD, this.mimeType);
} }
@ -247,8 +215,11 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
if (caption != null) { if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption); gen.writeStringField(CAPTION_FIELD, this.caption);
} }
if (messageText != null) { if (replyMarkup != null) {
gen.writeStringField(MESSAGETEXT_FIELD, this.messageText); gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
} }
gen.writeEndObject(); gen.writeEndObject();
@ -273,9 +244,8 @@ public class InlineQueryResultPhoto implements InlineQueryResult {
", title='" + title + '\'' + ", title='" + title + '\'' +
", description='" + description + '\'' + ", description='" + description + '\'' +
", caption='" + caption + '\'' + ", caption='" + caption + '\'' +
", messageText='" + messageText + '\'' + ", inputMessageContent='" + inputMessageContent + '\'' +
", parseMode='" + parseMode + '\'' + ", replyMarkup='" + replyMarkup + '\'' +
", disableWebPagePreview=" + disableWebPagePreview +
'}'; '}';
} }
} }

View File

@ -0,0 +1,238 @@
package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a venue. By default, the venue will be sent by the user. Alternatively, you can
* use input_message_content to send a message with the specified content instead of the venue.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultVenue implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "venue"; ///< Type of the result, must be "venue"
private static final String ID_FIELD = "id";
private static final String TITLE_FIELD = "title";
private static final String LATITUDE_FIELD = "latitude";
private static final String LONGITUDE_FIELD = "longitude";
private static final String ADDRESS_FIELD = "address";
private static final String FOURSQUARE_ID_FIELD = "foursquare_id";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String THUMBWIDTH_FIELD = "thumb_width";
private static final String THUMBHEIGHT_FIELD = "thumb_height";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Location title
@JsonProperty(LATITUDE_FIELD)
private String latitude; ///< Venue latitude in degrees
@JsonProperty(LONGITUDE_FIELD)
private String longitude; ///< Venue longitude in degrees
@JsonProperty(ADDRESS_FIELD)
private String address; ///< Address of the venue
@JsonProperty(FOURSQUARE_ID_FIELD)
private String foursquareId; ///< Optional. Foursquare identifier of the venue if known
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the file
@JsonProperty(THUMBWIDTH_FIELD)
private Integer thumbWidth; ///< Optional. Thumbnail width
@JsonProperty(THUMBHEIGHT_FIELD)
private Integer thumbHeight; ///< Optional. Thumbnail height
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public Integer getThumbWidth() {
return thumbWidth;
}
public void setThumbWidth(Integer thumbWidth) {
this.thumbWidth = thumbWidth;
}
public Integer getThumbHeight() {
return thumbHeight;
}
public void setThumbHeight(Integer thumbHeight) {
this.thumbHeight = thumbHeight;
}
public String getThumbUrl() {
return thumbUrl;
}
public void setThumbUrl(String thumbUrl) {
this.thumbUrl = thumbUrl;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getFoursquareId() {
return foursquareId;
}
public void setFoursquareId(String foursquareId) {
this.foursquareId = foursquareId;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, id);
jsonObject.put(LATITUDE_FIELD, latitude);
jsonObject.put(TITLE_FIELD, title);
jsonObject.put(LONGITUDE_FIELD, longitude);
jsonObject.put(ADDRESS_FIELD, address);
if (foursquareId != null) {
jsonObject.put(FOURSQUARE_ID_FIELD, foursquareId);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (thumbUrl != null) {
jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
}
if (thumbWidth != null) {
jsonObject.put(THUMBWIDTH_FIELD, this.thumbWidth);
}
if (thumbHeight != null) {
jsonObject.put(THUMBHEIGHT_FIELD, thumbHeight);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(LONGITUDE_FIELD, longitude);
gen.writeStringField(LATITUDE_FIELD, latitude);
gen.writeStringField(TITLE_FIELD, title);
gen.writeStringField(ADDRESS_FIELD, address);
if (foursquareId != null) {
gen.writeStringField(FOURSQUARE_ID_FIELD, foursquareId);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (thumbUrl != null) {
gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
}
if (thumbWidth != null) {
gen.writeNumberField(THUMBWIDTH_FIELD, thumbWidth);
}
if (thumbHeight != null) {
gen.writeNumberField(THUMBHEIGHT_FIELD, thumbHeight);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultVenue{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", mimeType='" + latitude + '\'' +
", documentUrl='" + longitude + '\'' +
", thumbHeight=" + thumbHeight +
", thumbWidth=" + thumbWidth +
", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' +
", foursquareId='" + foursquareId + '\'' +
", address='" + address + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException; import java.io.IOException;
@ -13,51 +15,53 @@ import java.io.IOException;
* @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. * @brief Represents link to a page containing an embedded video player or a video file.
* Alternatively, you can use input_message_content to send a message with the specified content
* instead of the video.
* @date 01 of January of 2016 * @date 01 of January of 2016
*/ */
public class InlineQueryResultVideo implements InlineQueryResult { public class InlineQueryResultVideo implements InlineQueryResult {
public static final String TYPE_FIELD = "type"; private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD) @JsonProperty(TYPE_FIELD)
private final String type = "video"; ///< Type of the result, must be "video" private static final String type = "video"; ///< Type of the result, must be "video"
public 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 VIDEOURL_FIELD = "video_url";
private static final String VIDEOWIDTH_FIELD = "video_width";
private static final String VIDEOHEIGHT_FIELD = "video_height";
private static final String VIDEODURATION_FIELD = "video_duration";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String TITLE_FIELD = "title";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD) @JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result private String id; ///< Unique identifier of this result
public static final String MIMETYPE_FIELD = "mime_type";
@JsonProperty(MIMETYPE_FIELD) @JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Mime type of the content of video url, i.e. text/html or video/mp4 private String mimeType; ///< Mime type of the content of video url, i.e. text/html or video/mp4
public static final String VIDEOURL_FIELD = "video_url";
@JsonProperty(VIDEOURL_FIELD) @JsonProperty(VIDEOURL_FIELD)
private String videoUrl; ///< A valid URL for the embedded video player or video file private String videoUrl; ///< A valid URL for the embedded video player or video file
public static final String VIDEOWIDTH_FIELD = "video_width";
@JsonProperty(VIDEOWIDTH_FIELD) @JsonProperty(VIDEOWIDTH_FIELD)
private Integer videoWidth; ///< Optional. Video width private Integer videoWidth; ///< Optional. Video width
public static final String VIDEOHEIGHT_FIELD = "video_height";
@JsonProperty(VIDEOHEIGHT_FIELD) @JsonProperty(VIDEOHEIGHT_FIELD)
private Integer videoHeight; ///< Optional. Video height private Integer videoHeight; ///< Optional. Video height
public static final String VIDEODURATION_FIELD = "video_duration";
@JsonProperty(VIDEODURATION_FIELD) @JsonProperty(VIDEODURATION_FIELD)
private Integer videoDuration; ///< Optional. Video duration in seconds private Integer videoDuration; ///< Optional. Video duration in seconds
public static final String THUMBURL_FIELD = "thumb_url";
@JsonProperty(THUMBURL_FIELD) @JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the video private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the video
public static final String TITLE_FIELD = "title";
@JsonProperty(TITLE_FIELD) @JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result private String title; ///< Optional. Title for the result
public static final String DESCRIPTION_FIELD = "description";
@JsonProperty(DESCRIPTION_FIELD) @JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result private String description; ///< Optional. Short description of the result
public static final String MESSAGETEXT_FIELD = "message_text"; @JsonProperty(CAPTION_FIELD)
@JsonProperty(MESSAGETEXT_FIELD) private String caption; ///< Optional. Caption of the video to be sent, 0-200 characters
private String messageText; ///< Optional. Text of a message to be sent instead of the video, 1-4096 characters @JsonProperty(INPUTMESSAGECONTENT_FIELD)
public static final String PARSEMODE_FIELD = "parse_mode"; private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(PARSEMODE_FIELD) @JsonProperty(REPLY_MARKUP_FIELD)
private String parseMode; ///< Optional. Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message. private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static final String DISABLEWEBPAGEPREVIEW_FIELD = "disable_web_page_preview";
@JsonProperty(DISABLEWEBPAGEPREVIEW_FIELD)
private Boolean disableWebPagePreview; ///< Optional. Disables link previews for links in the sent message
public String getType() { public static String getType() {
return type; return type;
} }
@ -77,40 +81,20 @@ public class InlineQueryResultVideo implements InlineQueryResult {
this.title = title; this.title = title;
} }
public String getMessageText() { public InputMessageContent getInputMessageContent() {
return messageText; return inputMessageContent;
} }
public void setMessageText(String messageText) { public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.messageText = messageText; this.inputMessageContent = inputMessageContent;
} }
public String getParseMode() { public InlineKeyboardMarkup getReplyMarkup() {
return parseMode; return replyMarkup;
} }
public void enableMarkdown(boolean enable) { public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
if (enable) { this.replyMarkup = replyMarkup;
this.parseMode = "Markdown";
} else {
this.parseMode = null;
}
}
public void enableHtml(boolean enable) {
if (enable) {
this.parseMode = "html";
} else {
this.parseMode = null;
}
}
public Boolean getDisableWebPagePreview() {
return disableWebPagePreview;
}
public void setDisableWebPagePreview(Boolean disableWebPagePreview) {
this.disableWebPagePreview = disableWebPagePreview;
} }
public String getMimeType() { public String getMimeType() {
@ -169,25 +153,24 @@ public class InlineQueryResultVideo implements InlineQueryResult {
this.description = description; this.description = description;
} }
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
@Override @Override
public JSONObject toJson() { public JSONObject toJson() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, this.type); jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id); jsonObject.put(ID_FIELD, this.id);
jsonObject.put(VIDEOURL_FIELD, this.videoUrl); jsonObject.put(VIDEOURL_FIELD, this.videoUrl);
if (mimeType != null) { if (mimeType != null) {
jsonObject.put(MIMETYPE_FIELD, this.mimeType); jsonObject.put(MIMETYPE_FIELD, this.mimeType);
} }
if (messageText != null) {
jsonObject.put(MESSAGETEXT_FIELD, this.messageText);
}
if (parseMode != null) {
jsonObject.put(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
jsonObject.put(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
if (videoWidth != null) { if (videoWidth != null) {
jsonObject.put(VIDEOWIDTH_FIELD, this.videoWidth); jsonObject.put(VIDEOWIDTH_FIELD, this.videoWidth);
} }
@ -206,6 +189,15 @@ public class InlineQueryResultVideo implements InlineQueryResult {
if (description != null) { if (description != null) {
jsonObject.put(DESCRIPTION_FIELD, this.description); jsonObject.put(DESCRIPTION_FIELD, this.description);
} }
if (caption != null) {
jsonObject.put(CAPTION_FIELD, caption);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject; return jsonObject;
} }
@ -219,15 +211,6 @@ public class InlineQueryResultVideo implements InlineQueryResult {
if (mimeType != null) { if (mimeType != null) {
gen.writeStringField(MIMETYPE_FIELD, this.mimeType); gen.writeStringField(MIMETYPE_FIELD, this.mimeType);
} }
if (messageText != null) {
gen.writeStringField(MESSAGETEXT_FIELD, this.messageText);
}
if (parseMode != null) {
gen.writeStringField(PARSEMODE_FIELD, this.parseMode);
}
if (disableWebPagePreview != null) {
gen.writeBooleanField(DISABLEWEBPAGEPREVIEW_FIELD, this.disableWebPagePreview);
}
if (videoWidth != null) { if (videoWidth != null) {
gen.writeNumberField(VIDEOWIDTH_FIELD, this.videoWidth); gen.writeNumberField(VIDEOWIDTH_FIELD, this.videoWidth);
} }
@ -246,6 +229,15 @@ public class InlineQueryResultVideo implements InlineQueryResult {
if (description != null) { if (description != null) {
gen.writeStringField(DESCRIPTION_FIELD, this.description); gen.writeStringField(DESCRIPTION_FIELD, this.description);
} }
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, caption);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject(); gen.writeEndObject();
gen.flush(); gen.flush();
@ -269,9 +261,9 @@ public class InlineQueryResultVideo implements InlineQueryResult {
", thumbUrl='" + thumbUrl + '\'' + ", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' + ", title='" + title + '\'' +
", description='" + description + '\'' + ", description='" + description + '\'' +
", messageText='" + messageText + '\'' + ", caption='" + caption + '\'' +
", parseMode='" + parseMode + '\'' + ", inputMessageContent='" + inputMessageContent + '\'' +
", disableWebPagePreview=" + disableWebPagePreview + ", replyMarkup='" + replyMarkup + '\'' +
'}'; '}';
} }
} }

View File

@ -0,0 +1,160 @@
package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a voice recording in an .ogg container encoded with OPUS. By default,
* this voice recording will be sent by the user. Alternatively, you can use input_message_content
* to send a message with the specified content instead of the the voice message.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultVoice implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "voice"; ///< Type of the result, must be "voice"
private static final String ID_FIELD = "id";
private static final String VOICEURL_FIELD = "voice_url";
private static final String TITLE_FIELD = "title";
private static final String VOICE_DURATION_FIELD = "voice_duration";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(VOICEURL_FIELD)
private String voiceUrl; ///< A valid URL for the voice recording
@JsonProperty(TITLE_FIELD)
private String title; ///< Recording title
@JsonProperty(VOICE_DURATION_FIELD)
private Integer voiceDuration; ///< Optional. Recording duration in seconds
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the voice recording
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public Integer getVoiceDuration() {
return voiceDuration;
}
public void setVoiceDuration(Integer voiceDuration) {
this.voiceDuration = voiceDuration;
}
public String getVoiceUrl() {
return voiceUrl;
}
public void setVoiceUrl(String voiceUrl) {
this.voiceUrl = voiceUrl;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(VOICE_DURATION_FIELD, voiceUrl);
if (title != null) {
jsonObject.put(TITLE_FIELD, this.title);
}
if (voiceDuration != null) {
jsonObject.put(VOICE_DURATION_FIELD, voiceDuration);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(VOICEURL_FIELD, voiceUrl);
if (title != null) {
gen.writeStringField(TITLE_FIELD, this.title);
}
if (voiceDuration != null) {
gen.writeNumberField(VOICE_DURATION_FIELD, voiceDuration);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultVoice{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", voiceDuration='" + voiceDuration + '\'' +
", voiceUrl=" + voiceUrl +
", title='" + title + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,126 @@
package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to an mp3 audio file stored on the Telegram servers. By default, this
* audio file will be sent by the user. Alternatively, you can use input_message_content to send a
* message with the specified content instead of the audio.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedAudio implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "audio"; ///< Type of the result, must be "audio"
private static final String ID_FIELD = "id";
private static final String AUDIO_FILE_ID_FIELD = "audio_file_id";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result
@JsonProperty(AUDIO_FILE_ID_FIELD)
private String audioFileId; ///< A valid file identifier for the audio file
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the audio
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getAudioFileId() {
return audioFileId;
}
public void setAudioFileId(String audioFileId) {
this.audioFileId = audioFileId;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, id);
jsonObject.put(AUDIO_FILE_ID_FIELD, audioFileId);
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(AUDIO_FILE_ID_FIELD, audioFileId);
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultCachedAudio{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", audioFileId='" + audioFileId + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,176 @@
package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a file stored on the Telegram servers. By default, this file will be
* sent by the user with an optional caption. Alternatively, you can use input_message_content to
* send a message with the specified content instead of the file.
* @note Currently, only pdf-files and zip archives can be sent using this method.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedDocument implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "document"; ///< Type of the result, must be "document"
private static final String ID_FIELD = "id";
private static final String TITLE_FIELD = "title";
private static final String DOCUMENT_FILE_ID_FIELD = "document_file_id";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(DOCUMENT_FILE_ID_FIELD)
private String documentFileId; ///< A valid file identifier for the file
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the document to be sent, 0-200 characters
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the file
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public String getDocumentFileId() {
return documentFileId;
}
public void setDocumentFileId(String documentFileId) {
this.documentFileId = documentFileId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, id);
jsonObject.put(DOCUMENT_FILE_ID_FIELD, documentFileId);
jsonObject.put(TITLE_FIELD, title);
if (description != null) {
jsonObject.put(DESCRIPTION_FIELD, this.description);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (caption != null) {
jsonObject.put(CAPTION_FIELD, caption);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(DOCUMENT_FILE_ID_FIELD, documentFileId);
gen.writeStringField(TITLE_FIELD, title);
if (description != null) {
gen.writeStringField(DESCRIPTION_FIELD, description);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, caption);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultCachedDocument{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", documentFileId='" + documentFileId + '\'' +
", caption='" + caption + '\'' +
", title='" + title + '\'' +
", description='" + description + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,159 @@
package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to an animated GIF file stored on the Telegram servers. By default, this
* animated GIF file will be sent by the user with an optional caption. Alternatively, you can use
* input_message_content to send a message with specified content instead of the animation.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedGif implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "gif"; ///< Type of the result, must be "gif"
private static final String ID_FIELD = "id";
private static final String GIF_FILE_ID_FIELD = "gif_file_id";
private static final String TITLE_FIELD = "title";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(GIF_FILE_ID_FIELD)
private String gifFileId; ///< A valid file identifier for the GIF file
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the GIF file to be sent
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the GIF animation
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getGifFileId() {
return gifFileId;
}
public void setGifFileId(String gifFileId) {
this.gifFileId = gifFileId;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(GIF_FILE_ID_FIELD, gifFileId);
if (title != null) {
jsonObject.put(TITLE_FIELD, this.title);
}
if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(GIF_FILE_ID_FIELD, gifFileId);
if (title != null) {
gen.writeStringField(TITLE_FIELD, this.title);
}
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultCachedGif{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", gifUrl='" + gifFileId + '\'' +
", title='" + title + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,160 @@
package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default,
* this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can
* use input_message_content to send a message with the specified content instead of the animation.
* @date 01 of January of 2016
*/
public class InlineQueryResultCachedMpeg4Gif implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "mpeg4_gif"; ///< Type of the result, must be "mpeg4_gif"
private static final String ID_FIELD = "id";
private static final String MPEG4_FILE_ID_FIELD = "mpeg4_file_id";
private static final String TITLE_FIELD = "title";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(MPEG4_FILE_ID_FIELD)
private String mpeg4FileId; ///< A valid file identifier for the MP4 file
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the MPEG-4 file to be sent
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getMpeg4FileId() {
return mpeg4FileId;
}
public void setMpeg4FileId(String mpeg4FileId) {
this.mpeg4FileId = mpeg4FileId;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(MPEG4_FILE_ID_FIELD, mpeg4FileId);
if (title != null) {
jsonObject.put(TITLE_FIELD, this.title);
}
if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(MPEG4_FILE_ID_FIELD, mpeg4FileId);
if (title != null) {
gen.writeStringField(TITLE_FIELD, this.title);
}
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultCachedMpeg4Gif{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", mpeg4Url='" + mpeg4FileId + '\'' +
", title='" + title + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,183 @@
package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a photo stored on the Telegram servers. By default, this photo will
* be sent by the user with an optional caption. Alternatively, you can use input_message_content to
* send a message with the specified content instead of the photo.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedPhoto implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "photo"; ///< Type of the result, must be photo
private static final String ID_FIELD = "id";
private static final String PHOTOFILEID_FIELD = "photo_file_id";
private static final String TITLE_FIELD = "title";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(PHOTOFILEID_FIELD)
private String photoFileId; ///< A valid file identifier of the photo
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the photo to be sent
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getPhotoFileId() {
return photoFileId;
}
public void setPhotoFileId(String photoFileId) {
this.photoFileId = photoFileId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(PHOTOFILEID_FIELD, photoFileId);
if (title != null) {
jsonObject.put(TITLE_FIELD, this.title);
}
if (description != null) {
jsonObject.put(DESCRIPTION_FIELD, this.description);
}
if (caption != null) {
jsonObject.put(CAPTION_FIELD, this.caption);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
/*
reply_markup InlineKeyboardMarkup Optional. Inline keyboard attached to the message
input_message_content InputMessageContent Optional. Content of the message to be sent instead of the photo
*/
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(PHOTOFILEID_FIELD, photoFileId);
if (description != null) {
gen.writeStringField(DESCRIPTION_FIELD, this.description);
}
if (title != null) {
gen.writeStringField(TITLE_FIELD, this.title);
}
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, this.caption);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultCachedPhoto{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", photoFileId='" + photoFileId + '\'' +
", title='" + title + '\'' +
", description='" + description + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,125 @@
package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a sticker stored on the Telegram servers. By default, this sticker
* will be sent by the user. Alternatively, you can use input_message_content to send a message with
* the specified content instead of the sticker.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedSticker implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "sticker"; ///< Type of the result, must be "sticker"
private static final String ID_FIELD = "id";
private static final String STICKER_FILE_ID_FIELD = "sticker_file_id";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(STICKER_FILE_ID_FIELD)
private String stickerFileId; ///< A valid file identifier of the sticker
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the sticker
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getStickerFileId() {
return stickerFileId;
}
public void setStickerFileId(String stickerFileId) {
this.stickerFileId = stickerFileId;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(STICKER_FILE_ID_FIELD, stickerFileId);
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(STICKER_FILE_ID_FIELD, stickerFileId);
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultCachedGif{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", gifUrl='" + stickerFileId + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,177 @@
package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a video file stored on the Telegram servers. By default, this video
* file will be sent by the user with an optional caption. Alternatively, you can use
* input_message_content to send a message with the specified content instead of the video.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedVideo implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "video"; ///< Type of the result, must be "video"
private static final String ID_FIELD = "id";
private static final String VIDEO_FILE_ID_FIELD = "video_file_id";
private static final String TITLE_FIELD = "title";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result
@JsonProperty(VIDEO_FILE_ID_FIELD)
private String videoFileId; ///< A valid file identifier for the video file
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the video to be sent, 0-200 characters
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getVideoFileId() {
return videoFileId;
}
public void setVideoFileId(String videoFileId) {
this.videoFileId = videoFileId;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(VIDEO_FILE_ID_FIELD, videoFileId);
if (caption != null) {
jsonObject.put(CAPTION_FIELD, caption);
}
if (title != null) {
jsonObject.put(TITLE_FIELD, this.title);
}
if (description != null) {
jsonObject.put(DESCRIPTION_FIELD, this.description);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(VIDEO_FILE_ID_FIELD, videoFileId);
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, caption);
}
if (title != null) {
gen.writeStringField(TITLE_FIELD, this.title);
}
if (description != null) {
gen.writeStringField(DESCRIPTION_FIELD, this.description);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultCachedVideo{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", caption='" + caption + '\'' +
", videoFileId='" + videoFileId + '\'' +
", title='" + title + '\'' +
", description='" + description + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -0,0 +1,143 @@
package org.telegram.telegrambots.api.objects.inlinequery.result.chached;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.inlinequery.result.InlineQueryResult;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents a link to a voice message stored on the Telegram servers. By default, this
* voice message will be sent by the user. Alternatively, you can use input_message_content to send
* a message with the specified content instead of the voice message.
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
* @date 10 of April of 2016
*/
public class InlineQueryResultCachedVoice implements InlineQueryResult {
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "voice"; ///< Type of the result, must be "voice"
private static final String ID_FIELD = "id";
private static final String VOICE_FILE_ID_FIELD = "voice_file_id";
private static final String TITLE_FIELD = "title";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result, 1-64 bytes
@JsonProperty(VOICE_FILE_ID_FIELD)
private String voiceFileId; ///< A valid file identifier for the voice message
@JsonProperty(TITLE_FIELD)
private String title; ///< Recording title
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the voice recording
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public void setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
}
public String getVoiceFileId() {
return voiceFileId;
}
public void setVoiceFileId(String voiceFileId) {
this.voiceFileId = voiceFileId;
}
@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(VOICE_FILE_ID_FIELD, voiceFileId);
if (title != null) {
jsonObject.put(TITLE_FIELD, this.title);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(VOICE_FILE_ID_FIELD, voiceFileId);
if (title != null) {
gen.writeStringField(TITLE_FIELD, this.title);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultCachedVoice{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", voiceFileId='" + voiceFileId + '\'' +
", title='" + title + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.replykeyboard;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -12,26 +12,26 @@ import java.io.IOException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief Upon receiving a message with this object, Telegram clients will display a reply interface to the user * @brief Upon receiving a message with this object, Telegram clients will display a reply interface
* (act as if the user has selected the bots message and tapped Reply'). * to the user (act as if the user has selected the bots message and tapped Reply'). This can be
* This can be extremely useful if you want to create user-friendly step-by-step * extremely useful if you want to create user-friendly step-by-step interfaces without having to
* interfaces without having to sacrifice privacy mode. * sacrifice privacy mode.
* @date 22 of June of 2015 * @date 22 of June of 2015
*/ */
public class ForceReplyKeyboard implements ReplyKeyboard { public class ForceReplyKeyboard implements ReplyKeyboard {
public static final String FORCEREPLY_FIELD = "force_reply"; private static final String FORCEREPLY_FIELD = "force_reply";
public static final String SELECTIVE_FIELD = "selective"; private static final String SELECTIVE_FIELD = "selective";
/** /**
* Shows reply interface to the user, as if they manually selected the bots message and tapped Reply' * Shows reply interface to the user, as if they manually selected the bots message and tapped
* Reply'
*/ */
@JsonProperty(FORCEREPLY_FIELD) @JsonProperty(FORCEREPLY_FIELD)
private Boolean forceReply; private Boolean forceReply;
/** /**
* Use this parameter if you want to force reply from specific users only. * Use this parameter if you want to force reply from specific users only. Targets: 1) users
* Targets: * that are @mentioned in the text of the Message object; 2) if the bot's message is a reply
* 1) users that are @mentioned in the text of the Message object; * (has reply_to_message_id), sender of the original message.
* 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
*/ */
@JsonProperty(SELECTIVE_FIELD) @JsonProperty(SELECTIVE_FIELD)
private Boolean selective; private Boolean selective;

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.replykeyboard;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -15,15 +15,18 @@ import java.util.List;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief This object represents a custom keyboard with reply options. * @brief This object represents an inline keyboard that appears right next to the message it
* @date 20 of June of 2015 * belongs to
* @note Inline keyboards are currently being tested and are only available in one-on-one chats
* (i.e., user-bot or user-user in the case of inline bots).
* @date 10 of April of 2016
*/ */
public class ReplyKeyboardMarkup implements ReplyKeyboard { public class InlineKeyboardMarkup implements ReplyKeyboard {
public static final String KEYBOARD_FIELD = "keyboard"; private static final String KEYBOARD_FIELD = "keyboard";
public static final String RESIZEKEYBOARD_FIELD = "resize_keyboard"; private static final String RESIZEKEYBOARD_FIELD = "resize_keyboard";
public static final String ONETIMEKEYBOARD_FIELD = "one_time_keyboard"; private static final String ONETIMEKEYBOARD_FIELD = "one_time_keyboard";
public static final String SELECTIVE_FIELD = "selective"; private static final String SELECTIVE_FIELD = "selective";
@JsonProperty(KEYBOARD_FIELD) @JsonProperty(KEYBOARD_FIELD)
private List<List<String>> keyboard; ///< Array of button rows, each represented by an Array of Strings private List<List<String>> keyboard; ///< Array of button rows, each represented by an Array of Strings
@JsonProperty(RESIZEKEYBOARD_FIELD) @JsonProperty(RESIZEKEYBOARD_FIELD)
@ -32,18 +35,17 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard {
private Boolean oneTimeKeyboad; ///< Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false. private Boolean oneTimeKeyboad; ///< Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
/** /**
* Optional. Use this parameter if you want to show the keyboard to specific users only. * Optional. Use this parameter if you want to show the keyboard to specific users only.
* Targets: * Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's
* 1) users that are @mentioned in the text of the Message object; * message is a reply (has reply_to_message_id), sender of the original message.
* 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
*/ */
private Boolean selective; private Boolean selective;
public ReplyKeyboardMarkup() { public InlineKeyboardMarkup() {
super(); super();
keyboard = new ArrayList<List<String>>(); keyboard = new ArrayList<List<String>>();
} }
public ReplyKeyboardMarkup(JSONObject jsonObject) { public InlineKeyboardMarkup(JSONObject jsonObject) {
super(); super();
this.keyboard = new ArrayList<List<String>>(); this.keyboard = new ArrayList<List<String>>();
JSONArray keyboard = jsonObject.getJSONArray(KEYBOARD_FIELD); JSONArray keyboard = jsonObject.getJSONArray(KEYBOARD_FIELD);
@ -110,16 +112,16 @@ public class ReplyKeyboardMarkup implements ReplyKeyboard {
} }
jsonkeyboard.put(innerJSONKeyboard); jsonkeyboard.put(innerJSONKeyboard);
} }
jsonObject.put(ReplyKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard); jsonObject.put(InlineKeyboardMarkup.KEYBOARD_FIELD, jsonkeyboard);
if (this.oneTimeKeyboad != null) { if (this.oneTimeKeyboad != null) {
jsonObject.put(ReplyKeyboardMarkup.ONETIMEKEYBOARD_FIELD, this.oneTimeKeyboad); jsonObject.put(InlineKeyboardMarkup.ONETIMEKEYBOARD_FIELD, this.oneTimeKeyboad);
} }
if (this.resizeKeyboard != null) { if (this.resizeKeyboard != null) {
jsonObject.put(ReplyKeyboardMarkup.RESIZEKEYBOARD_FIELD, this.resizeKeyboard); jsonObject.put(InlineKeyboardMarkup.RESIZEKEYBOARD_FIELD, this.resizeKeyboard);
} }
if (this.selective != null) { if (this.selective != null) {
jsonObject.put(ReplyKeyboardMarkup.SELECTIVE_FIELD, this.selective); jsonObject.put(InlineKeyboardMarkup.SELECTIVE_FIELD, this.selective);
} }
return jsonObject; return jsonObject;

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.replykeyboard;
import org.telegram.telegrambots.api.interfaces.IBotApiObject; import org.telegram.telegrambots.api.interfaces.IBotApiObject;
import org.telegram.telegrambots.api.interfaces.IToJson; import org.telegram.telegrambots.api.interfaces.IToJson;

View File

@ -1,4 +1,4 @@
package org.telegram.telegrambots.api.objects; package org.telegram.telegrambots.api.objects.replykeyboard;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
@ -12,24 +12,22 @@ import java.io.IOException;
/** /**
* @author Ruben Bermudez * @author Ruben Bermudez
* @version 1.0 * @version 1.0
* @brief Upon receiving a message with this object, * @brief Upon receiving a message with this object, Telegram clients will hide the current custom
* Telegram clients will hide the current custom keyboard and display the default letter-keyboard. * keyboard and display the default letter-keyboard. By default, custom keyboards are displayed
* By default, custom keyboards are displayed until a new keyboard is sent by a bot. * until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are
* An exception is made for one-time keyboards that are hidden immediately after the user presses a button * hidden immediately after the user presses a button (@see ReplyKeyboardMarkup).
* (@see ReplyKeyboardMarkup).
* @date 20 of June of 2015 * @date 20 of June of 2015
*/ */
public class ReplyKeyboardHide implements ReplyKeyboard { public class ReplyKeyboardHide implements ReplyKeyboard {
public static final String HIDEKEYBOARD_FIELD = "hide_keyboard"; private static final String HIDEKEYBOARD_FIELD = "hide_keyboard";
public static final String SELECTIVE_FIELD = "selective"; private static final String SELECTIVE_FIELD = "selective";
@JsonProperty(HIDEKEYBOARD_FIELD) @JsonProperty(HIDEKEYBOARD_FIELD)
private Boolean hideKeyboard; ///< Requests clients to hide the custom keyboard private Boolean hideKeyboard; ///< Requests clients to hide the custom keyboard
/** /**
* Optional. Use this parameter if you want to show the keyboard to specific users only. * Optional. Use this parameter if you want to show the keyboard to specific users only.
* Targets: * Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's
* 1) users that are @mentioned in the text of the Message object; * message is a reply (has reply_to_message_id), sender of the original message.
* 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
*/ */
@JsonProperty(SELECTIVE_FIELD) @JsonProperty(SELECTIVE_FIELD)
private Boolean selective; private Boolean selective;

Some files were not shown because too many files have changed in this diff Show More