@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Nopolabs\Yabot\Bot\AbstractPlugin; |
5 | 5 | use Nopolabs\Yabot\Bot\Message; |
6 | -use Nopolabs\Yabot\Bot\MessageDispatcher; |
|
7 | 6 | use Nopolabs\Yabot\Bot\MessageInterface; |
8 | 7 | use Nopolabs\Yabot\Yabot; |
9 | 8 | use Psr\Log\LoggerInterface; |
@@ -143,6 +143,9 @@ |
||
143 | 143 | $this->setConfig($config); |
144 | 144 | } |
145 | 145 | |
146 | + /** |
|
147 | + * @param string $pluginId |
|
148 | + */ |
|
146 | 149 | protected function setPluginId($pluginId) |
147 | 150 | { |
148 | 151 | $this->pluginId = $pluginId; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | { |
106 | 106 | $replaced = []; |
107 | 107 | foreach ($matchers as $name => $params) { |
108 | - $params['patterns'] = array_map(function ($pattern) use ($search, $replace) { |
|
108 | + $params['patterns'] = array_map(function($pattern) use ($search, $replace) { |
|
109 | 109 | return str_replace($search, $replace, $pattern); |
110 | 110 | }, $params['patterns']); |
111 | 111 | $replaced[$name] = $params; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->getLog()->warning("{$this->pluginId} no method named: $method"); |
131 | 131 | } |
132 | 132 | } catch (Exception $e) { |
133 | - $this->getLog()->warning('Exception in ' . static::class . '::' . $method); |
|
133 | + $this->getLog()->warning('Exception in '.static::class.'::'.$method); |
|
134 | 134 | $this->getLog()->warning($e->getMessage()); |
135 | 135 | $this->getLog()->warning($e->getTraceAsString()); |
136 | 136 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | try { |
219 | 219 | preg_match($pattern, '', $matches); |
220 | 220 | } catch (Throwable $e) { |
221 | - $this->getLog()->warning("$name.pattern='$pattern' " . $e->getMessage()); |
|
221 | + $this->getLog()->warning("$name.pattern='$pattern' ".$e->getMessage()); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
@@ -107,6 +107,9 @@ |
||
107 | 107 | $this->slack->apiCall('chat.postMessage', $parameters); |
108 | 108 | } |
109 | 109 | |
110 | + /** |
|
111 | + * @param string $event |
|
112 | + */ |
|
110 | 113 | public function on($event, array $onMessage) |
111 | 114 | { |
112 | 115 | $this->slack->on($event, function (Payload $payload) use ($onMessage) { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | public function on($event, array $onMessage) |
111 | 111 | { |
112 | - $this->slack->on($event, function (Payload $payload) use ($onMessage) { |
|
112 | + $this->slack->on($event, function(Payload $payload) use ($onMessage) { |
|
113 | 113 | call_user_func($onMessage, $payload); |
114 | 114 | }); |
115 | 115 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | public function updateAuthedUser() |
168 | 168 | { |
169 | - $this->slack->getAuthedUser()->then(function (User $user) { |
|
169 | + $this->slack->getAuthedUser()->then(function(User $user) { |
|
170 | 170 | $this->authedUser = $user; |
171 | 171 | }); |
172 | 172 | } |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Nopolabs\Yabot\Bot\AbstractPlugin; |
5 | 5 | use Nopolabs\Yabot\Bot\Message; |
6 | -use Nopolabs\Yabot\Bot\MessageDispatcher; |
|
7 | 6 | use Nopolabs\Yabot\Bot\MessageInterface; |
8 | 7 | use Nopolabs\Yabot\Yabot; |
9 | 8 | use Psr\Log\LoggerInterface; |
@@ -80,6 +80,6 @@ |
||
80 | 80 | |
81 | 81 | protected function getParameterOrDefault($name, array $default = []) : array |
82 | 82 | { |
83 | - return $this->hasParameter($name)? $this->getParameter($name) : $default; |
|
83 | + return $this->hasParameter($name) ? $this->getParameter($name) : $default; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | \ No newline at end of file |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | private function schedule() |
59 | 59 | { |
60 | 60 | if ($this->timer === null) { |
61 | - $self =& $this; |
|
62 | - $this->timer = $this->eventloop->addPeriodicTimer(0, \Closure::bind(function () use (&$self) { |
|
61 | + $self = & $this; |
|
62 | + $this->timer = $this->eventloop->addPeriodicTimer(0, \Closure::bind(function() use (&$self) { |
|
63 | 63 | // Do a smidgen of request processing |
64 | 64 | $this->tick(); |
65 | 65 | // Stop the timer when there are no more requests |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | private function naiveSchedule($request) |
75 | 75 | { |
76 | 76 | // Schedule the request to be resolved later |
77 | - $this->eventloop->futureTick(function () use ($request) { |
|
77 | + $this->eventloop->futureTick(function() use ($request) { |
|
78 | 78 | $request->wait(); |
79 | 79 | }); |
80 | 80 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | private function callable($function) : callable |
40 | 40 | { |
41 | - return function () use ($function) { |
|
41 | + return function() use ($function) { |
|
42 | 42 | call_user_func($function); |
43 | 43 | }; |
44 | 44 | } |
@@ -155,15 +155,15 @@ discard block |
||
155 | 155 | if ($prefix === Message::AUTHED_USER) { |
156 | 156 | /** @var User $user */ |
157 | 157 | $user = $this->slackClient->getAuthedUser(); |
158 | - $prefix = '@' . $user->getUsername(); |
|
158 | + $prefix = '@'.$user->getUsername(); |
|
159 | 159 | } elseif (!$prefix) { |
160 | 160 | $prefix = '<none>'; |
161 | 161 | } |
162 | 162 | /** @var PluginInterface $plugin */ |
163 | 163 | $help[] = $pluginId; |
164 | - $help[] = ' prefix: ' . $prefix; |
|
164 | + $help[] = ' prefix: '.$prefix; |
|
165 | 165 | foreach (explode("\n", $plugin->help()) as $line) { |
166 | - $help[] = ' ' . $line; |
|
166 | + $help[] = ' '.$line; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $statuses[] = "There are $count plugins loaded."; |
180 | 180 | foreach ($this->plugins as $pluginId => $plugin) { |
181 | 181 | /** @var PluginInterface $plugin */ |
182 | - $statuses[] = "$pluginId " . $plugin->status(); |
|
182 | + $statuses[] = "$pluginId ".$plugin->status(); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return implode("\n", $statuses); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | $this->addTimer($delay, function() { |
226 | 226 | $this->logger->info($this->getFormattedMemoryUsage()); |
227 | - $this->addPeriodicTimer(3600, function () { |
|
227 | + $this->addPeriodicTimer(3600, function() { |
|
228 | 228 | $this->logger->info($this->getFormattedMemoryUsage()); |
229 | 229 | }); |
230 | 230 | }); |