• Hi!

    I have updated to PHP 8.1 because support for 7.4 will be discontinued at the end of the year. Unfortunately, after updating to PHP 8.1, it is no longer possible to send a direct message to the group associated with the bot. Also, the bot no longer responds to requests made from within the group. In direct chat with the bot everything works fine!

    The error log shows the following messages:

    mod_fcgid: stderr: PHP Fatal error: Uncaught TypeError: str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string in /exaple.com/httpdocs/wp-content/plugins/telegram-bot/telegram-bot.php:164, referer: https://example.com/wp-admin/admin.php?page=telegram_send

    After a short consultation with a WebDev friend, the assumption was that there might be a problem with the variable used and that the stricter checking by PHP 8.1 causes an error. Unfortunately, the bot is so under PHP 8.1 in groups no longer usable.

    If you have any questions about the error, I’m happy to help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter horstwursti

    (@horstwursti)

    Hey!
    in the meantime I could also test it with PHP 8.0. Unfortunately the same behavior. I have now downgraded back to PHP 7.4. Everything works again! I hope there is a solution in time, so that I can continue to use the plugin in the new year with a clear conscience ??

    I run PHP 7.4, there is the logs when I send a message to channel

    Error: incorrect parameters due to: HTTP/1.1 400 Bad Request @SieuVan-Bot Telegram Bot & Channel plugin test

    Did I fill the info in setting menu correctly

    https://drive.google.com/file/d/1q9_QSuSfVA0KuKpvoniY–ves0i_xjGL/view?usp=share_link


    You are able to get groups working, if you adjust line 164 like this (Don’t use the inbuild plugin editor!):

    Original:
    $text = str_replace('%LAST_NAME%', get_post_meta($o->ID, '', true), $text);

    Modified:
    $text = str_replace('%LAST_NAME%', strval(get_post_meta($o->ID, '', true)), $text);

    get_post_meta() has a mixed output, but str_replace() expects a string. So you need to convert it to string before with strval().

    I hope that’s fine for all cases. I’m a developer, but not familiar with PHP and I may miss something here….

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘no respone from in group chats and Error while sending direct messages to groups’ is closed to new replies.