PixelPlacerBot/app/Helpers/TwitchHelper

33 lines
796 B
Plaintext
Raw Normal View History

2024-07-20 13:02:52 -04:00
<?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;
}
}