<?php require_once 'lib/medoo.php'; require_once 'class/log.class.php'; require __DIR__ . '/vendor/autoload.php'; if (file_exists('config.php')) { require_once 'config.php'; } else { die('Local config not found. Please create one from config.sample.php and name it config.php'); } require_once 'class/log.class.php'; require __DIR__ . '/vendor/autoload.php'; try { log::addLog('Chiamata webhooks'); // create Telegram API object $telegram = new Longman\TelegramBot\Telegram($token, $botname); $telegram->enableMySQL($credentials); $telegram->enableAdmins(array($adminId)); $telegram->setLogRequests(true); $telegram->setLogPath($botname . '.log'); $COMMANDS_FOLDER = __DIR__ . '/command/'; $telegram->addCommandsPath($COMMANDS_FOLDER); } catch (Longman\TelegramBot\Exception\TelegramException $e) { log::addLog(print_r($e, true)); }
<?php //Composer Loader $loader = (require __DIR__ . '/vendor/autoload.php'); $API_KEY = '146668771:AAE9_zVF-YnDco0RcR-xxycUXeh1Cs15E6o'; $BOT_NAME = 'OfertixItBot'; $COMMANDS_FOLDER = __DIR__ . '/src/Commands/'; //$credentials = array('host'=>'localhost', 'user'=>'dbuser', 'password'=>'dbpass', 'database'=>'dbname'); try { // create Telegram API object $telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME); //Options //$telegram->enableMySQL($credentials); //$telegram->enableMySQL($credentials, $BOT_NAME.'_'); $telegram->addCommandsPath($COMMANDS_FOLDER); // here you can set some command specified parameters, // for example, google geocode/timezone api key for date command: //$telegram->setCommandConfig('date', array('google_api_key'=>'your_google_api_key_here')); $telegram->setLogRequests(true); $telegram->setLogPath($BOT_NAME . '.log'); $telegram->setLogVerbosity(4); //$telegram->setDownloadPath("../Download"); //$telegram->setUploadPath("../Upload"); // handle telegram webhook request $telegram->handle(); } catch (Longman\TelegramBot\Exception\TelegramException $e) { // log telegram errors echo $e; } catch (\Exception $e) { echo $e->getMessage(); }