<commit_before>#!/usr/bin/env php
<?php

require dirname(__DIR__).'/vendor/autoload.php';

use Icicle\Loop;
use Steelbot\TelegramBotApi\Api;
use Steelbot\TelegramBotApi\Method\SendMessage;
use Steelbot\TelegramBotApi\Type\Chat;
use Steelbot\TelegramBotApi\Type\Update;

if (!getenv('BOT_TOKEN')) {
    echo "Error: BOT_TOKEN environment variable not found\n";
    printf("Usage:\n  BOT_TOKEN=<PASSWORD>:telegram_bot_token ./%s\n", basename(__FILE__));
    exit(-1);
}

$generator = function () {
    $api = new Api(getenv('BOT_TOKEN'));

    while (true) {
        // waiting for updates from telegram server
        /** @var Update[] $updates */
        $updates = yield from $api->getUpdates();

        foreach ($updates as $update) {
            if ($update->inlineQuery) {
                $inlineQuery = $update->inlineQuery;

                for ($results=[]; count($results)<5;) {
                    $results[] = new \Steelbot\TelegramBotApi\InlineQueryResult\InlineQueryResultArticle(
                        null, "IQ title 1", "You entered 1: " . $inlineQuery->query
                    );
                    $results[] = new \Steelbot\TelegramBotApi\InlineQueryResult\InlineQueryResultArticle(
                        null, "IQ title 2", "You entered 2: " . $inlineQuery->query
                    );
                }

                $method = new \Steelbot\TelegramBotApi\Method\AnswerInlineQuery($inlineQuery->id, $results);

                echo "Answering to #{$inlineQuery->id}\n";
                yield from $api->execute($method);
            }

        }
    }
};

$coroutine = new \Icicle\Coroutine\Coroutine($generator());
$coroutine->done(null, function (\Throwable $exception) {<commit_msg>update inline query example<commit_after>#!/usr/bin/env php
<?php

require dirname(__DIR__).'/vendor/autoload.php';

use Icicle\Loop;
use Steelbot\TelegramBotApi\{
    Api,
    InlineQueryResult\InlineQueryResultArticle,
    InputMessageContent\InputContactMessageContent,
    InputMessageContent\InputLocationMessageContent,
    InputMessageContent\InputTextMessageContent,
    InputMessageContent\InputVenueMessageContent,
    Type\Update
};

if (!getenv('BOT_TOKEN')) {
    echo "Error: BOT_TOKEN environment variable not found\n";
    printf("Usage:\n  BOT_TOKEN=123:telegram_bot_token ./%s\n", basename(__FILE__));
    exit(-1);
}

$generator = function () {
    $api = new Api(getenv('BOT_TOKEN'));

    while (true) {
        // waiting for updates from telegram server
        /** @var Update[] $updates */
        $updates = yield from $api->getUpdates();

        foreach ($updates as $update) {
            if ($update->inlineQuery) {
                $inlineQuery = $update->inlineQuery;

                $results[] = new InlineQueryResultArticle(
                    null, "Text result", new InputTextMessageContent("You entered 1: " . $inlineQuery->query)
                );
                $results[] = new InlineQueryResultArticle(
                    null, "Location result", new InputLocationMessageContent(55.757, 37,616)
                );
                $results[] = new InlineQueryResultArticle(
                    null, "Venue result", new InputVenueMessageContent(55.757, 37.616, "Venue title", "Venue address")
                );
                $results[] = new InlineQueryResultArticle(
                    null, "Contact result", new InputContactMessageContent('+0123456789', "<NAME>")
                );

                $method = new \Steelbot\TelegramBotApi\Method\AnswerInlineQuery($inlineQuery->id, $results);

                echo "Answering to #{$inlineQuery->id}\n";
                yield from $api->execute($method);
            }

        }
    }
};

$coroutine = new \Icicle\Coroutine\Coroutine($generator());
$coroutine->done(null, function (\Throwable $exception) {
{'fraction_non_alphanumeric': 0.13101464435146443, 'fraction_numerical': 0.010721757322175732, 'mean_word_length': 2.442844284428443, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1171381', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1096, 'n_words': 221}