andrebian / telegram-error-report
一个简单的通过Telegram发送错误报告的工具
dev-master
2021-04-05 14:27 UTC
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunir/phpunit: *
This package is auto-updated.
Last update: 2024-09-05 21:52:06 UTC
README
这是一个简单的Telegram机器人的实现,用于使开发者了解应用程序的错误。
这是一个代码级别的工具,意味着它主要对开发者有用。
使用这个实现,开发者可以接收异常、500错误、暴力破解尝试、用户作弊行为、登录失败尝试等。发挥你的想象力。
安装
输入 composer require andrebian/telegram-error-report
或者下载zip文件。
测试
将文件 config/config.php.dist
复制到 config/config.php
,设置你的机器人和频道配置,然后运行 ./vendor/bin/phpunit
使用
<?php use Andrebian\TelegramErrorReport\TelegramErrorReport; require __DIR__ . '/vendor/autoload.php'; // initializing $telegramErrorReport = new TelegramErrorReport('YOUR_CHANNEL_ID_HERE', 'YOUR_BOT_ID_HERE'); // sending info message $telegramErrorReport->sendInfoMessage('Your message'); // sending error message $telegramErrorReport->sendErrorMessage('Your message'); // sending debug message $telegramErrorReport->sendDebugMessage('Your message'); // Using with try/catch try { // your stuff here } catch (Exception $exception) { $message = $exception->getMessage(); $message .= TelegramErrorReport::LINE_BREAK . $exception->getFile(); $message .= ':' . $exception->getLine(); $message .= TelegramErrorReport::LINE_BREAK . $exception->getTraceAsString(); $telegramErrorReport->sendErrorMessage($message); }