Skip to content

Migrating from core to manager

Armando Lüscher edited this page May 21, 2020 · 1 revision

So, you'd like to move from the classic core library to the manager?

This is very easy and can be done in a few simple steps, which apply for both webhook and getUpdates methods.

  1. You will need to change your composer.json to require the manager and update the version of the core library (replace <version> with the version of core you'd like). Add these two entries to your composer.json:
    • "longman/telegram-bot": "<version> as 0.59"
    • "php-telegram-bot/telegram-bot-manager": "^1.5"
  2. Run composer update to fetch the manager and update the core library.
  3. Take a look at the example-bot repo and get a copy of manager.php.
  4. Your set.php, unset.php and hook.php will all be managed by the same file (in this example manager.php).
  5. Move all variables that you have set in your hook.php into the new array format of the manager. (see list of all options)
  6. After setting all necessary values, you will need to reset the webhook to point to your new manager.php, via your CLI execute:
    • php manager.php a=reset
  7. Your new webhook should now be set and the bot should work as before, well done!
    • Check the webhook via CLI: php manager.php a=webhookinfo

The most important change from hook.php to manager.php is the added layer of security, which allows only Telegram servers to access the script from the internet and a necessary secret that is defined in the config. To modify any extra behaviour, be sure to read the full README

Clone this wiki locally