Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 0378e97

Browse files
committed
Account for changed structure of params
1 parent ea27995 commit 0378e97

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

src/Plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,15 @@ public function loadUserModes(EventInterface $event, EventQueueInterface $queue)
245245

246246
$connectionMask = $this->getConnectionMask($event->getConnection());
247247
$params = $event->getParams();
248-
$channel = ltrim(array_shift($params), '=*@');
248+
$channel = $params[1];
249249
$validPrefixes = implode('', array_keys($this->prefixes));
250250
$pattern = '/^([' . preg_quote($validPrefixes) . ']+)(.+)$/';
251251
$logger->debug('Gathering initial user mode data', array(
252252
'connectionMask' => $connectionMask,
253253
'channel' => $channel,
254254
));
255255

256-
foreach ($params as $fullNick) {
256+
foreach ($params['iterable'] as $fullNick) {
257257
if (!preg_match($pattern, $fullNick, $match)) {
258258
continue;
259259
}

tests/PluginTest.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,19 @@ public function testLoadUserModesWithSupportedPrefixes($channelPrefix)
295295
{
296296
$channel = '#channel';
297297
$params = array(
298-
$channelPrefix . $channel,
299-
'~owner',
300-
'&admin',
301-
'@op',
302-
'%halfop',
303-
'+voice',
304-
'&@multi',
305-
'regular',
298+
$channelPrefix,
299+
$channel,
300+
'~owner &admin @op %halfop +voice &@multi regular',
301+
'iterable' => array(
302+
'~owner',
303+
'&admin',
304+
'@op',
305+
'%halfop',
306+
'+voice',
307+
'&@multi',
308+
'regular',
309+
),
310+
'tail' => '~owner &admin @op %halfop +voice &@multi regular',
306311
);
307312
$event = $this->getMockEvent();
308313
$connection = $this->getMockConnection();
@@ -327,8 +332,13 @@ public function testLoadUserModesWithUnsupportedPrefix()
327332
{
328333
$channel = '#channel';
329334
$params = array(
330-
'=' . $channel,
335+
'=',
336+
$channel,
331337
'$unsupported',
338+
'iterable' => array(
339+
'$unsupported',
340+
),
341+
'tail' => '$unsupported',
332342
);
333343
$event = $this->getMockEvent();
334344
$connection = $this->getMockConnection();
@@ -347,8 +357,13 @@ public function testLoadUserModesWithOverriddenPrefix()
347357
{
348358
$channel = '#channel';
349359
$params = array(
350-
'=' . $channel,
360+
'=',
361+
$channel,
351362
'$unsupported',
363+
'iterable' => array(
364+
'$unsupported',
365+
),
366+
'tail' => '$unsupported',
352367
);
353368
$event = $this->getMockEvent();
354369
$connection = $this->getMockConnection();

0 commit comments

Comments
 (0)