Skip to content

Commit

Permalink
Update listener.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSheer committed Feb 14, 2019
1 parent 70e0685 commit 5f52eb3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions event/listener.php
Expand Up @@ -103,12 +103,22 @@ public function modify_message($event)
{
$message_parser = $event['message_parser'];
$attachments = array();
$attachment_data = $message_parser->attachment_data;
$attachments = $message_parser->attachment_data;

$text = $message_parser->message;
preg_match_all('#\[img\]((.*?)|(.*?).jpg|(.*?).jpeg|(.*?).png|(.*?).gif)\[\/img\]#i', $text, $current_posted_img);
if (!empty($current_posted_img[1]))
{
$img_number = sizeof($current_posted_img[1]);

$text = preg_replace_callback ('#\[attachment=(.*?)\]#',
function ($matches) use (&$img_number)
{
return "[attachment=" . ($matches[1] + $img_number) . "]";
},
$text
);

foreach($current_posted_img[1] as $posted_img)
{
$url = preg_replace(array('#&\#46;#', '#&\#58;#', '/\[(.*?)\]/'), array('.', ':', ''), $posted_img);
Expand All @@ -128,16 +138,6 @@ public function modify_message($event)

if (!empty($attachments))
{
$img_number = sizeof($attachments);

$text = preg_replace_callback ('#\[attachment=(.*?)\]#',
function ($matches) use (&$img_number)
{
return "[attachment=" . ($matches[1] + $img_number) . "]";
},
$text
);

$text = preg_replace_callback('#\[img\]((.*?)|(.*?).jpg|(.*?).jpeg|(.*?).png|(.*?).gif)\[\/img\]#',
function ($matches) use (&$img_number)
{
Expand Down

0 comments on commit 5f52eb3

Please sign in to comment.