@@ -54,6 +54,6 @@ |
||
54 | 54 | |
55 | 55 | $option = $options[random_int(0, count($options) - 1)]; |
56 | 56 | |
57 | - return '*Botty says:* _' . $option . '_'; |
|
57 | + return '*Botty says:* _'.$option.'_'; |
|
58 | 58 | } |
59 | 59 | } |
@@ -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']; |
@@ -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 |
@@ -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, $GLOBALS['config']); |
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, $GLOBALS['config']); |
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); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | protected function bold($string) : string |
28 | 28 | { |
29 | - return '*' . $string . '*'; |
|
29 | + return '*'.$string.'*'; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected function italic($string) : string |
40 | 40 | { |
41 | - return '_' . $string . '_'; |
|
41 | + return '_'.$string.'_'; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | */ |
51 | 51 | protected function buildReviewLine($item) : string |
52 | 52 | { |
53 | - return $this->bold($item->subject) . ' <https://review.typo3.org/' . $item->_number |
|
54 | - . '|Review #' . $item->_number . ' now>'; |
|
53 | + return $this->bold($item->subject).' <https://review.typo3.org/'.$item->_number |
|
54 | + . '|Review #'.$item->_number.' now>'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | { |
64 | 64 | $created = substr($item->created_on, 0, 19); |
65 | 65 | $updated = substr($item->updated_on, 0, 19); |
66 | - $text = $this->bold('[' . $item->tracker->name . '] ' . $item->subject) |
|
67 | - . ' by ' . $this->italic($item->author->name) . chr(10); |
|
68 | - $text .= 'Project: ' . $this->bold($item->project->name); |
|
66 | + $text = $this->bold('['.$item->tracker->name.'] '.$item->subject) |
|
67 | + . ' by '.$this->italic($item->author->name).chr(10); |
|
68 | + $text .= 'Project: '.$this->bold($item->project->name); |
|
69 | 69 | if (!empty($item->category->name)) { |
70 | - $text .= ' | Category: ' . $this->bold($item->category->name); |
|
70 | + $text .= ' | Category: '.$this->bold($item->category->name); |
|
71 | 71 | } |
72 | - $text .= ' | Status: ' . $this->bold($item->status->name) . chr(10); |
|
73 | - $text .= ':calendar: Created: ' . $this->bold($created) . ' | Last update: ' . $this->bold($updated) . chr(10); |
|
74 | - $text .= '<https://forge.typo3.org/issues/' . $item->id . '|:arrow_right: View on Forge>'; |
|
72 | + $text .= ' | Status: '.$this->bold($item->status->name).chr(10); |
|
73 | + $text .= ':calendar: Created: '.$this->bold($created).' | Last update: '.$this->bold($updated).chr(10); |
|
74 | + $text .= '<https://forge.typo3.org/issues/'.$item->id.'|:arrow_right: View on Forge>'; |
|
75 | 75 | |
76 | 76 | return $text; |
77 | 77 | } |
@@ -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 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $result = false; |
52 | 52 | if (!curl_errno($ch)) { |
53 | 53 | curl_close($ch); |
54 | - $result = json_decode(str_replace(")]}'" . chr(10), '', $data)); |
|
54 | + $result = json_decode(str_replace(")]}'".chr(10), '', $data)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $result; |
@@ -64,6 +64,6 @@ |
||
64 | 64 | { |
65 | 65 | $delimiter = strpos($message, ':') !== false ? ':' : ' '; |
66 | 66 | $parts = explode($delimiter, $message); |
67 | - return '\\T3Bot\\Commands\\' . ucfirst(strtolower($parts[0])) . 'Command'; |
|
67 | + return '\\T3Bot\\Commands\\'.ucfirst(strtolower($parts[0])).'Command'; |
|
68 | 68 | } |
69 | 69 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function processAll() : string |
51 | 51 | { |
52 | - return 'Yeah, ' . $this->getBeerCountAll() . ' :t3beer: spend to all people'; |
|
52 | + return 'Yeah, '.$this->getBeerCountAll().' :t3beer: spend to all people'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $rows = $this->getBeerTop10(); |
65 | 65 | $text = ['*Yeah, here are the TOP 10*']; |
66 | 66 | foreach ($rows as $row) { |
67 | - $text[] = '<@' . $row['username'] . '> has received ' . $row['cnt'] . ' :t3beer:'; |
|
67 | + $text[] = '<@'.$row['username'].'> has received '.$row['cnt'].' :t3beer:'; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return implode(chr(10), $text); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if (strpos($username, '<') === 0 && $username[1] === '@') { |
86 | 86 | $username = str_replace(['<', '>', '@'], '', $username); |
87 | 87 | |
88 | - return '<@' . $username . '> has received ' . $this->getBeerCountByUsername($username) . ' :t3beer: so far'; |
|
88 | + return '<@'.$username.'> has received '.$this->getBeerCountByUsername($username).' :t3beer: so far'; |
|
89 | 89 | } |
90 | 90 | return '*Sorry, a username must start with a @-sign:*'; |
91 | 91 | } |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | 'from_user' => $from_user, |
110 | 110 | 'tstamp' => time() |
111 | 111 | ]); |
112 | - return 'Yeah, one more :t3beer: for <@' . $username . '>' . chr(10) . '<@' . $username . '> has received ' |
|
113 | - . $this->getBeerCountByUsername($username) . ' :t3beer: so far'; |
|
112 | + return 'Yeah, one more :t3beer: for <@'.$username.'>'.chr(10).'<@'.$username.'> has received ' |
|
113 | + . $this->getBeerCountByUsername($username).' :t3beer: so far'; |
|
114 | 114 | } |
115 | - return 'You spend one :t3beer: to <@' . $username . '> within in last 24 hours. Too much beer is unhealthy ;)'; |
|
115 | + return 'You spend one :t3beer: to <@'.$username.'> within in last 24 hours. Too much beer is unhealthy ;)'; |
|
116 | 116 | } |
117 | 117 | return '*Sorry, a username must start with a @-sign:*'; |
118 | 118 | } |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | { |
105 | 105 | $parts = explode(':', $notification['message']); |
106 | 106 | $refId = (int) trim($parts[1]); |
107 | - $result = $this->queryGerrit('change:' . $refId); |
|
108 | - $msg = '*Hi <@' . $user . '>, <@' . $notification['from_user'] . '>' |
|
107 | + $result = $this->queryGerrit('change:'.$refId); |
|
108 | + $msg = '*Hi <@'.$user.'>, <@'.$notification['from_user'].'>' |
|
109 | 109 | . ' ask you to look at this patch:*'; |
110 | 110 | |
111 | 111 | if (is_array($result)) { |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | { |
128 | 128 | $parts = explode(':', $notification['message']); |
129 | 129 | $issueNumber = (int) trim($parts[1]); |
130 | - $result = $this->queryForge('issues/' . $issueNumber); |
|
130 | + $result = $this->queryForge('issues/'.$issueNumber); |
|
131 | 131 | if ($result) { |
132 | - $msg = '*Hi <@' . $user . '>, <@' . $notification['from_user'] . '>' |
|
132 | + $msg = '*Hi <@'.$user.'>, <@'.$notification['from_user'].'>' |
|
133 | 133 | . ' ask you to look at this issue:*'; |
134 | - $this->sendResponse($msg . chr(10) . $this->buildIssueMessage($result->issue), $user); |
|
134 | + $this->sendResponse($msg.chr(10).$this->buildIssueMessage($result->issue), $user); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function processTextMessage(array $notification, string $user) |
143 | 143 | { |
144 | - $msg = '*Hi <@' . $user . '>, here is a message from <@' . $notification['from_user'] . '>' . ' for you:*'; |
|
145 | - $this->sendResponse($msg . chr(10) . $notification['message'], $user); |
|
144 | + $msg = '*Hi <@'.$user.'>, here is a message from <@'.$notification['from_user'].'>'.' for you:*'; |
|
145 | + $this->sendResponse($msg.chr(10).$notification['message'], $user); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -168,6 +168,6 @@ discard block |
||
168 | 168 | 'message' => $message, |
169 | 169 | ]); |
170 | 170 | |
171 | - return 'OK, I will tell <@' . $toUser . '> about your message'; |
|
171 | + return 'OK, I will tell <@'.$toUser.'> about your message'; |
|
172 | 172 | } |
173 | 173 | } |