Commit 3b517ce5 authored by MBoretto's avatar MBoretto

examples

parent d6362448
......@@ -43,7 +43,7 @@ A Telegram Bot based on the official [Telegram Bot API](https://core.telegram.or
- [Set Admins](#set-admins)
- [Channel Administration](#channel-administration)
- [Upload and Download directory path](#upload-and-download-directory-path)
- [Logging](#logging)
- [Logging](doc/01-utils.md)
- [Documentation](#documentation)
- [Projects with this library](#projects-with-this-library)
- [Troubleshooting](#troubleshooting)
......@@ -511,27 +511,6 @@ $telegram->setDownloadPath('yourpath/Download');
$telegram->setUploadPath('yourpath/Upload');
```
### Logging
Thrown Exceptions are not stored by default. You can Enable this feature adding this line in your 'webhook.php' or 'getUpdates.php'
```php
Longman\TelegramBot\Logger::initialize('your_path/TelegramException.log');
```
Incoming update (json string from webhook and getUpdates) can be logged in a text file. Set those options with the methods:
```php
$telegram->setLogRequests(true);
$telegram->setLogPath($BOT_NAME . '.log');
```
Set verbosity to 3 to also log curl requests and responses from the bot to Telegram:
```php
$telegram->setLogRequests(true);
$telegram->setLogPath($BOT_NAME . '.log');
$telegram->setLogVerbosity(3);
```
## Documentation
Take a look at the repo [Wiki](https://github.com/akalongman/php-telegram-bot/wiki) for further information and tutorials!
......
......@@ -4,8 +4,8 @@
//This configuration file is intented to run the bot with the webhook method
//Uncommented parameters must be filled
#bash script
#while true; do ./getUpdatesCLI.php; done
//bash script
//while true; do ./getUpdatesCLI.php; done
// Load composer
require __DIR__ . '/vendor/autoload.php';
......@@ -42,9 +42,11 @@ try {
//$telegram->setCommandConfig('date', ['google_api_key' => 'your_google_api_key_here']);
//// Logging
//$telegram->setLogRequests(true);
//$telegram->setLogPath($BOT_NAME . '.log');
//$telegram->setLogVerbosity(3);
//$telegram->enableExternalLog($insert_ here_your_extenl_monolog_instance)
//$path = 'your_path'
//$telegram->setErrorLog($path . '/' . $BOT_NAME . '_error.log');
//$telegram->setDebugLog($path . '/' . $BOT_NAME . '_debug.log');
//$telegram->setUpdateLog($path . '/' . $BOT_NAME . '_update.log');
//// Set custom Upload and Download path
//$telegram->setDownloadPath('../Download');
......@@ -64,6 +66,7 @@ try {
echo $ServerResponse->printError() . "\n";
}
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// log telegram errors
echo $e;
// log telegram errors
\Longman\TelegramBot\TelegramLog::error($e);
}
......@@ -3,7 +3,7 @@
//This configuration file is intended to run the bot with the webhook method.
//Uncommented parameters must be filled
//Please notice that if you open this file with your browser you'll get the "Input is empty!" Exception.
//This is a normal behaviour because this address has to be reached only by Telegram server
//This is a normal behaviour because this address has to be reached only by Telegram server.
// Load composer
require __DIR__ . '/vendor/autoload.php';
......@@ -40,9 +40,11 @@ try {
//$telegram->setCommandConfig('date', ['google_api_key' => 'your_google_api_key_here']);
//// Logging
//$telegram->setLogRequests(true);
//$telegram->setLogPath($BOT_NAME . '.log');
//$telegram->setLogVerbosity(3);
//$telegram->enableExternalLog($insert_ here_your_extenl_monolog_instance)
//$path = 'your_path'
//$telegram->setErrorLog($path . '/' . $BOT_NAME . '_error.log');
//$telegram->setDebugLog($path . '/' . $BOT_NAME . '_debug.log');
//$telegram->setUpdateLog($path . '/' . $BOT_NAME . '_update.log');
//// Set custom Upload and Download path
//$telegram->setDownloadPath('../Download');
......@@ -55,6 +57,7 @@ try {
$telegram->handle();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// Silence is golden!
// log telegram errors
// echo $e;
// log telegram errors
\Longman\TelegramBot\TelegramLog::error($e);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment