for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Domains\Bot\Middlewares;
use Domains\Message;
use Interfaces\Gitter\Middleware\MiddlewareInterface;
/**
* Class InlineDataMiddleware
*/
class InlineDataMiddleware implements MiddlewareInterface
{
* @param Message $message
* @return mixed
public function handle(Message $message)
$isImage = preg_match(
'/[^`]http(?:s)?:\/\/.*?\.(?:jpg|png|jpeg|svg|bmp)/iu'
, ' ' . $message->text);
$isVideo = preg_match(
'/[^`]http(?:s)?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be).*?/iu'
if (($isImage || $isVideo) && $message->user->login !== \Auth::user()->login) {
$answer = \Lang::get('gitter.inline', [
'user' => $message->user->login
]);
$message->italic($answer);
}
return $message;