@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | $countMinus2 = count($result); |
59 | 59 | |
60 | 60 | $returnString = ''; |
61 | - $returnString .= 'There are currently ' . $this->bold($count) . ' open reviews for project ' |
|
62 | - . $this->italic($project) . ' and branch master on <https://review.typo3.org/#/q/project:' . $project |
|
63 | - . '+status:open+branch:master|https://review.typo3.org>' . "\n"; |
|
64 | - $returnString .= $this->bold($countMinus1) . ' of ' . $this->bold($count) . ' open reviews voted with ' |
|
65 | - . $this->bold('-1') . ' <https://review.typo3.org/#/q/label:Code-Review%253D-1+is:open+branch:' |
|
66 | - . 'master+project:' . $project . '|Check now> ' . "\n"; |
|
67 | - $returnString .= $this->bold($countMinus2) . ' of ' . $this->bold($count) . ' open reviews voted with ' |
|
68 | - . $this->bold('-2') . ' <https://review.typo3.org/#/q/label:Code-Review%253D-2+is:open+branch:' |
|
69 | - . 'master+project:' . $project . '|Check now>'; |
|
61 | + $returnString .= 'There are currently '.$this->bold($count).' open reviews for project ' |
|
62 | + . $this->italic($project).' and branch master on <https://review.typo3.org/#/q/project:'.$project |
|
63 | + . '+status:open+branch:master|https://review.typo3.org>'."\n"; |
|
64 | + $returnString .= $this->bold($countMinus1).' of '.$this->bold($count).' open reviews voted with ' |
|
65 | + . $this->bold('-1').' <https://review.typo3.org/#/q/label:Code-Review%253D-1+is:open+branch:' |
|
66 | + . 'master+project:'.$project.'|Check now> '."\n"; |
|
67 | + $returnString .= $this->bold($countMinus2).' of '.$this->bold($count).' open reviews voted with ' |
|
68 | + . $this->bold('-2').' <https://review.typo3.org/#/q/label:Code-Review%253D-2+is:open+branch:' |
|
69 | + . 'master+project:'.$project.'|Check now>'; |
|
70 | 70 | |
71 | 71 | return $returnString; |
72 | 72 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | if ($username === null) { |
98 | 98 | return 'hey, I need a username!'; |
99 | 99 | } |
100 | - $results = $this->queryGerrit('is:open owner:"' . $username . '" project:' . $project); |
|
100 | + $results = $this->queryGerrit('is:open owner:"'.$username.'" project:'.$project); |
|
101 | 101 | if (count($results) > 0) { |
102 | - $listOfItems = ['*Here are the results for ' . $username . '*:']; |
|
102 | + $listOfItems = ['*Here are the results for '.$username.'*:']; |
|
103 | 103 | if (is_array($results)) { |
104 | 104 | foreach ($results as $item) { |
105 | 105 | $listOfItems[] = $this->buildReviewLine($item); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | return implode("\n", $listOfItems); |
110 | 110 | } |
111 | - return $username . ' has no open reviews or username is unknown'; |
|
111 | + return $username.' has no open reviews or username is unknown'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | if ($paramsCount > 2) { |
134 | 134 | $changeIds = []; |
135 | 135 | for ($i = 1; $i < $paramsCount; ++$i) { |
136 | - $changeIds[] = 'change:' . $this->params[$i]; |
|
136 | + $changeIds[] = 'change:'.$this->params[$i]; |
|
137 | 137 | } |
138 | 138 | $result = $this->queryGerrit(implode(' OR ', $changeIds)); |
139 | 139 | $listOfItems = []; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } |
145 | 145 | $returnMessage = implode(chr(10), $listOfItems); |
146 | 146 | } else { |
147 | - $result = $this->queryGerrit('change:' . $refId); |
|
147 | + $result = $this->queryGerrit('change:'.$refId); |
|
148 | 148 | if (!$result) { |
149 | 149 | return "{$refId} not found, sorry!"; |
150 | 150 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | return 'hey, I need a query!'; |
175 | 175 | } |
176 | 176 | |
177 | - $results = $this->queryGerrit('limit:50 ' . $query); |
|
177 | + $results = $this->queryGerrit('limit:50 '.$query); |
|
178 | 178 | if (count($results) > 0) { |
179 | 179 | $listOfItems = ["*Here are the results for {$query}*:"]; |
180 | 180 | if (is_array($results)) { |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | $cnt = count($result); |
206 | 206 | |
207 | - return 'Good job folks, since ' . $date . ' you merged *' . $cnt . '* patches into master'; |
|
207 | + return 'Good job folks, since '.$date.' you merged *'.$cnt.'* patches into master'; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | if (strpos($notification['message'], 'review:') === 0) { |
80 | 80 | $parts = explode(':', $notification['message']); |
81 | 81 | $refId = (int) trim($parts[1]); |
82 | - $result = $this->queryGerrit('change:' . $refId); |
|
83 | - $msg = '*Hi <@' . $user . '>, <@' . $notification['from_user'] . '>' |
|
82 | + $result = $this->queryGerrit('change:'.$refId); |
|
83 | + $msg = '*Hi <@'.$user.'>, <@'.$notification['from_user'].'>' |
|
84 | 84 | . ' ask you to look at this patch:*'; |
85 | 85 | |
86 | 86 | if (is_array($result)) { |
@@ -95,16 +95,16 @@ discard block |
||
95 | 95 | } elseif (strpos($notification['message'], 'forge:') === 0) { |
96 | 96 | $parts = explode(':', $notification['message']); |
97 | 97 | $issueNumber = (int) trim($parts[1]); |
98 | - $result = $this->queryForge('issues/' . $issueNumber); |
|
98 | + $result = $this->queryForge('issues/'.$issueNumber); |
|
99 | 99 | if ($result) { |
100 | - $msg = '*Hi <@' . $user . '>, <@' . $notification['from_user'] . '>' |
|
100 | + $msg = '*Hi <@'.$user.'>, <@'.$notification['from_user'].'>' |
|
101 | 101 | . ' ask you to look at this issue:*'; |
102 | - $this->sendResponse($msg . "\n" . $this->buildIssueMessage($result->issue), $user); |
|
102 | + $this->sendResponse($msg."\n".$this->buildIssueMessage($result->issue), $user); |
|
103 | 103 | } |
104 | 104 | } else { |
105 | - $msg = '*Hi <@' . $user . '>, here is a message from <@' . $notification['from_user'] . '>' |
|
105 | + $msg = '*Hi <@'.$user.'>, here is a message from <@'.$notification['from_user'].'>' |
|
106 | 106 | . ' for you:*'; |
107 | - $this->sendResponse($msg . "\n" . $notification['message'], $user); |
|
107 | + $this->sendResponse($msg."\n".$notification['message'], $user); |
|
108 | 108 | } |
109 | 109 | $now = new \DateTime(); |
110 | 110 | $now->setTimestamp(time()); |
@@ -141,6 +141,6 @@ discard block |
||
141 | 141 | 'message' => $message, |
142 | 142 | ]); |
143 | 143 | |
144 | - return 'OK, I will tell <@' . $toUser . '> about your message'; |
|
144 | + return 'OK, I will tell <@'.$toUser.'> about your message'; |
|
145 | 145 | } |
146 | 146 | } |
@@ -43,14 +43,14 @@ |
||
43 | 43 | $message = $this->payload->getData()['text']; |
44 | 44 | $parts = explode(':', $message); |
45 | 45 | $command = ucfirst(strtolower($parts[0])); |
46 | - $commandClass = '\\T3Bot\\Commands\\' . $command . 'Command'; |
|
46 | + $commandClass = '\\T3Bot\\Commands\\'.$command.'Command'; |
|
47 | 47 | if (class_exists($commandClass)) { |
48 | 48 | return new $commandClass($this->payload, $this->client); |
49 | 49 | } |
50 | 50 | |
51 | 51 | $parts = explode(' ', $message); |
52 | 52 | $command = ucfirst(strtolower($parts[0])); |
53 | - $commandClass = '\\T3Bot\\Commands\\' . $command . 'Command'; |
|
53 | + $commandClass = '\\T3Bot\\Commands\\'.$command.'Command'; |
|
54 | 54 | if (class_exists($commandClass)) { |
55 | 55 | return new $commandClass($this->payload, $this->client); |
56 | 56 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | protected function queryGerrit($query) |
20 | 20 | { |
21 | - return $this->remoteCall('https://review.typo3.org/changes/?q=' . urlencode($query)); |
|
21 | + return $this->remoteCall('https://review.typo3.org/changes/?q='.urlencode($query)); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | protected function getFilesForPatch($changeId, $revision) |
31 | 31 | { |
32 | 32 | return $this->remoteCall( |
33 | - 'https://review.typo3.org/changes/' . $changeId . '/revisions/' . $revision . '/files' |
|
33 | + 'https://review.typo3.org/changes/'.$changeId.'/revisions/'.$revision.'/files' |
|
34 | 34 | ); |
35 | 35 | } |
36 | 36 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | protected function bold($string) : string |
25 | 25 | { |
26 | - return '*' . $string . '*'; |
|
26 | + return '*'.$string.'*'; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | protected function italic($string) : string |
37 | 37 | { |
38 | - return '_' . $string . '_'; |
|
38 | + return '_'.$string.'_'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected function buildReviewLine($item) : string |
49 | 49 | { |
50 | - return $this->bold($item->subject) . ' <https://review.typo3.org/' . $item->_number |
|
51 | - . '|Review #' . $item->_number . ' now>'; |
|
50 | + return $this->bold($item->subject).' <https://review.typo3.org/'.$item->_number |
|
51 | + . '|Review #'.$item->_number.' now>'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | { |
61 | 61 | $created = substr($item->created_on, 0, 19); |
62 | 62 | $updated = substr($item->updated_on, 0, 19); |
63 | - $text = $this->bold('[' . $item->tracker->name . '] ' . $item->subject) |
|
64 | - . ' by ' . $this->italic($item->author->name) . "\n"; |
|
65 | - $text .= 'Project: ' . $this->bold($item->project->name); |
|
63 | + $text = $this->bold('['.$item->tracker->name.'] '.$item->subject) |
|
64 | + . ' by '.$this->italic($item->author->name)."\n"; |
|
65 | + $text .= 'Project: '.$this->bold($item->project->name); |
|
66 | 66 | if (!empty($item->category->name)) { |
67 | - $text .= ' | Category: ' . $this->bold($item->category->name); |
|
67 | + $text .= ' | Category: '.$this->bold($item->category->name); |
|
68 | 68 | } |
69 | - $text .= ' | Status: ' . $this->bold($item->status->name) . "\n"; |
|
70 | - $text .= ':calendar: Created: ' . $this->bold($created) . ' | Last update: ' . $this->bold($updated) . "\n"; |
|
71 | - $text .= '<https://forge.typo3.org/issues/' . $item->id . '|:arrow_right: View on Forge>'; |
|
69 | + $text .= ' | Status: '.$this->bold($item->status->name)."\n"; |
|
70 | + $text .= ':calendar: Created: '.$this->bold($created).' | Last update: '.$this->bold($updated)."\n"; |
|
71 | + $text .= '<https://forge.typo3.org/issues/'.$item->id.'|:arrow_right: View on Forge>'; |
|
72 | 72 | |
73 | 73 | return $text; |
74 | 74 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | switch ($hook) { |
48 | 48 | case 'patchset-created': |
49 | 49 | if ($patchSet === 1 && $branch === 'master') { |
50 | - $item = $this->queryGerrit('change:' . $patchId); |
|
50 | + $item = $this->queryGerrit('change:'.$patchId); |
|
51 | 51 | $item = $item[0]; |
52 | 52 | $created = substr($item->created, 0, 19); |
53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $attachment = new Message\Attachment(); |
57 | 57 | |
58 | 58 | $attachment->setColor(Message\Attachment::COLOR_NOTICE); |
59 | - $attachment->setTitle('[NEW] ' . $item->subject); |
|
59 | + $attachment->setTitle('[NEW] '.$item->subject); |
|
60 | 60 | |
61 | 61 | $text = "Branch: *{$branch}* | :calendar: _{$created}_ | ID: {$item->_number}\n"; |
62 | 62 | $text .= ":link: <https://review.typo3.org/{$item->_number}|Review now>"; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | break; |
74 | 74 | case 'change-merged': |
75 | 75 | /** @var array $item */ |
76 | - $item = $this->queryGerrit('change:' . $patchId); |
|
76 | + $item = $this->queryGerrit('change:'.$patchId); |
|
77 | 77 | $item = $item[0]; |
78 | 78 | /* @var \stdClass $item */ |
79 | 79 | $created = substr($item->created, 0, 19); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $attachment = new Message\Attachment(); |
84 | 84 | |
85 | 85 | $attachment->setColor(Message\Attachment::COLOR_GOOD); |
86 | - $attachment->setTitle(':white_check_mark: [MERGED] ' . $item->subject); |
|
86 | + $attachment->setTitle(':white_check_mark: [MERGED] '.$item->subject); |
|
87 | 87 | |
88 | 88 | $text = "Branch: {$branch} | :calendar: {$created} | ID: {$item->_number}\n"; |
89 | 89 | $text .= ":link: <https://review.typo3.org/{$item->_number}|Goto Review>"; |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | $attachment->setTitle('A documentation file has been updated'); |
127 | 127 | break; |
128 | 128 | } |
129 | - $text = ':link: <https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/' . $fileName |
|
130 | - . '|' . $fileName . '>'; |
|
129 | + $text = ':link: <https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/'.$fileName |
|
130 | + . '|'.$fileName.'>'; |
|
131 | 131 | $attachment->setText($text); |
132 | 132 | $attachment->setFallback($text); |
133 | 133 | $message->addAttachment($attachment); |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once __DIR__ . '/config/config.php'; |
|
3 | +require_once __DIR__.'/config/config.php'; |
|
4 | 4 | |
5 | 5 | return $GLOBALS['config']['db']; |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | $client = new Slack\RealTimeClient($loop); |
17 | 17 | $client->setToken($GLOBALS['config']['slack']['botAuthToken']); |
18 | 18 | |
19 | -$client->on('message', function (Slack\Payload $payload) use ($client) { |
|
19 | +$client->on('message', function(Slack\Payload $payload) use ($client) { |
|
20 | 20 | $user = $payload->getData()['user']; |
21 | 21 | $blackList = array_map('trim', explode(',', $GLOBALS['config']['slack']['userBlacklist'])); |
22 | 22 | if (in_array($user, $blackList, true)) { |
23 | 23 | $client->apiCall('im.open', ['user' => $user]) |
24 | - ->then(function (Slack\Payload $response) use ($client) { |
|
24 | + ->then(function(Slack\Payload $response) use ($client) { |
|
25 | 25 | $channel = $response->getData()['channel']['id']; |
26 | 26 | $data = []; |
27 | 27 | $data['unfurl_links'] = false; |
@@ -48,28 +48,28 @@ discard block |
||
48 | 48 | } |
49 | 49 | }); |
50 | 50 | |
51 | -$client->on('channel_created', function (Slack\Payload $payload) use ($client) { |
|
51 | +$client->on('channel_created', function(Slack\Payload $payload) use ($client) { |
|
52 | 52 | if ($payload->getData()['user'] !== $GLOBALS['config']['slack']['botId']) { |
53 | 53 | $command = new \T3Bot\Commands\ChannelCommand($payload, $client); |
54 | 54 | $command->processChannelCreated($payload->getData()); |
55 | 55 | } |
56 | 56 | }); |
57 | 57 | |
58 | -$client->on('presence_change', function (Slack\Payload $payload) use ($client) { |
|
58 | +$client->on('presence_change', function(Slack\Payload $payload) use ($client) { |
|
59 | 59 | if ($payload->getData()['user'] !== $GLOBALS['config']['slack']['botId']) { |
60 | 60 | $command = new \T3Bot\Commands\TellCommand($payload, $client); |
61 | 61 | $command->processPresenceChange($payload->getData()['user'], $payload->getData()['presence']); |
62 | 62 | } |
63 | 63 | }); |
64 | 64 | |
65 | -$client->connect()->then(function () use ($client) { |
|
65 | +$client->connect()->then(function() use ($client) { |
|
66 | 66 | echo "Connected!\n"; |
67 | 67 | }); |
68 | 68 | |
69 | 69 | /* @noinspection PhpInternalEntityUsedInspection */ |
70 | 70 | $db = \Doctrine\DBAL\DriverManager::getConnection($GLOBALS['config']['db'], new \Doctrine\DBAL\Configuration()); |
71 | 71 | |
72 | -$loop->addPeriodicTimer(5, function () use ($client, $db) { |
|
72 | +$loop->addPeriodicTimer(5, function() use ($client, $db) { |
|
73 | 73 | $messages = $db->fetchAll('SELECT * FROM messages ORDER BY id ASC'); |
74 | 74 | foreach ($messages as $message) { |
75 | 75 | $data = json_decode($message['message'], true); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -(new Dotenv\Dotenv(__DIR__ . '/../'))->load(); |
|
3 | +(new Dotenv\Dotenv(__DIR__.'/../'))->load(); |
|
4 | 4 | |
5 | 5 | $GLOBALS['config'] = [ |
6 | 6 | // project phase |