/
var
/
www
/
cobraambalaj
/
vendor
/
monolog
/
monolog
/
src
/
Monolog
/
Handler
/
/var/www/cobraambalaj/vendor/monolog/monolog/src/Monolog/Handler
mkdir
upload
Name
Size
Mode
Actions
Curl/
-
0755
rm
FingersCrossed/
-
0755
rm
Slack/
-
0755
rm
SyslogUdp/
-
0755
rm
AbstractHandler.php
2287
0644
edit
dl
rm
AbstractProcessingHandler.php
1433
0644
edit
dl
rm
AbstractSyslogHandler.php
3584
0644
edit
dl
rm
AmqpHandler.php
4038
0644
edit
dl
rm
BrowserConsoleHandler.php
7622
0644
edit
dl
rm
BufferHandler.php
4674
0644
edit
dl
rm
ChromePHPHandler.php
5252
0644
edit
dl
rm
CouchDBHandler.php
2032
0644
edit
dl
rm
CubeHandler.php
4849
0644
edit
dl
rm
DeduplicationHandler.php
5695
0644
edit
dl
rm
DoctrineCouchDBHandler.php
1098
0644
edit
dl
rm
DynamoDbHandler.php
2460
0644
edit
dl
rm
ElasticaHandler.php
3423
0644
edit
dl
rm
ElasticsearchHandler.php
5470
0644
edit
dl
rm
ErrorLogHandler.php
2512
0644
edit
dl
rm
FallbackGroupHandler.php
1385
0644
edit
dl
rm
FilterHandler.php
5937
0644
edit
dl
rm
FingersCrossedHandler.php
7716
0644
edit
dl
rm
FirePHPHandler.php
4897
0644
edit
dl
rm
FleepHookHandler.php
3319
0644
edit
dl
rm
FlowdockHandler.php
3254
0644
edit
dl
rm
FormattableHandlerInterface.php
845
0644
edit
dl
rm
FormattableHandlerTrait.php
1281
0644
edit
dl
rm
GelfHandler.php
1622
0644
edit
dl
rm
GroupHandler.php
3077
0644
edit
dl
rm
Handler.php
1029
0644
edit
dl
rm
HandlerInterface.php
2778
0644
edit
dl
rm
HandlerWrapper.php
3358
0644
edit
dl
rm
IFTTTHandler.php
2195
0644
edit
dl
rm
InsightOpsHandler.php
1895
0644
edit
dl
rm
LogEntriesHandler.php
1714
0644
edit
dl
rm
LogglyHandler.php
4240
0644
edit
dl
rm
LogmaticHandler.php
2502
0644
edit
dl
rm
MailHandler.php
2066
0644
edit
dl
rm
MandrillHandler.php
2700
0644
edit
dl
rm
MissingExtensionException.php
473
0644
edit
dl
rm
MongoDBHandler.php
2672
0644
edit
dl
rm
NativeMailerHandler.php
5165
0644
edit
dl
rm
NewRelicHandler.php
6366
0644
edit
dl
rm
NoopHandler.php
880
0644
edit
dl
rm
NullHandler.php
1142
0644
edit
dl
rm
OverflowHandler.php
4935
0644
edit
dl
rm
PHPConsoleHandler.php
10210
0644
edit
dl
rm
ProcessableHandlerInterface.php
1078
0644
edit
dl
rm
ProcessableHandlerTrait.php
1494
0644
edit
dl
rm
ProcessHandler.php
5423
0644
edit
dl
rm
PsrHandler.php
2651
0644
edit
dl
rm
PushoverHandler.php
7025
0644
edit
dl
rm
RedisHandler.php
3005
0644
edit
dl
rm
RedisPubSubHandler.php
1952
0644
edit
dl
rm
RollbarHandler.php
3550
0644
edit
dl
rm
RotatingFileHandler.php
6185
0644
edit
dl
rm
SamplingHandler.php
3988
0644
edit
dl
rm
SendGridHandler.php
2900
0644
edit
dl
rm
SlackHandler.php
6664
0644
edit
dl
rm
SlackWebhookHandler.php
4029
0644
edit
dl
rm
SocketHandler.php
9942
0644
edit
dl
rm
SqsHandler.php
1783
0644
edit
dl
rm
StreamHandler.php
5435
0644
edit
dl
rm
SwiftMailerHandler.php
3362
0644
edit
dl
rm
SyslogHandler.php
2003
0644
edit
dl
rm
SyslogUdpHandler.php
3852
0644
edit
dl
rm
TelegramBotHandler.php
5305
0644
edit
dl
rm
TestHandler.php
5766
0644
edit
dl
rm
WebRequestRecognizerTrait.php
524
0644
edit
dl
rm
WhatFailureGroupHandler.php
1533
0644
edit
dl
rm
ZendMonitorHandler.php
3185
0644
edit
dl
rm
Edit:
/var/www/cobraambalaj/vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php
(5305B)
<?php declare(strict_types=1); /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Handler; use RuntimeException; use Monolog\Logger; /** * Handler send logs to Telegram using Telegram Bot API. * * How to use: * 1) Create telegram bot with https://telegram.me/BotFather * 2) Create a telegram channel where logs will be recorded. * 3) Add created bot from step 1 to the created channel from step 2. * * Use telegram bot API key from step 1 and channel name with '@' prefix from step 2 to create instance of TelegramBotHandler * * @link https://core.telegram.org/bots/api * * @author Mazur Alexandr <alexandrmazur96@gmail.com> */ class TelegramBotHandler extends AbstractProcessingHandler { private const BOT_API = 'https://api.telegram.org/bot'; /** * @var array AVAILABLE_PARSE_MODES The available values of parseMode according to the Telegram api documentation */ private const AVAILABLE_PARSE_MODES = [ 'HTML', 'MarkdownV2', 'Markdown' // legacy mode without underline and strikethrough, use MarkdownV2 instead ]; /** * Telegram bot access token provided by BotFather. * Create telegram bot with https://telegram.me/BotFather and use access token from it. * @var string */ private $apiKey; /** * Telegram channel name. * Since to start with '@' symbol as prefix. * @var string */ private $channel; /** * The kind of formatting that is used for the message. * See available options at https://core.telegram.org/bots/api#formatting-options * or in AVAILABLE_PARSE_MODES * @var string|null */ private $parseMode; /** * Disables link previews for links in the message. * @var bool|null */ private $disableWebPagePreview; /** * Sends the message silently. Users will receive a notification with no sound. * @var bool|null */ private $disableNotification; /** * @param string $apiKey Telegram bot access token provided by BotFather * @param string $channel Telegram channel name * @inheritDoc */ public function __construct( string $apiKey, string $channel, $level = Logger::DEBUG, bool $bubble = true, string $parseMode = null, bool $disableWebPagePreview = null, bool $disableNotification = null ) { parent::__construct($level, $bubble); $this->apiKey = $apiKey; $this->channel = $channel; $this->setParseMode($parseMode); $this->disableWebPagePreview($disableWebPagePreview); $this->disableNotification($disableNotification); } public function setParseMode(string $parseMode = null): self { if ($parseMode !== null && !in_array($parseMode, self::AVAILABLE_PARSE_MODES)) { throw new \InvalidArgumentException('Unknown parseMode, use one of these: ' . implode(', ', self::AVAILABLE_PARSE_MODES) . '.'); } $this->parseMode = $parseMode; return $this; } public function disableWebPagePreview(bool $disableWebPagePreview = null): self { $this->disableWebPagePreview = $disableWebPagePreview; return $this; } public function disableNotification(bool $disableNotification = null): self { $this->disableNotification = $disableNotification; return $this; } /** * {@inheritdoc} */ public function handleBatch(array $records): void { $messages = []; foreach ($records as $record) { if (!$this->isHandling($record)) { continue; } if ($this->processors) { $record = $this->processRecord($record); } $messages[] = $record; } if (!empty($messages)) { $this->send((string) $this->getFormatter()->formatBatch($messages)); } } /** * @inheritDoc */ protected function write(array $record): void { $this->send($record['formatted']); } /** * Send request to @link https://api.telegram.org/bot on SendMessage action. * @param string $message */ protected function send(string $message): void { $ch = curl_init(); $url = self::BOT_API . $this->apiKey . '/SendMessage'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'text' => $message, 'chat_id' => $this->channel, 'parse_mode' => $this->parseMode, 'disable_web_page_preview' => $this->disableWebPagePreview, 'disable_notification' => $this->disableNotification, ])); $result = Curl\Util::execute($ch); $result = json_decode($result, true); if ($result['ok'] === false) { throw new RuntimeException('Telegram API error. Description: ' . $result['description']); } } }
Save
cmd:
run