I wrote a bot to delete some words from a telegram group.
function filter_messages() {
global $telegram;
$bad_words = [
'hello',
'hi'
];
$all_words = end( explode( ' ', $telegram->Text() ) );
if ( in_array( $all_words, $bad_words ) ) {
deletMessage();
}
}
it works when a user sends a message like “hello”. Robot deletes the message.
but when he sends “hello guys”
the robot does not delete the messeage.
2
Answers
I used strpos() function.