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 sudo: required
language: php language: php
...@@ -14,6 +14,7 @@ php: ...@@ -14,6 +14,7 @@ php:
- 5.6 - 5.6
- 7.0 - 7.0
- 7.1 - 7.1
- 7.2
- nightly - nightly
- hhvm - hhvm
...@@ -42,7 +43,7 @@ before_script: ...@@ -42,7 +43,7 @@ before_script:
script: script:
- composer check-code - 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: 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 ...@@ -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. Exclamation symbols (:exclamation:) note something of importance e.g. breaking changes. Click them to learn more.
## [Unreleased] ## [Unreleased]
:exclamation: After updating to this version, you will need to execute the [SQL migration script][unreleased-sql-migration] on your database.
### Added ### 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! - Telegram Games platform!
### Changed ### 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 ### Deprecated
### Removed ### Removed
### Fixed ### Fixed
- Entity relations and wrong types for payments. - PHPCS fixes for updated CodeSniffer dependency.
- Send messages correctly via `/sendtochannel`.
### Security ### 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 ## [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. :exclamation: After updating to this version, you will need to execute the [SQL migration script][0.51.0-sql-migration] on your database.
### Added ### Added
...@@ -185,6 +199,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ...@@ -185,6 +199,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Deprecated ### Deprecated
- Move `hideKeyboard` to `removeKeyboard`. - 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.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.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 [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 ...@@ -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 [example-bot]: https://github.com/php-telegram-bot/example-bot
[Unreleased]: https://github.com/php-telegram-bot/core/compare/master...develop [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.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.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 [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 ...@@ -23,6 +23,5 @@ W: http://noplanman.ch
D: Maintainer and Collaborator D: Maintainer and Collaborator
N: Jack'lul (alias) N: Jack'lul (alias)
E: jacklul@jacklul.com E: jacklulcat@gmail.com
W: http://jacklul.com
D: Maintainer and Collaborator D: Maintainer and Collaborator
...@@ -186,7 +186,7 @@ The bot can handle updates with **Webhook** or **getUpdates** method: ...@@ -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 | | Description | Telegram sends the updates directly to your host | You have to fetch Telegram updates manually |
| Host with https | Required | Not required | | Host with https | Required | Not required |
| MySQL | Not required | Required | | MySQL | Not required | ([Not](#getupdates-without-database)) Required |
## Webhook installation ## Webhook installation
...@@ -257,9 +257,9 @@ $result = $telegram->setWebhook($hook_url, ['certificate' => '/path/to/certifica ...@@ -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. 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: Create [*getUpdatesCLI.php*][getUpdatesCLI.php] with the following contents:
```php ```php
...@@ -301,6 +301,13 @@ Lastly, run it! ...@@ -301,6 +301,13 @@ Lastly, run it!
$ ./getUpdatesCLI.php $ ./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 ## Support
### Types ### Types
......
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
"ext-pdo": "*", "ext-pdo": "*",
"ext-curl": "*", "ext-curl": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"monolog/monolog": "^1.22", "monolog/monolog": "^1.23",
"guzzlehttp/guzzle": "^6.2" "guzzlehttp/guzzle": "^6.3"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^4.8|^5.7|^6.1", "phpunit/phpunit": "^4.8|^5.7|^6.5",
"squizlabs/php_codesniffer": "^2.8" "squizlabs/php_codesniffer": "^3.2"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
...@@ -41,13 +41,13 @@ ...@@ -41,13 +41,13 @@
}, },
"scripts": { "scripts": {
"check-code": [ "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": [ "test": [
"./vendor/bin/phpunit" "\"vendor/bin/phpunit\""
], ],
"test-cov": [ "test-cov": [
"./vendor/bin/phpunit --coverage-clover build/logs/clover.xml" "\"vendor/bin/phpunit\" --coverage-clover build/logs/clover.xml"
], ],
"test-cov-upload": [ "test-cov-upload": [
"wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml" "wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml"
......
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "fc20b65f31ecd6a88d148f48e89fd4f7", "content-hash": "1fd4b486f04a942aca0767e94431f284",
"packages": [ "packages": [
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
"version": "6.2.3", "version": "6.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/guzzle/guzzle.git", "url": "https://github.com/guzzle/guzzle.git",
"reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006" "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/8d6c6cc55186db87b7dc5009827429ba4e9dc006", "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699",
"reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006", "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -27,9 +27,12 @@ ...@@ -27,9 +27,12 @@
}, },
"require-dev": { "require-dev": {
"ext-curl": "*", "ext-curl": "*",
"phpunit/phpunit": "^4.0", "phpunit/phpunit": "^4.0 || ^5.0",
"psr/log": "^1.0" "psr/log": "^1.0"
}, },
"suggest": {
"psr/log": "Required for using the Log middleware"
},
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
...@@ -66,7 +69,7 @@ ...@@ -66,7 +69,7 @@
"rest", "rest",
"web service" "web service"
], ],
"time": "2017-02-28T22:50:30+00:00" "time": "2017-06-22T18:50:49+00:00"
}, },
{ {
"name": "guzzlehttp/promises", "name": "guzzlehttp/promises",
...@@ -186,16 +189,16 @@ ...@@ -186,16 +189,16 @@
}, },
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "1.22.1", "version": "1.23.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Seldaek/monolog.git", "url": "https://github.com/Seldaek/monolog.git",
"reference": "1e044bc4b34e91743943479f1be7a1d5eb93add0" "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/1e044bc4b34e91743943479f1be7a1d5eb93add0", "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
"reference": "1e044bc4b34e91743943479f1be7a1d5eb93add0", "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -216,7 +219,7 @@ ...@@ -216,7 +219,7 @@
"phpunit/phpunit-mock-objects": "2.3.0", "phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0", "ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13", "sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "~5.3" "swiftmailer/swiftmailer": "^5.3|^6.0"
}, },
"suggest": { "suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
...@@ -260,7 +263,7 @@ ...@@ -260,7 +263,7 @@
"logging", "logging",
"psr-3" "psr-3"
], ],
"time": "2017-03-13T07:08:03+00:00" "time": "2017-06-19T01:22:40+00:00"
}, },
{ {
"name": "psr/http-message", "name": "psr/http-message",
...@@ -417,16 +420,16 @@ ...@@ -417,16 +420,16 @@
}, },
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
"version": "1.0", "version": "1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -467,26 +470,26 @@ ...@@ -467,26 +470,26 @@
"reflection", "reflection",
"static analysis" "static analysis"
], ],
"time": "2015-12-27T11:43:31+00:00" "time": "2017-09-11T18:02:19+00:00"
}, },
{ {
"name": "phpdocumentor/reflection-docblock", "name": "phpdocumentor/reflection-docblock",
"version": "3.1.1", "version": "3.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/4aada1f93c72c35e22fb1383b47fee43b8f1d157",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.5", "php": ">=5.5",
"phpdocumentor/reflection-common": "^1.0@dev", "phpdocumentor/reflection-common": "^1.0@dev",
"phpdocumentor/type-resolver": "^0.2.0", "phpdocumentor/type-resolver": "^0.3.0",
"webmozart/assert": "^1.0" "webmozart/assert": "^1.0"
}, },
"require-dev": { "require-dev": {
...@@ -512,24 +515,24 @@ ...@@ -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.", "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", "name": "phpdocumentor/type-resolver",
"version": "0.2.1", "version": "0.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git", "url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fb3933512008d8162b3cdf9e18dba9309b7c3773",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.5", "php": "^5.5 || ^7.0",
"phpdocumentor/reflection-common": "^1.0" "phpdocumentor/reflection-common": "^1.0"
}, },
"require-dev": { "require-dev": {
...@@ -559,37 +562,37 @@ ...@@ -559,37 +562,37 @@
"email": "me@mikevanriel.com" "email": "me@mikevanriel.com"
} }
], ],
"time": "2016-11-25T06:54:22+00:00" "time": "2017-06-03T08:32:36+00:00"
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
"version": "v1.7.0", "version": "1.7.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/prophecy.git", "url": "https://github.com/phpspec/prophecy.git",
"reference": "93d39f1f7f9326d746203c7c056f300f7f126073" "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", "url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
"reference": "93d39f1f7f9326d746203c7c056f300f7f126073", "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/instantiator": "^1.0.2", "doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0", "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/comparator": "^1.1|^2.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0" "sebastian/recursion-context": "^1.0|^2.0|^3.0"
}, },
"require-dev": { "require-dev": {
"phpspec/phpspec": "^2.5|^3.2", "phpspec/phpspec": "^2.5|^3.2",
"phpunit/phpunit": "^4.8 || ^5.6.5" "phpunit/phpunit": "^4.8.35 || ^5.7"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.6.x-dev" "dev-master": "1.7.x-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -622,7 +625,7 @@ ...@@ -622,7 +625,7 @@
"spy", "spy",
"stub" "stub"
], ],
"time": "2017-03-02T20:05:34+00:00" "time": "2017-11-24T13:59:53+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
...@@ -688,16 +691,16 @@ ...@@ -688,16 +691,16 @@
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
"version": "1.4.2", "version": "1.4.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4",
"reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -731,7 +734,7 @@ ...@@ -731,7 +734,7 @@
"filesystem", "filesystem",
"iterator" "iterator"
], ],
"time": "2016-10-03T07:40:28+00:00" "time": "2017-11-27T13:52:08+00:00"
}, },
{ {
"name": "phpunit/php-text-template", "name": "phpunit/php-text-template",
...@@ -825,16 +828,16 @@ ...@@ -825,16 +828,16 @@
}, },
{ {
"name": "phpunit/php-token-stream", "name": "phpunit/php-token-stream",
"version": "1.4.11", "version": "1.4.12",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git", "url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16",
"reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -870,20 +873,20 @@ ...@@ -870,20 +873,20 @@
"keywords": [ "keywords": [
"tokenizer" "tokenizer"
], ],
"time": "2017-02-27T10:12:30+00:00" "time": "2017-12-04T08:55:13+00:00"
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "4.8.35", "version": "4.8.36",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87" "reference": "46023de9a91eec7dfb06cc56cb4e260017298517"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/791b1a67c25af50e230f841ee7a9c6eba507dc87", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517",
"reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87", "reference": "46023de9a91eec7dfb06cc56cb4e260017298517",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -942,7 +945,7 @@ ...@@ -942,7 +945,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2017-02-06T05:18:07+00:00" "time": "2017-06-21T08:07:12+00:00"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
...@@ -1066,23 +1069,23 @@ ...@@ -1066,23 +1069,23 @@
}, },
{ {
"name": "sebastian/diff", "name": "sebastian/diff",
"version": "1.4.1", "version": "1.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/diff.git", "url": "https://github.com/sebastianbergmann/diff.git",
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4",
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": "^5.3.3 || ^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.8" "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
...@@ -1114,7 +1117,7 @@ ...@@ -1114,7 +1117,7 @@
"keywords": [ "keywords": [
"diff" "diff"
], ],
"time": "2015-12-08T07:14:41+00:00" "time": "2017-05-22T07:24:03+00:00"
}, },
{ {
"name": "sebastian/environment", "name": "sebastian/environment",
...@@ -1374,64 +1377,37 @@ ...@@ -1374,64 +1377,37 @@
}, },
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "2.8.1", "version": "3.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d" "reference": "d7c00c3000ac0ce79c96fcbfef86b49a71158cd1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7c00c3000ac0ce79c96fcbfef86b49a71158cd1",
"reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", "reference": "d7c00c3000ac0ce79c96fcbfef86b49a71158cd1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-simplexml": "*", "ext-simplexml": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"php": ">=5.1.2" "php": ">=5.4.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0" "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0"
}, },
"bin": [ "bin": [
"scripts/phpcs", "bin/phpcs",
"scripts/phpcbf" "bin/phpcbf"
], ],
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "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/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
...@@ -1448,27 +1424,30 @@ ...@@ -1448,27 +1424,30 @@
"phpcs", "phpcs",
"standards" "standards"
], ],
"time": "2017-03-01T22:17:45+00:00" "time": "2017-12-19T21:44:46+00:00"
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v3.2.7", "version": "v3.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
"reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621" "reference": "25c192f25721a74084272671f658797d9e0e0146"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621", "url": "https://api.github.com/repos/symfony/yaml/zipball/25c192f25721a74084272671f658797d9e0e0146",
"reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621", "reference": "25c192f25721a74084272671f658797d9e0e0146",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.5.9" "php": "^5.5.9|>=7.0.8"
},
"conflict": {
"symfony/console": "<3.4"
}, },
"require-dev": { "require-dev": {
"symfony/console": "~2.8|~3.0" "symfony/console": "~3.4|~4.0"
}, },
"suggest": { "suggest": {
"symfony/console": "For validating YAML files using the lint command" "symfony/console": "For validating YAML files using the lint command"
...@@ -1476,7 +1455,7 @@ ...@@ -1476,7 +1455,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.2-dev" "dev-master": "3.4-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -1503,7 +1482,7 @@ ...@@ -1503,7 +1482,7 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-03-20T09:45:15+00:00" "time": "2018-01-03T07:37:34+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",
......
...@@ -290,13 +290,7 @@ class SendtochannelCommand extends AdminCommand ...@@ -290,13 +290,7 @@ class SendtochannelCommand extends AdminCommand
$data['longitude'] = $message->getLocation()->getLongitude(); $data['longitude'] = $message->getLocation()->getLongitude();
} }
$callback_path = 'Longman\TelegramBot\Request'; return Request::send('send' . ucfirst($type), $data);
$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);
} }
/** /**
......
...@@ -260,17 +260,13 @@ class DB ...@@ -260,17 +260,13 @@ class DB
/** /**
* Convert from unix timestamp to timestamp * 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 * @return string
*/ */
protected static function getTimestamp($time = null) protected static function getTimestamp($time = null)
{ {
if ($time === null) { return date('Y-m-d H:i:s', $time ?: time());
$time = time();
}
return date('Y-m-d H:i:s', $time);
} }
/** /**
...@@ -362,7 +358,7 @@ class DB ...@@ -362,7 +358,7 @@ class DB
* @return bool If the insert was successful * @return bool If the insert was successful
* @throws TelegramException * @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()) { if (!self::isDbConnected()) {
return false; return false;
...@@ -389,6 +385,7 @@ class DB ...@@ -389,6 +385,7 @@ class DB
$sth->bindValue(':first_name', $user->getFirstName()); $sth->bindValue(':first_name', $user->getFirstName());
$sth->bindValue(':last_name', $user->getLastName()); $sth->bindValue(':last_name', $user->getLastName());
$sth->bindValue(':language_code', $user->getLanguageCode()); $sth->bindValue(':language_code', $user->getLanguageCode());
$date = $date ?: self::getTimestamp();
$sth->bindValue(':created_at', $date); $sth->bindValue(':created_at', $date);
$sth->bindValue(':updated_at', $date); $sth->bindValue(':updated_at', $date);
...@@ -429,7 +426,7 @@ class DB ...@@ -429,7 +426,7 @@ class DB
* @return bool If the insert was successful * @return bool If the insert was successful
* @throws TelegramException * @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()) { if (!self::isDbConnected()) {
return false; return false;
...@@ -466,6 +463,7 @@ class DB ...@@ -466,6 +463,7 @@ class DB
$sth->bindValue(':title', $chat->getTitle()); $sth->bindValue(':title', $chat->getTitle());
$sth->bindValue(':username', $chat->getUsername()); $sth->bindValue(':username', $chat->getUsername());
$sth->bindValue(':all_members_are_administrators', $chat->getAllMembersAreAdministrators(), PDO::PARAM_INT); $sth->bindValue(':all_members_are_administrators', $chat->getAllMembersAreAdministrators(), PDO::PARAM_INT);
$date = $date ?: self::getTimestamp();
$sth->bindValue(':created_at', $date); $sth->bindValue(':created_at', $date);
$sth->bindValue(':updated_at', $date); $sth->bindValue(':updated_at', $date);
...@@ -494,10 +492,6 @@ class DB ...@@ -494,10 +492,6 @@ class DB
$update_id = $update->getUpdateId(); $update_id = $update->getUpdateId();
$update_type = $update->getUpdateType(); $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()) ... // @todo Make this simpler: if ($message = $update->getMessage()) ...
if ($update_type === 'message') { if ($update_type === 'message') {
$message = $update->getMessage(); $message = $update->getMessage();
...@@ -835,7 +829,7 @@ class DB ...@@ -835,7 +829,7 @@ class DB
`location`, `venue`, `new_chat_members`, `left_chat_member`, `location`, `venue`, `new_chat_members`, `left_chat_member`,
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`, `new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
`supergroup_chat_created`, `channel_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 ( ) VALUES (
:message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id, :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, :forward_date, :reply_to_chat, :reply_to_message, :media_group_id, :text, :entities, :audio, :document,
...@@ -843,7 +837,7 @@ class DB ...@@ -843,7 +837,7 @@ class DB
:location, :venue, :new_chat_members, :left_chat_member, :location, :venue, :new_chat_members, :left_chat_member,
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created, :new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
:supergroup_chat_created, :channel_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 ...@@ -904,6 +898,7 @@ class DB
$sth->bindValue(':migrate_from_chat_id', $message->getMigrateFromChatId()); $sth->bindValue(':migrate_from_chat_id', $message->getMigrateFromChatId());
$sth->bindValue(':migrate_to_chat_id', $message->getMigrateToChatId()); $sth->bindValue(':migrate_to_chat_id', $message->getMigrateToChatId());
$sth->bindValue(':pinned_message', $message->getPinnedMessage()); $sth->bindValue(':pinned_message', $message->getPinnedMessage());
$sth->bindValue(':connected_website', $message->getConnectedWebsite());
return $sth->execute(); return $sth->execute();
} catch (PDOException $e) { } catch (PDOException $e) {
......
...@@ -67,12 +67,18 @@ class InlineKeyboardButton extends KeyboardButton ...@@ -67,12 +67,18 @@ class InlineKeyboardButton extends KeyboardButton
$num_params = 0; $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, '') !== '') { if ($this->getProperty($param, '') !== '') {
$num_params++; $num_params++;
} }
} }
foreach (['switch_inline_query', 'switch_inline_query_current_chat'] as $param) {
if ($this->getProperty($param) !== null) {
$num_params++;
}
}
if ($num_params !== 1) { 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!'); 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 @@ ...@@ -11,6 +11,7 @@
namespace Longman\TelegramBot\Entities; namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Entities\InlineQuery\InlineQueryResult; use Longman\TelegramBot\Entities\InlineQuery\InlineQueryResult;
use Longman\TelegramBot\Request;
/** /**
* Class InlineQuery * Class InlineQuery
......
...@@ -19,26 +19,29 @@ use Longman\TelegramBot\Entities\Entity; ...@@ -19,26 +19,29 @@ use Longman\TelegramBot\Entities\Entity;
* *
* <code> * <code>
* $data = [ * $data = [
* 'media' => '123abc', * 'media' => '123abc',
* 'caption' => 'Video caption', * 'caption' => 'Video caption (streamable)',
* 'width' => 800, * 'width' => 800,
* 'heidht' => 600, * 'height' => 600,
* 'duration' => 42 * 'duration' => 42,
* 'supports_streaming' => true
* ]; * ];
* </code> * </code>
* *
* @method string getType() Type of the result, must be video * @method string getType() Type of the result, must be video
* @method string getMedia() 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 string getMedia() 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 string getCaption() Optional. Caption of the video to be sent, 0-200 characters * @method string getCaption() Optional. Caption of the video to be sent, 0-200 characters
* @method int getWidth() Optional. Video width * @method int getWidth() Optional. Video width
* @method int getHeight() Optional. Video height * @method int getHeight() Optional. Video height
* @method int getDuration() Optional. Video duration * @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 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 setCaption(string $caption) Optional. Caption of the video to be sent, 0-200 characters
* @method $this setWidth(int $width) Optional. Video width * @method $this setWidth(int $width) Optional. Video width
* @method $this setHeight(int $height) Optional. Video height * @method $this setHeight(int $height) Optional. Video height
* @method $this setDuration(int $duration) Optional. Video duration * @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 class InputMediaVideo extends Entity implements InputMedia
{ {
......
...@@ -54,6 +54,7 @@ use Longman\TelegramBot\Entities\Payments\SuccessfulPayment; ...@@ -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 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 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 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 class Message extends Entity
{ {
......
...@@ -30,7 +30,7 @@ class Telegram ...@@ -30,7 +30,7 @@ class Telegram
* *
* @var string * @var string
*/ */
protected $version = '0.51.0'; protected $version = '0.52.0';
/** /**
* Telegram API key * Telegram API key
...@@ -137,6 +137,21 @@ class Telegram ...@@ -137,6 +137,21 @@ class Telegram
*/ */
protected $run_commands = false; 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. * Telegram constructor.
* *
...@@ -320,26 +335,33 @@ class Telegram ...@@ -320,26 +335,33 @@ class Telegram
throw new TelegramException('Bot Username is not defined!'); throw new TelegramException('Bot Username is not defined!');
} }
if (!DB::isDbConnected()) { if (!DB::isDbConnected() && !$this->getupdates_without_database) {
return new ServerResponse( return new ServerResponse(
[ [
'ok' => false, 'ok' => false,
'description' => 'getUpdates needs MySQL connection!', 'description' => 'getUpdates needs MySQL connection! (This can be overridden - see documentation)',
], ],
$this->bot_username $this->bot_username
); );
} }
$offset = 0;
//Take custom input into account. //Take custom input into account.
if ($custom_input = $this->getCustomInput()) { if ($custom_input = $this->getCustomInput()) {
$response = new ServerResponse(json_decode($custom_input, true), $this->bot_username); $response = new ServerResponse(json_decode($custom_input, true), $this->bot_username);
} else { } else {
//DB Query if (DB::isDbConnected()) {
$last_update = DB::selectTelegramUpdate(1); //Get last update id from the database
$last_update = reset($last_update); $last_update = DB::selectTelegramUpdate(1);
$last_update = reset($last_update);
$this->last_update_id = isset($last_update['id']) ? $last_update['id'] : null;
}
//As explained in the telegram bot api documentation if ($this->last_update_id !== null) {
$offset = isset($last_update['id']) ? $last_update['id'] + 1 : null; $offset = $this->last_update_id + 1; //As explained in the telegram bot API documentation
}
$response = Request::getUpdates( $response = Request::getUpdates(
[ [
...@@ -351,11 +373,24 @@ class Telegram ...@@ -351,11 +373,24 @@ class Telegram
} }
if ($response->isOk()) { if ($response->isOk()) {
$results = $response->getResult();
//Process all updates //Process all updates
/** @var Update $result */ /** @var Update $result */
foreach ((array) $response->getResult() as $result) { foreach ($results as $result) {
$this->processUpdate($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; return $response;
...@@ -415,6 +450,7 @@ class Telegram ...@@ -415,6 +450,7 @@ class Telegram
public function processUpdate(Update $update) public function processUpdate(Update $update)
{ {
$this->update = $update; $this->update = $update;
$this->last_update_id = $update->getUpdateId();
//If all else fails, it's a generic message. //If all else fails, it's a generic message.
$command = 'genericmessage'; $command = 'genericmessage';
...@@ -457,6 +493,13 @@ class Telegram ...@@ -457,6 +493,13 @@ class Telegram
//This is necessary to "require" all the necessary command files! //This is necessary to "require" all the necessary command files!
$this->getCommandsList(); $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); DB::insertRequest($this->update);
return $this->executeCommand($command); return $this->executeCommand($command);
...@@ -855,9 +898,8 @@ class Telegram ...@@ -855,9 +898,8 @@ class Telegram
*/ */
protected function ucfirstUnicode($str, $encoding = 'UTF-8') protected function ucfirstUnicode($str, $encoding = 'UTF-8')
{ {
return return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding)
mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_strtolower(mb_substr($str, 1, mb_strlen($str), $encoding), $encoding);
. mb_strtolower(mb_substr($str, 1, mb_strlen($str), $encoding), $encoding);
} }
/** /**
...@@ -959,4 +1001,24 @@ class Telegram ...@@ -959,4 +1001,24 @@ class Telegram
{ {
return $this->run_commands; 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` ( ...@@ -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_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', `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', `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`), PRIMARY KEY (`chat_id`, `id`),
KEY `user_id` (`user_id`), KEY `user_id` (`user_id`),
......
...@@ -99,7 +99,9 @@ class InlineKeyboardButtonTest extends TestCase ...@@ -99,7 +99,9 @@ class InlineKeyboardButtonTest extends TestCase
new InlineKeyboardButton(['text' => 'message', 'url' => 'url_value']); new InlineKeyboardButton(['text' => 'message', 'url' => 'url_value']);
new InlineKeyboardButton(['text' => 'message', 'callback_data' => 'callback_data_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' => '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' => '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', 'callback_game' => new CallbackGame([])]);
new InlineKeyboardButton(['text' => 'message', 'pay' => true]); 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