Здравствуйте!
Подскажите как правильно подключить и использовать с моделями Opencart библиотеки
https://github.com/TelegramBot/Api или
https://github.com/php-telegram-bot/core
Проблема не в Composer, а в том как получать данные из методов Opencart в бота Telegram.
Привожу код бота.
Не загружается $this->load->model('catalog/product');
<?php
class ControllerApiTelegram extends Controller {
public function index() {
try {
$bot = new \TelegramBot\Api\Client('токен');
// Запуск бота
$bot->command('start', function ($message) use ($bot) {
$answer = 'Добро пожаловать!';
$bot->sendMessage($message->getChat()->getId(), $answer);
});
// помощь
$bot->command('help', function ($message) use ($bot) {
$answer = 'Команды:
/help - помощь';
$bot->sendMessage($message->getChat()->getId(), $answer);
});
$bot->command('qaanswer', function ($message) use ($bot) {
$this->load->model('catalog/product'); // Загрузка модели Opencart
$pr = $this->model_catalog_product->getProduct(430); // вызов метода с аргументом
$bot->sendMessage($message->getChat()->getId(), str_replace("<br/>", "\n", $pr["price"]));
$bot->sendMessage($message->getChat()->getId(), str_replace("<br/>", "\n", "тестовый текст"));
});
$bot->run();
} catch (\TelegramBot\Api\Exception $e) {
$e->getMessage();
}
}
}