33 lines
796 B
Plaintext
33 lines
796 B
Plaintext
|
<?php
|
||
|
|
||
|
namespace App\Helpers;
|
||
|
|
||
|
class TwitchHelper
|
||
|
{
|
||
|
public static function parseMessage($message)
|
||
|
{
|
||
|
$commandPattern = '/^!place\s([A-P])\s(\d{1,2})\s(\w+)$/i';
|
||
|
$shortCommandPattern = '/^!p\s([A-P])(\d{1,2})\s(\w+)$/i';
|
||
|
|
||
|
if (preg_match($commandPattern, $message, $matches)) {
|
||
|
return [
|
||
|
'command' => 'place',
|
||
|
'x' => $matches[1],
|
||
|
'y' => $matches[2],
|
||
|
'color' => $matches[3]
|
||
|
];
|
||
|
}
|
||
|
|
||
|
if (preg_match($shortCommandPattern, $message, $matches)) {
|
||
|
return [
|
||
|
'command' => 'place',
|
||
|
'x' => $matches[1],
|
||
|
'y' => $matches[2],
|
||
|
'color' => $matches[3]
|
||
|
];
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
}
|