@@ -141,7 +141,8 @@ private function buildIssuesText(array $Message, string $RepositoryName, string
141141 }
142142
143143 if (!empty ($ Issue ['body ' ])) {
144- $ ChatMsg .= "\n\n> " . substr ($ Issue ['body ' ], 0 , 500 ) . (strlen ($ Issue ['body ' ]) > 500 ? "… " : "" );
144+ $ body = self ::stripImages ($ Issue ['body ' ]);
145+ $ ChatMsg .= "\n\n> " . substr ($ body , 0 , 500 ) . (strlen ($ body ) > 500 ? "… " : "" );
145146 }
146147
147148 return $ ChatMsg ;
@@ -190,7 +191,8 @@ private function buildPullRequestText(array $Message, string $RepositoryName, st
190191 }
191192
192193 if (!empty ($ PR ['body ' ])) {
193- $ ChatMsg .= "\n\n> " . substr ($ PR ['body ' ], 0 , 500 ) . (strlen ($ PR ['body ' ]) > 500 ? "… " : "" );
194+ $ body = self ::stripImages ($ PR ['body ' ]);
195+ $ ChatMsg .= "\n\n> " . substr ($ body , 0 , 500 ) . (strlen ($ body ) > 500 ? "… " : "" );
194196 }
195197
196198 return $ ChatMsg ;
@@ -326,4 +328,14 @@ private function buildDefaultText(string $EventType, array $Message, string $Rep
326328 . (isset ($ Message ['action ' ]) ? "( {$ Message ['action ' ]}) " : "" )
327329 . "on [ {$ RepositoryName }](https://github.com/ {$ RepositoryName }). " ;
328330 }
331+
332+ private static function stripImages (string $ text ): string
333+ {
334+ // Remove markdown images: 
335+ $ text = preg_replace ('/!\[.*?\]\(.*?\)/ ' , '' , $ text );
336+ // Remove HTML <img> tags and their contents
337+ $ text = preg_replace ('/<img[^>]*>.*?<\/img>/ ' , '' , $ text );
338+ $ text = preg_replace ('/<img[^>]*\/>/ ' , '' , $ text );
339+ return trim ($ text );
340+ }
329341}
0 commit comments