Unverified Commit 84647ebc authored by Armando Lüscher's avatar Armando Lüscher

Merge remote-tracking branch 'upstream/develop' into 726-games

parents e80e551d 09f23ff9
dist: xenial
dist: trusty
sudo: required
language: php
......@@ -14,6 +14,7 @@ php:
- 5.6
- 7.0
- 7.1
- 7.2
- nightly
- hhvm
......@@ -42,7 +43,7 @@ before_script:
script:
- composer check-code
- if [ "$TRAVIS_PHP_VERSION" == "7.1" ] ; then composer test-cov; else composer test; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ] ; then composer test-cov; else composer test; fi
after_script:
- if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then composer test-cov-upload; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then composer test-cov-upload; fi
......@@ -4,15 +4,29 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
Exclamation symbols (:exclamation:) note something of importance e.g. breaking changes. Click them to learn more.
## [Unreleased]
:exclamation: After updating to this version, you will need to execute the [SQL migration script][unreleased-sql-migration] on your database.
### Added
- Implemented new changes for Bot API 3.6 (streamable InputMediaVideo, connected website).
- `Telegram::getLastUpdateId()` method, returns ID of the last update that was processed.
- `Telegram::useGetUpdatesWithoutDatabase()` method, enables `Telegram::handleGetUpdates()` to run without a database.
- Telegram Games platform!
### Changed
- Updated Travis to use Trusty containers (for HHVM) and add PHP 7.2 to the tests.
- Add debug log entry instead of throwing an exception for duplicate updates.
- `Telegram::handleGetUpdates()` can now work without a database connection (not enabled by default).
### Deprecated
### Removed
### Fixed
- Entity relations and wrong types for payments.
- PHPCS fixes for updated CodeSniffer dependency.
- Send messages correctly via `/sendtochannel`.
### Security
## [0.52.0] - 2018-01-07
### Fixed
- Entity relations and wrong types for payments.
- Allow empty string for `switch_inline_query` and `switch_inline_query_current_chat` (InlineKeyboardButton).
- Fix empty date entry for User and Chat entities, using the current timestamp instead.
## [0.51.0] - 2017-12-05
:exclamation: After updating to this version, you will need to execute the [SQL migration script][0.51.0-sql-migration] on your database.
### Added
......@@ -185,6 +199,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Deprecated
- Move `hideKeyboard` to `removeKeyboard`.
[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/develop/utils/db-schema-update/0.52.0-unreleased.sql
[0.51.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/develop/utils/db-schema-update/0.50.0-0.51.0.sql
[0.50.0-bc-messagegetcommand-return-value]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#messagegetcommand-return-value
[0.48.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/develop/utils/db-schema-update/0.47.1-0.48.0.sql
......@@ -199,6 +214,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
[example-bot]: https://github.com/php-telegram-bot/example-bot
[Unreleased]: https://github.com/php-telegram-bot/core/compare/master...develop
[0.52.0]: https://github.com/php-telegram-bot/core/compare/0.51.0...0.52.0
[0.51.0]: https://github.com/php-telegram-bot/core/compare/0.50.0...0.51.0
[0.50.0]: https://github.com/php-telegram-bot/core/compare/0.49.0...0.50.0
[0.49.0]: https://github.com/php-telegram-bot/core/compare/0.48.0...0.49.0
......
......@@ -23,6 +23,5 @@ W: http://noplanman.ch
D: Maintainer and Collaborator
N: Jack'lul (alias)
E: jacklul@jacklul.com
W: http://jacklul.com
E: jacklulcat@gmail.com
D: Maintainer and Collaborator
......@@ -186,7 +186,7 @@ The bot can handle updates with **Webhook** or **getUpdates** method:
| ---- | :----: | :----: |
| Description | Telegram sends the updates directly to your host | You have to fetch Telegram updates manually |
| Host with https | Required | Not required |
| MySQL | Not required | Required |
| MySQL | Not required | ([Not](#getupdates-without-database)) Required |
## Webhook installation
......@@ -257,9 +257,9 @@ $result = $telegram->setWebhook($hook_url, ['certificate' => '/path/to/certifica
Edit [*unset.php*][unset.php] with your bot credentials and execute it.
### getUpdates installation
## getUpdates installation
The MySQL database must be enabled for the getUpdates method!
For best performance, the MySQL database should be enabled for the `getUpdates` method!
Create [*getUpdatesCLI.php*][getUpdatesCLI.php] with the following contents:
```php
......@@ -301,6 +301,13 @@ Lastly, run it!
$ ./getUpdatesCLI.php
```
### getUpdates without database
If you choose to / or are obliged to use the `getUpdates` method without a database, you can replace the `$telegram->useMySQL(...);` line above with:
```php
$telegram->useGetUpdatesWithoutDatabase();
```
## Support
### Types
......
......@@ -22,12 +22,12 @@
"ext-pdo": "*",
"ext-curl": "*",
"ext-mbstring": "*",
"monolog/monolog": "^1.22",
"guzzlehttp/guzzle": "^6.2"
"monolog/monolog": "^1.23",
"guzzlehttp/guzzle": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.7|^6.1",
"squizlabs/php_codesniffer": "^2.8"
"phpunit/phpunit": "^4.8|^5.7|^6.5",
"squizlabs/php_codesniffer": "^3.2"
},
"autoload": {
"psr-4": {
......@@ -41,13 +41,13 @@
},
"scripts": {
"check-code": [
"./vendor/bin/phpcs --standard=phpcs.xml -snp --encoding=utf-8 src/ tests/ --report-width=150"
"\"vendor/bin/phpcs\" --standard=phpcs.xml -snp --encoding=utf-8 src/ tests/ --report-width=150"
],
"test": [
"./vendor/bin/phpunit"
"\"vendor/bin/phpunit\""
],
"test-cov": [
"./vendor/bin/phpunit --coverage-clover build/logs/clover.xml"
"\"vendor/bin/phpunit\" --coverage-clover build/logs/clover.xml"
],
"test-cov-upload": [
"wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml"
......
......@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "fc20b65f31ecd6a88d148f48e89fd4f7",
"content-hash": "1fd4b486f04a942aca0767e94431f284",
"packages": [
{
"name": "guzzlehttp/guzzle",
"version": "6.2.3",
"version": "6.3.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006"
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/8d6c6cc55186db87b7dc5009827429ba4e9dc006",
"reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699",
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699",
"shasum": ""
},
"require": {
......@@ -27,9 +27,12 @@
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.0",
"phpunit/phpunit": "^4.0 || ^5.0",
"psr/log": "^1.0"
},
"suggest": {
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"branch-alias": {
......@@ -66,7 +69,7 @@
"rest",
"web service"
],
"time": "2017-02-28T22:50:30+00:00"
"time": "2017-06-22T18:50:49+00:00"
},
{
"name": "guzzlehttp/promises",
......@@ -186,16 +189,16 @@
},
{
"name": "monolog/monolog",
"version": "1.22.1",
"version": "1.23.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "1e044bc4b34e91743943479f1be7a1d5eb93add0"
"reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/1e044bc4b34e91743943479f1be7a1d5eb93add0",
"reference": "1e044bc4b34e91743943479f1be7a1d5eb93add0",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
"reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
"shasum": ""
},
"require": {
......@@ -216,7 +219,7 @@
"phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "~5.3"
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
......@@ -260,7 +263,7 @@
"logging",
"psr-3"
],
"time": "2017-03-13T07:08:03+00:00"
"time": "2017-06-19T01:22:40+00:00"
},
{
"name": "psr/http-message",
......@@ -417,16 +420,16 @@
},
{
"name": "phpdocumentor/reflection-common",
"version": "1.0",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c"
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"shasum": ""
},
"require": {
......@@ -467,26 +470,26 @@
"reflection",
"static analysis"
],
"time": "2015-12-27T11:43:31+00:00"
"time": "2017-09-11T18:02:19+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "3.1.1",
"version": "3.2.2",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e"
"reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/4aada1f93c72c35e22fb1383b47fee43b8f1d157",
"reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157",
"shasum": ""
},
"require": {
"php": ">=5.5",
"phpdocumentor/reflection-common": "^1.0@dev",
"phpdocumentor/type-resolver": "^0.2.0",
"phpdocumentor/type-resolver": "^0.3.0",
"webmozart/assert": "^1.0"
},
"require-dev": {
......@@ -512,24 +515,24 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2016-09-30T07:12:33+00:00"
"time": "2017-08-08T06:39:58+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "0.2.1",
"version": "0.3.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb"
"reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fb3933512008d8162b3cdf9e18dba9309b7c3773",
"reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773",
"shasum": ""
},
"require": {
"php": ">=5.5",
"php": "^5.5 || ^7.0",
"phpdocumentor/reflection-common": "^1.0"
},
"require-dev": {
......@@ -559,37 +562,37 @@
"email": "me@mikevanriel.com"
}
],
"time": "2016-11-25T06:54:22+00:00"
"time": "2017-06-03T08:32:36+00:00"
},
{
"name": "phpspec/prophecy",
"version": "v1.7.0",
"version": "1.7.3",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "93d39f1f7f9326d746203c7c056f300f7f126073"
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073",
"reference": "93d39f1f7f9326d746203c7c056f300f7f126073",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
"sebastian/comparator": "^1.1|^2.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
},
"require-dev": {
"phpspec/phpspec": "^2.5|^3.2",
"phpunit/phpunit": "^4.8 || ^5.6.5"
"phpunit/phpunit": "^4.8.35 || ^5.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
"dev-master": "1.7.x-dev"
}
},
"autoload": {
......@@ -622,7 +625,7 @@
"spy",
"stub"
],
"time": "2017-03-02T20:05:34+00:00"
"time": "2017-11-24T13:59:53+00:00"
},
{
"name": "phpunit/php-code-coverage",
......@@ -688,16 +691,16 @@
},
{
"name": "phpunit/php-file-iterator",
"version": "1.4.2",
"version": "1.4.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5"
"reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5",
"reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4",
"reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4",
"shasum": ""
},
"require": {
......@@ -731,7 +734,7 @@
"filesystem",
"iterator"
],
"time": "2016-10-03T07:40:28+00:00"
"time": "2017-11-27T13:52:08+00:00"
},
{
"name": "phpunit/php-text-template",
......@@ -825,16 +828,16 @@
},
{
"name": "phpunit/php-token-stream",
"version": "1.4.11",
"version": "1.4.12",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7"
"reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7",
"reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16",
"reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16",
"shasum": ""
},
"require": {
......@@ -870,20 +873,20 @@
"keywords": [
"tokenizer"
],
"time": "2017-02-27T10:12:30+00:00"
"time": "2017-12-04T08:55:13+00:00"
},
{
"name": "phpunit/phpunit",
"version": "4.8.35",
"version": "4.8.36",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87"
"reference": "46023de9a91eec7dfb06cc56cb4e260017298517"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/791b1a67c25af50e230f841ee7a9c6eba507dc87",
"reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517",
"reference": "46023de9a91eec7dfb06cc56cb4e260017298517",
"shasum": ""
},
"require": {
......@@ -942,7 +945,7 @@
"testing",
"xunit"
],
"time": "2017-02-06T05:18:07+00:00"
"time": "2017-06-21T08:07:12+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
......@@ -1066,23 +1069,23 @@
},
{
"name": "sebastian/diff",
"version": "1.4.1",
"version": "1.4.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e"
"reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e",
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4",
"reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
"php": "^5.3.3 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0"
},
"type": "library",
"extra": {
......@@ -1114,7 +1117,7 @@
"keywords": [
"diff"
],
"time": "2015-12-08T07:14:41+00:00"
"time": "2017-05-22T07:24:03+00:00"
},
{
"name": "sebastian/environment",
......@@ -1374,64 +1377,37 @@
},
{
"name": "squizlabs/php_codesniffer",
"version": "2.8.1",
"version": "3.2.2",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d"
"reference": "d7c00c3000ac0ce79c96fcbfef86b49a71158cd1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d",
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7c00c3000ac0ce79c96fcbfef86b49a71158cd1",
"reference": "d7c00c3000ac0ce79c96fcbfef86b49a71158cd1",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": ">=5.1.2"
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0"
},
"bin": [
"scripts/phpcs",
"scripts/phpcbf"
"bin/phpcs",
"bin/phpcbf"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
"dev-master": "3.x-dev"
}
},
"autoload": {
"classmap": [
"CodeSniffer.php",
"CodeSniffer/CLI.php",
"CodeSniffer/Exception.php",
"CodeSniffer/File.php",
"CodeSniffer/Fixer.php",
"CodeSniffer/Report.php",
"CodeSniffer/Reporting.php",
"CodeSniffer/Sniff.php",
"CodeSniffer/Tokens.php",
"CodeSniffer/Reports/",
"CodeSniffer/Tokenizers/",
"CodeSniffer/DocGenerators/",
"CodeSniffer/Standards/AbstractPatternSniff.php",
"CodeSniffer/Standards/AbstractScopeSniff.php",
"CodeSniffer/Standards/AbstractVariableSniff.php",
"CodeSniffer/Standards/IncorrectPatternException.php",
"CodeSniffer/Standards/Generic/Sniffs/",
"CodeSniffer/Standards/MySource/Sniffs/",
"CodeSniffer/Standards/PEAR/Sniffs/",
"CodeSniffer/Standards/PSR1/Sniffs/",
"CodeSniffer/Standards/PSR2/Sniffs/",
"CodeSniffer/Standards/Squiz/Sniffs/",
"CodeSniffer/Standards/Zend/Sniffs/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
......@@ -1448,27 +1424,30 @@
"phpcs",
"standards"
],
"time": "2017-03-01T22:17:45+00:00"
"time": "2017-12-19T21:44:46+00:00"
},
{
"name": "symfony/yaml",
"version": "v3.2.7",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621"
"reference": "25c192f25721a74084272671f658797d9e0e0146"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621",
"reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621",
"url": "https://api.github.com/repos/symfony/yaml/zipball/25c192f25721a74084272671f658797d9e0e0146",
"reference": "25c192f25721a74084272671f658797d9e0e0146",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
"php": "^5.5.9|>=7.0.8"
},
"conflict": {
"symfony/console": "<3.4"
},
"require-dev": {
"symfony/console": "~2.8|~3.0"
"symfony/console": "~3.4|~4.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
......@@ -1476,7 +1455,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
"dev-master": "3.4-dev"
}
},
"autoload": {
......@@ -1503,7 +1482,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2017-03-20T09:45:15+00:00"
"time": "2018-01-03T07:37:34+00:00"
},
{
"name": "webmozart/assert",
......
......@@ -290,13 +290,7 @@ class SendtochannelCommand extends AdminCommand
$data['longitude'] = $message->getLocation()->getLongitude();
}
$callback_path = 'Longman\TelegramBot\Request';
$callback_function = 'send' . ucfirst($type);
if (!method_exists($callback_path, $callback_function)) {
throw new TelegramException('Methods: ' . $callback_function . ' not found in class Request.');
}
return $callback_path::$callback_function($data);
return Request::send('send' . ucfirst($type), $data);
}
/**
......
......@@ -260,17 +260,13 @@ class DB
/**
* Convert from unix timestamp to timestamp
*
* @param int $time Unix timestamp (if null, current timestamp is used)
* @param int $time Unix timestamp (if empty, current timestamp is used)
*
* @return string
*/
protected static function getTimestamp($time = null)
{
if ($time === null) {
$time = time();
}
return date('Y-m-d H:i:s', $time);
return date('Y-m-d H:i:s', $time ?: time());
}
/**
......@@ -362,7 +358,7 @@ class DB
* @return bool If the insert was successful
* @throws TelegramException
*/
public static function insertUser(User $user, $date, Chat $chat = null)
public static function insertUser(User $user, $date = null, Chat $chat = null)
{
if (!self::isDbConnected()) {
return false;
......@@ -389,6 +385,7 @@ class DB
$sth->bindValue(':first_name', $user->getFirstName());
$sth->bindValue(':last_name', $user->getLastName());
$sth->bindValue(':language_code', $user->getLanguageCode());
$date = $date ?: self::getTimestamp();
$sth->bindValue(':created_at', $date);
$sth->bindValue(':updated_at', $date);
......@@ -429,7 +426,7 @@ class DB
* @return bool If the insert was successful
* @throws TelegramException
*/
public static function insertChat(Chat $chat, $date, $migrate_to_chat_id = null)
public static function insertChat(Chat $chat, $date = null, $migrate_to_chat_id = null)
{
if (!self::isDbConnected()) {
return false;
......@@ -466,6 +463,7 @@ class DB
$sth->bindValue(':title', $chat->getTitle());
$sth->bindValue(':username', $chat->getUsername());
$sth->bindValue(':all_members_are_administrators', $chat->getAllMembersAreAdministrators(), PDO::PARAM_INT);
$date = $date ?: self::getTimestamp();
$sth->bindValue(':created_at', $date);
$sth->bindValue(':updated_at', $date);
......@@ -494,10 +492,6 @@ class DB
$update_id = $update->getUpdateId();
$update_type = $update->getUpdateType();
if (count(self::selectTelegramUpdate(1, $update_id)) === 1) {
throw new TelegramException('Duplicate update received!');
}
// @todo Make this simpler: if ($message = $update->getMessage()) ...
if ($update_type === 'message') {
$message = $update->getMessage();
......@@ -835,7 +829,7 @@ class DB
`location`, `venue`, `new_chat_members`, `left_chat_member`,
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
`supergroup_chat_created`, `channel_chat_created`,
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`, `connected_website`
) VALUES (
:message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
:forward_date, :reply_to_chat, :reply_to_message, :media_group_id, :text, :entities, :audio, :document,
......@@ -843,7 +837,7 @@ class DB
:location, :venue, :new_chat_members, :left_chat_member,
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
:supergroup_chat_created, :channel_chat_created,
:migrate_from_chat_id, :migrate_to_chat_id, :pinned_message
:migrate_from_chat_id, :migrate_to_chat_id, :pinned_message, :connected_website
)
');
......@@ -904,6 +898,7 @@ class DB
$sth->bindValue(':migrate_from_chat_id', $message->getMigrateFromChatId());
$sth->bindValue(':migrate_to_chat_id', $message->getMigrateToChatId());
$sth->bindValue(':pinned_message', $message->getPinnedMessage());
$sth->bindValue(':connected_website', $message->getConnectedWebsite());
return $sth->execute();
} catch (PDOException $e) {
......
......@@ -67,12 +67,18 @@ class InlineKeyboardButton extends KeyboardButton
$num_params = 0;
foreach (['url', 'callback_data', 'switch_inline_query', 'switch_inline_query_current_chat', 'callback_game', 'pay'] as $param) {
foreach (['url', 'callback_data', 'callback_game', 'pay'] as $param) {
if ($this->getProperty($param, '') !== '') {
$num_params++;
}
}
foreach (['switch_inline_query', 'switch_inline_query_current_chat'] as $param) {
if ($this->getProperty($param) !== null) {
$num_params++;
}
}
if ($num_params !== 1) {
throw new TelegramException('You must use only one of these fields: url, callback_data, switch_inline_query, switch_inline_query_current_chat, callback_game, pay!');
}
......
......@@ -11,6 +11,7 @@
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Entities\InlineQuery\InlineQueryResult;
use Longman\TelegramBot\Request;
/**
* Class InlineQuery
......
......@@ -20,10 +20,11 @@ use Longman\TelegramBot\Entities\Entity;
* <code>
* $data = [
* 'media' => '123abc',
* 'caption' => 'Video caption',
* 'caption' => 'Video caption (streamable)',
* 'width' => 800,
* 'heidht' => 600,
* 'duration' => 42
* 'height' => 600,
* 'duration' => 42,
* 'supports_streaming' => true
* ];
* </code>
*
......@@ -33,12 +34,14 @@ use Longman\TelegramBot\Entities\Entity;
* @method int getWidth() Optional. Video width
* @method int getHeight() Optional. Video height
* @method int getDuration() Optional. Video duration
* @method bool getSupportsStreaming() Optional. Pass True, if the uploaded video is suitable for streaming
*
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
* @method $this setCaption(string $caption) Optional. Caption of the video to be sent, 0-200 characters
* @method $this setWidth(int $width) Optional. Video width
* @method $this setHeight(int $height) Optional. Video height
* @method $this setDuration(int $duration) Optional. Video duration
* @method $this setSupportsStreaming(bool $supports_streaming) Optional. Pass True, if the uploaded video is suitable for streaming
*/
class InputMediaVideo extends Entity implements InputMedia
{
......
......@@ -54,6 +54,7 @@ use Longman\TelegramBot\Entities\Payments\SuccessfulPayment;
* @method Message getPinnedMessage() 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.
* @method Invoice getInvoice() Optional. Message is an invoice for a payment, information about the invoice.
* @method SuccessfulPayment getSuccessfulPayment() Optional. Message is a service message about a successful payment, information about the payment.
* @method string getConnectedWebsite() Optional. The domain name of the website on which the user has logged in.
*/
class Message extends Entity
{
......
......@@ -30,7 +30,7 @@ class Telegram
*
* @var string
*/
protected $version = '0.51.0';
protected $version = '0.52.0';
/**
* Telegram API key
......@@ -137,6 +137,21 @@ class Telegram
*/
protected $run_commands = false;
/**
* Is running getUpdates without DB enabled
*
* @var bool
*/
protected $getupdates_without_database = false;
/**
* Last update ID
* Only used when running getUpdates without a database
*
* @var integer
*/
protected $last_update_id = null;
/**
* Telegram constructor.
*
......@@ -320,26 +335,33 @@ class Telegram
throw new TelegramException('Bot Username is not defined!');
}
if (!DB::isDbConnected()) {
if (!DB::isDbConnected() && !$this->getupdates_without_database) {
return new ServerResponse(
[
'ok' => false,
'description' => 'getUpdates needs MySQL connection!',
'description' => 'getUpdates needs MySQL connection! (This can be overridden - see documentation)',
],
$this->bot_username
);
}
$offset = 0;
//Take custom input into account.
if ($custom_input = $this->getCustomInput()) {
$response = new ServerResponse(json_decode($custom_input, true), $this->bot_username);
} else {
//DB Query
if (DB::isDbConnected()) {
//Get last update id from the database
$last_update = DB::selectTelegramUpdate(1);
$last_update = reset($last_update);
//As explained in the telegram bot api documentation
$offset = isset($last_update['id']) ? $last_update['id'] + 1 : null;
$this->last_update_id = isset($last_update['id']) ? $last_update['id'] : null;
}
if ($this->last_update_id !== null) {
$offset = $this->last_update_id + 1; //As explained in the telegram bot API documentation
}
$response = Request::getUpdates(
[
......@@ -351,11 +373,24 @@ class Telegram
}
if ($response->isOk()) {
$results = $response->getResult();
//Process all updates
/** @var Update $result */
foreach ((array) $response->getResult() as $result) {
foreach ($results as $result) {
$this->processUpdate($result);
}
if (!DB::isDbConnected() && !$custom_input && $this->last_update_id !== null && $offset === 0) {
//Mark update(s) as read after handling
Request::getUpdates(
[
'offset' => $this->last_update_id + 1,
'limit' => 1,
'timeout' => $timeout,
]
);
}
}
return $response;
......@@ -415,6 +450,7 @@ class Telegram
public function processUpdate(Update $update)
{
$this->update = $update;
$this->last_update_id = $update->getUpdateId();
//If all else fails, it's a generic message.
$command = 'genericmessage';
......@@ -457,6 +493,13 @@ class Telegram
//This is necessary to "require" all the necessary command files!
$this->getCommandsList();
//Make sure we don't try to process update that was already processed
$last_id = DB::selectTelegramUpdate(1, $this->update->getUpdateId());
if ($last_id && count($last_id) === 1) {
TelegramLog::debug('Duplicate update received, processing aborted!');
return Request::emptyResponse();
}
DB::insertRequest($this->update);
return $this->executeCommand($command);
......@@ -855,8 +898,7 @@ class Telegram
*/
protected function ucfirstUnicode($str, $encoding = 'UTF-8')
{
return
mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding)
return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding)
. mb_strtolower(mb_substr($str, 1, mb_strlen($str), $encoding), $encoding);
}
......@@ -959,4 +1001,24 @@ class Telegram
{
return $this->run_commands;
}
/**
* Switch to enable running getUpdates without a database
*
* @param bool $enable
*/
public function useGetUpdatesWithoutDatabase($enable = true)
{
$this->getupdates_without_database = $enable;
}
/**
* Return last update id
*
* @return int
*/
public function getLastUpdateId()
{
return $this->last_update_id;
}
}
......@@ -102,6 +102,7 @@ CREATE TABLE IF NOT EXISTS `message` (
`migrate_to_chat_id` bigint NULL DEFAULT NULL COMMENT 'Migrate to chat identifier. The group has been migrated to a supergroup with the specified identifier',
`migrate_from_chat_id` bigint NULL DEFAULT NULL COMMENT 'Migrate from chat identifier. The supergroup has been migrated from a group with the specified identifier',
`pinned_message` TEXT NULL COMMENT 'Message object. Specified message was pinned',
`connected_website` TEXT NULL COMMENT 'The domain name of the website on which the user has logged in.',
PRIMARY KEY (`chat_id`, `id`),
KEY `user_id` (`user_id`),
......
......@@ -99,7 +99,9 @@ class InlineKeyboardButtonTest extends TestCase
new InlineKeyboardButton(['text' => 'message', 'url' => 'url_value']);
new InlineKeyboardButton(['text' => 'message', 'callback_data' => 'callback_data_value']);
new InlineKeyboardButton(['text' => 'message', 'switch_inline_query' => 'switch_inline_query_value']);
new InlineKeyboardButton(['text' => 'message', 'switch_inline_query' => '']); // Allow empty string.
new InlineKeyboardButton(['text' => 'message', 'switch_inline_query_current_chat' => 'switch_inline_query_current_chat_value']);
new InlineKeyboardButton(['text' => 'message', 'switch_inline_query_current_chat' => '']); // Allow empty string.
new InlineKeyboardButton(['text' => 'message', 'callback_game' => new CallbackGame([])]);
new InlineKeyboardButton(['text' => 'message', 'pay' => true]);
}
......
ALTER TABLE `message` ADD COLUMN `connected_website` TEXT NULL COMMENT 'The domain name of the website on which the user has logged in.' AFTER `pinned_message`;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment