Файл: social12/chat/bot_bartender.php
Строк: 22
<?php
include 'bartender.php';
$botB = new bot_bartender($user['alcohol'], $user['balls'], $user['id']);
$ids = mt_rand(100000, 999999);
if ($user['alcohol'] > $botB->config['ik'] && (time() - $botB->config['ik_time']) > $_SESSION['last_ik_bot']) {
    mysql_query ("
        INSERT INTO `message` SET
        `id` = '$ids',
        `who` = '$user[id]',
        `user` = '$user[user]',
        `time` = '" . time() . "',
        `msg` = 'Ик..Ик..Ик..',
        `room` = '$rm'
    ");
    $_SESSION['last_ik_bot'] = time();
}
if ($user['alcohol'] && (time() - $botB->config['time']) > $_SESSION['bot_cron']) {
    $user['alcohol'] = $user['alcohol'] ? ($user['alcohol'] - $botB->config['percentage']) : 0;
    if (0 > $user['alcohol']) $user['alcohol'] = 0;
    mysql_query("UPDATE `users` SET `alcohol` = '$user[alcohol]' WHERE `id` = '$user[id]' LIMIT 1");
    $_SESSION['bot_cron'] = time();
}
if (isset($msg)) {
    $botSql = '';
    $botRow = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $botB->config['id_bot'] . "'"));
    $sqlTpl = "INSERT INTO `message` SET
               `id` = '$ids',
               `who` = '0',
               `user` = 'Бармен',
               `time` = '" . (time() + 1) . "',
               `msg` = '%s',
               `room` = '$rm'";
    switch ($botB->analysis($msg)) {
        case 1:
            $botSql = sprintf($sqlTpl, '<b>' . $user['user'] . '</b>, ' . $botB->youDrunk());
        break;
        case 2:
            $botSql = sprintf($sqlTpl, '<b>' . $user['user'] . '</b>, У Вас недостаточно бубликов!');
        break;
        case 3:
            $_SESSION['bot_cron'] = time();
            $tost = !$botB->eda ? '<b>Тост:</b> ' . $botB->toast() : '';
            $botSql = sprintf($sqlTpl, cvetnik($user['id']) . ", заказал " . $botB->team . ". Заказ выполнен.n" . $tost);
            mysql_query("UPDATE `users` SET `balls` = '" . $botB->update_balls . "', `alcohol` = '" . $botB->update_alcohol . "' WHERE `id` = '$user[id]' LIMIT 1");
        break;
    }
    $msg = $botB->msg;
    if ($botSql != '') mysql_query($botSql);
}
?>