Пример #1
0
/**
 * @return Generator
 * @throws \Steelbot\TelegramBotApi\Exception\TelegramBotApiException
 */
function botCoroutine() : \Generator
{
    $api = new Api(getenv('BOT_TOKEN'));
    $updateId = 1;
    printf("Waiting for updates ...\n");
    while (true) {
        // waiting for updates from telegram server
        /** @var Update[] $updates */
        $updates = (yield from $api->getUpdates($updateId));
        foreach ($updates as $update) {
            $method = processUpdate($update);
            if (is_object($method)) {
                yield from $api->execute($method);
            }
            $updateId = $update->updateId;
        }
    }
}
Пример #2
0
</p>
				<?php 
                            } else {
                                if (newUpdates($check_updates)) {
                                    // Get the update informations
                                    $update_infos = updateInformations();
                                    // We can launch the update!
                                    if (isset($_GET['p']) && $_GET['p'] == 'update') {
                                        ?>
						<h4><?php 
                                        _e("Update in progress");
                                        ?>
</h4>
						
						<?php 
                                        if (processUpdate($update_infos['url'])) {
                                            ?>
							<p class="info smallspace success"><?php 
                                            _e("Jappix has been updated: you are now running the latest version. Have fun!");
                                            ?>
</p>
						<?php 
                                        } else {
                                            ?>
							<p class="info smallspace fail"><?php 
                                            _e("The update has failed! Please try again later.");
                                            ?>
</p>
						<?php 
                                        }
                                    } else {
Пример #3
0
{
    $pwgenURL = "http://androm.ru/pwgen/passwordGenerator.php?";
    $curl = curl_init($pwgenURL . $params);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}
function debugEcho($string)
{
    echo $string . "\n";
}
function logData($data, $flag = True)
{
    if ($flag) {
        $string = implode(" | ", $data);
        file_put_contents("./log.txt", $string . "\n", FILE_APPEND);
    } else {
        file_put_contents("./log.txt", var_export($data, true) . "\n", FILE_APPEND);
    }
}
debugEcho("Starting");
if ($_GET) {
    debugEcho("It's GET");
    processGET($_GET);
} elseif ($json = file_get_contents("php://input")) {
    processUpdate($json);
} else {
    header("Location: https://telegram.me/FlimFlamBot");
    exit;
}