src/BotManager.php
protected function defaultGetUpdatesCallback($get_updates_response): string
    {
        if (!$get_updates_response->isOk()) {
            return sprintf(
                '%s - Failed to fetch updates' . PHP_EOL . '%s',
                date('Y-m-d H:i:s'),
                $get_updates_response->printError(true)
            );
        }

        /** @var Entities\Update[] $results */
        $results = array_filter((array) $get_updates_response->getResult());

        $output = sprintf(
            '%s - Updates processed: %d' . PHP_EOL,
            date('Y-m-d H:i:s'),
            count($results)
        );

        foreach ($results as $result) {
            $chat_id = 0;
            $text    = '<n/a>';

            $update_content = $result->getUpdateContent();
            if ($update_content instanceof Entities\Message) {
                $chat_id = $update_content->getChat()->getId();
                $text    = sprintf('<%s>', $update_content->getType());
            } elseif ($update_content instanceof Entities\InlineQuery ||
                      $update_content instanceof Entities\ChosenInlineResult
            ) {
                $chat_id = $update_content->getFrom()->getId();
                $text    = sprintf('<query> %s', $update_content->getQuery());
            }

            $output .= sprintf(
                '%d: %s' . PHP_EOL,
                $chat_id,
                preg_replace('/\s+/', ' ', trim($text))
            );
        }

        return $output;
    }
protected function defaultGetUpdatesCallback($get_updates_response): string
    {
        if (!$get_updates_response->isOk()) {
            return sprintf(
                '%s - Failed to fetch updates' . PHP_EOL . '%s',
                date('Y-m-d H:i:s'),
                $get_updates_response->printError(true)
            );
        }

        /** @var Entities\Update[] $results */
        $results = array_filter((array) $get_updates_response->getResult());

        $output = sprintf(
            '%s - Updates processed: %d' . PHP_EOL,
            date('Y-m-d H:i:s'),
            count($results)
        );

        foreach ($results as $result) {
            $chat_id = 0;
            $text    = '<n/a>';

            $update_content = $result->getUpdateContent();
            if ($update_content instanceof Entities\Message) {
                $chat_id = $update_content->getChat()->getId();
                $text    = sprintf('<%s>', $update_content->getType());
            } elseif ($update_content instanceof Entities\InlineQuery ||
                      $update_content instanceof Entities\ChosenInlineResult
            ) {
                $chat_id = $update_content->getFrom()->getId();
                $text    = sprintf('<query> %s', $update_content->getQuery());
            }

            $output .= sprintf(
                '%d: %s' . PHP_EOL,
                $chat_id,
                preg_replace('/\s+/', ' ', trim($text))
            );
        }

        return $output;
    }
protected function defaultGetUpdatesCallback ( $ get_updates_response ) : string { if ( ! $ get_updates_response -> isOk ( ) ) { return sprintf ( '%s - Failed to fetch updates' . PHP_EOL . '%s' , date ( 'Y-m-d H:i:s' ) , $ get_updates_response -> printError ( true ) ) ; } /** @var Entities\Update[] $results */ $ results = array_filter ( ( array ) $ get_updates_response -> getResult ( ) ) ; $ output = sprintf ( '%s - Updates processed: %d' . PHP_EOL , date ( 'Y-m-d H:i:s' ) , count ( $ results ) ) ; foreach ( $ results as $ result ) { $ chat_id = 0 ; $ text = '<n/a>' ; $ update_content = $ result -> getUpdateContent ( ) ; if ( $ update_content instanceof Entities \ Message ) { $ chat_id = $ update_content -> getChat ( ) -> getId ( ) ; $ text = sprintf ( '<%s>' , $ update_content -> getType ( ) ) ; } elseif ( $ update_content instanceof Entities \ InlineQuery || $ update_content instanceof Entities \ ChosenInlineResult ) { $ chat_id = $ update_content -> getFrom ( ) -> getId ( ) ; $ text = sprintf ( '<query> %s' , $ update_content -> getQuery ( ) ) ; } $ output .= sprintf ( '%d: %s' . PHP_EOL , $ chat_id , preg_replace ( '/\s+/' , ' ' , trim ( $ text ) ) ) ; } return $ output ; }
Return the default output for getUpdates handling.

@param Entities\ServerResponse $get_updates_response

@return string
Return the default output for getUpdates handling .