Simple but very smart Telegram bot for processing various types of location format and converting them to user-defined formats.
Available publicly on Telegram as @BetterLocationBot and web better-location.palider.cz.
composer install --no-dev
- you need Composer to do that.APP_URL
and all DB_*
and TELEGRAM_*
constants in data/config.local.php
.
Install development depenencies via composer install --dev
.
Run PHPStan static analysis via composer phpstan
.
Baseline can be re-generated via composer phpstan-baseline
Run PHPUnit tests via composer test
which will run all tests available. For running only tests, that are very quick (great for precommit hook), run composer test-quick
.
@group request
(more in PHPUnit docs)This bot is supporting Telegram's deep linking using ?start=parameter
or ?startgroup=parameter
so you can create links from your website or app to directly perform one of actions listed below (currently only Show location).
Parameter start
will open in user's private message and create "start" button.
Parameter startgroup
works similarly, but user will be prompted to select group, where @BetterLocationBot will be added.
Show location as better message.
Because Telegram is very restrictive what can be in start parameter, WGS-84 coordinates are encoded as two parts (latlon) with `` as divider. To encode coordinate, multiply coordinate by 1 000 000 and round to integer.
Input coordinates | Encoded coordinates | Result link |
---|---|---|
50.733088,15.741169 |
50733088_15741169 |
https://t.me/BetterLocationBot?start=50733088_15741169 |
-14.7653,4.845524 |
-14765300_4845524 |
https://t.me/BetterLocationBot?start=-14765300_4845524 |
-41.326919711111,174.80770311111 |
-41326919_174807703 |
https://t.me/BetterLocationBot?start=-41326919_174807703 |
There are some internal usages of start parameters as add to favourite, but it is not recommended to use it from external applications, since it might change any time.
For encoding and decoding parameters are used InlineTextDecode()
, InlineTextEncode()
, generateStart()
and generateStartCoords()
methods from \App\TelegramCustomWrapper\TelegramHelper namespace.
Based on the simple DJTommek/php-template.