@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use CURLFile; |
| 14 | 14 | |
| 15 | 15 | class webhook extends receiver {
|
| 16 | - public static function init () {
|
|
| 16 | + public static function init() {
|
|
| 17 | 17 | if (settings::$multi) {
|
| 18 | 18 | multi::init(); |
| 19 | 19 | } |
@@ -42,26 +42,26 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - protected static function setWebhook(string $url,string $secret = '') {
|
|
| 45 | + protected static function setWebhook(string $url, string $secret = '') {
|
|
| 46 | 46 | $res = telegram::setWebhook($url, settings::$certificate, max_connections:settings::$max_connection, allowed_updates : settings::$allowed_updates, secret_token: $secret); |
| 47 | 47 | if (telegram::$status) {
|
| 48 | - logger::write('Webhook was set successfully',loggerTypes::INFO);
|
|
| 48 | + logger::write('Webhook was set successfully', loggerTypes::INFO);
|
|
| 49 | 49 | } |
| 50 | 50 | else {
|
| 51 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR);
|
|
| 52 | - BPT::exit(print_r($res,true)); |
|
| 51 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR);
|
|
| 52 | + BPT::exit(print_r($res, true)); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | protected static function checkURL() {
|
| 57 | 57 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) {
|
| 58 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR);
|
|
| 58 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR);
|
|
| 59 | 59 | throw new bptException('WEBHOOK_NEED_URL');
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | private static function setURL(): string {
|
| 64 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
|
| 64 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected static function setCertificate() {
|
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | self::setCertificate(); |
| 84 | 84 | $url = self::setURL(); |
| 85 | 85 | $secret = tools::randomString(64); |
| 86 | - self::setWebhook($url,$secret); |
|
| 87 | - lock::save('BPT-HOOK',$secret);
|
|
| 86 | + self::setWebhook($url, $secret); |
|
| 87 | + lock::save('BPT-HOOK', $secret);
|
|
| 88 | 88 | BPT::exit('Done');
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | private static function checkSecret() {
|
| 92 | 92 | $secret = lock::read('BPT-HOOK');
|
| 93 | 93 | if (!isset($_SERVER['HTTP_X_TELEGRAM_BOT_API_SECRET_TOKEN']) || $_SERVER['HTTP_X_TELEGRAM_BOT_API_SECRET_TOKEN'] != $secret) {
|
| 94 | - logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING);
|
|
| 94 | + logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING);
|
|
| 95 | 95 | self::processSetWebhook(); |
| 96 | 96 | } |
| 97 | 97 | } |