You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB

1 year ago
  1. <?php
  2. /**
  3. * This file is part of the PHP Telegram Bot example-bot package.
  4. * https://github.com/php-telegram-bot/example-bot/
  5. *
  6. * (c) PHP Telegram Bot Team
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. /**
  12. * This file is used to run a list of commands with crontab.
  13. */
  14. // Your command(s) to run, pass them just like in a message (arguments supported)
  15. $commands = [
  16. '/whoami',
  17. "/echo I'm a bot!",
  18. ];
  19. // Load composer
  20. require_once __DIR__ . '/vendor/autoload.php';
  21. // Load all configuration options
  22. /** @var array $config */
  23. $config = require __DIR__ . '/config.php';
  24. try {
  25. // Create Telegram API object
  26. $telegram = new Longman\TelegramBot\Telegram($config['api_key'], $config['bot_username']);
  27. /**
  28. * Check `hook.php` for configuration code to be added here.
  29. */
  30. // Run user selected commands
  31. $telegram->runCommands($commands);
  32. } catch (Longman\TelegramBot\Exception\TelegramException $e) {
  33. // Log telegram errors
  34. Longman\TelegramBot\TelegramLog::error($e);
  35. // Uncomment this to output any errors (ONLY FOR DEVELOPMENT!)
  36. // echo $e;
  37. } catch (Longman\TelegramBot\Exception\TelegramLogException $e) {
  38. // Uncomment this to output log initialisation errors (ONLY FOR DEVELOPMENT!)
  39. // echo $e;
  40. }