Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 13, 2019. It is now read-only.

Commit b6a12d1

Browse files
Merge pull request #4 from corpsee/feature-improvement
Improvements
2 parents 2bf405d + c89a48e commit b6a12d1

File tree

3 files changed

+47
-21
lines changed

3 files changed

+47
-21
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a58c62e4bde1485f95b52fa56a2e4320)](https://www.codacy.com/app/LEXASOFT/PHP-Censor-Telegram-Plugin)
44
# PHP-Censor-Telegram-Plugin
5-
Telegram plugin for [PHP Censor](https://github.com/corpsee/php-censor)
5+
Telegram plugin for [PHP Censor](https://github.com/php-censor/php-censor)
66
# Installation
77
First of all - `composer require lexasoft/php-censor-telegram-plugin`
88

‎composer.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
11
{
22
"name": "lexasoft/php-censor-telegram-plugin",
33
"description": "PHP Censor plugin for Telegram",
4+
"minimum-stability": "stable",
5+
"type": "php-censor-plugin",
6+
"keywords": [
7+
"php",
8+
"php-censor",
9+
"testing",
10+
"open-source",
11+
"ci",
12+
"continuous integration",
13+
"telegram"
14+
],
15+
"homepage": "https://github.com/LEXASOFT/PHP-Censor-Telegram-Plugin",
416
"license": "GPL-3.0",
517
"authors": [
618
{
719
"name": "LEXASOFT",
8-
"email": "lexasoft83@gmail.com"
20+
"email": "lexasoft83@gmail.com",
21+
"role": "Developer"
922
}
1023
],
24+
"support": {
25+
"issues": "https://github.com/LEXASOFT/PHP-Censor-Telegram-Plugin/issues",
26+
"source": "https://github.com/LEXASOFT/PHP-Censor-Telegram-Plugin"
27+
},
1128
"require": {
12-
"php": ">=5.3.3"
29+
"php": ">=5.3.3",
30+
"guzzlehttp/guzzle": "6.2.*"
1331
},
1432
"autoload": {
1533
"psr-4": {
1634
"PHPCensor\\Plugin\\": "src"
1735
}
1836
},
1937
"extra": {
20-
"phpci": {
38+
"php-censor": {
2139
"pluginNamespace": "PHPCensor\\Plugin\\",
2240
"suppliedPlugins": [
2341
{

‎src/Telegram.php

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use PHPCensor\Builder;
66
use PHPCensor\Model\Build;
7-
use b8\HttpClient;
7+
use GuzzleHttp\Client;
88

99
/**
1010
* Telegram Plugin
11-
*
11+
*
1212
* @author LEXASOFT <lexasoft83@gmail.com>
1313
* @package PHPCensor
1414
* @subpackage Plugins
@@ -77,28 +77,36 @@ public function execute()
7777
{
7878

7979
$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';
8482

8583
foreach ($this->recipients as $chatId) {
8684
$params = [
87-
'chat_id' => $chatId,
88-
'text' => $message,
85+
'chat_id' => $chatId,
86+
'text' => $message,
8987
'parse_mode' => 'Markdown',
9088
];
9189

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+
]);
9396

9497
if ($this->sendLog) {
9598
$params = [
96-
'chat_id' => $chatId,
97-
'text' => $this->buildMsg,
99+
'chat_id' => $chatId,
100+
'text' => $this->buildMsg,
98101
'parse_mode' => 'Markdown',
99102
];
100103

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+
]);
102110
}
103111
}
104112

@@ -112,13 +120,13 @@ public function execute()
112120
private function buildMessage()
113121
{
114122
$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);
119127

120128
foreach ($buildMessages as $bm) {
121-
$pos = mb_strpos($bm, "\n");
129+
$pos = mb_strpos($bm, "\n");
122130
$firstRow = mb_substr($bm, 0, $pos);
123131

124132
//skip long outputs

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /