4
4
5
5
use PHPCensor \Builder ;
6
6
use PHPCensor \Model \Build ;
7
- use b8 \ HttpClient ;
7
+ use GuzzleHttp \ Client ;
8
8
9
9
/**
10
10
* Telegram Plugin
11
- *
11
+ *
12
12
* @author LEXASOFT <lexasoft83@gmail.com>
13
13
* @package PHPCensor
14
14
* @subpackage Plugins
@@ -77,28 +77,36 @@ public function execute()
77
77
{
78
78
79
79
$ message = $ this ->buildMessage ();
80
-
81
- $ http = new HttpClient ('https://api.telegram.org ' );
82
- $ http ->setHeaders (['Content-Type: application/json ' ]);
83
- $ uri = '/bot ' . $ this ->apiKey . '/sendMessage ' ;
80
+ $ client = new Client ();
81
+ $ url = '/bot ' . $ this ->apiKey . '/sendMessage ' ;
84
82
85
83
foreach ($ this ->recipients as $ chatId ) {
86
84
$ params = [
87
- 'chat_id ' => $ chatId ,
88
- 'text ' => $ message ,
85
+ 'chat_id ' => $ chatId ,
86
+ 'text ' => $ message ,
89
87
'parse_mode ' => 'Markdown ' ,
90
88
];
91
89
92
- $ http ->post ($ uri , json_encode ($ params ));
90
+ $ client ->post (('https://api.telegram.org ' . $ url ), [
91
+ 'headers ' => [
92
+ 'Content-Type ' => 'application/json ' ,
93
+ ],
94
+ 'json ' => $ params ,
95
+ ]);
93
96
94
97
if ($ this ->sendLog ) {
95
98
$ params = [
96
- 'chat_id ' => $ chatId ,
97
- 'text ' => $ this ->buildMsg ,
99
+ 'chat_id ' => $ chatId ,
100
+ 'text ' => $ this ->buildMsg ,
98
101
'parse_mode ' => 'Markdown ' ,
99
102
];
100
103
101
- $ http ->post ($ uri , json_encode ($ params ));
104
+ $ client ->post (('https://api.telegram.org ' . $ url ), [
105
+ 'headers ' => [
106
+ 'Content-Type ' => 'application/json ' ,
107
+ ],
108
+ 'json ' => $ params ,
109
+ ]);
102
110
}
103
111
}
104
112
@@ -112,13 +120,13 @@ public function execute()
112
120
private function buildMessage ()
113
121
{
114
122
$ this ->buildMsg = '' ;
115
- $ buildIcon = $ this ->build ->isSuccessful () ? '✅ ' : '❎ ' ;
116
- $ buildLog = $ this ->build ->getLog ();
117
- $ buildLog = str_replace (['[0;32m ' , '[0;31m ' , '[0m ' , '/[0m ' ], '' , $ buildLog );
118
- $ buildMessages = explode ('RUNNING PLUGIN: ' , $ buildLog );
123
+ $ buildIcon = $ this ->build ->isSuccessful () ? '✅ ' : '❎ ' ;
124
+ $ buildLog = $ this ->build ->getLog ();
125
+ $ buildLog = str_replace (['[0;32m ' , '[0;31m ' , '[0m ' , '/[0m ' ], '' , $ buildLog );
126
+ $ buildMessages = explode ('RUNNING PLUGIN: ' , $ buildLog );
119
127
120
128
foreach ($ buildMessages as $ bm ) {
121
- $ pos = mb_strpos ($ bm , "\n" );
129
+ $ pos = mb_strpos ($ bm , "\n" );
122
130
$ firstRow = mb_substr ($ bm , 0 , $ pos );
123
131
124
132
//skip long outputs
0 commit comments