<?php
include 'class/bot_bartender.php';
$botB = new bot_bartender($user['alcohol'], $user['rur'], $user['id']);
if ($user['alcohol'] > $botB->config['ik'] && (time() - $botB->config['ik_time']) > $_SESSION['last_ik_bot']) {
$db->sql_query ("
INSERT INTO message SET
user = '".$user['user']."',
user_id = '".$user['id']."',
time = '".time()."',
msg = 'Ик..Ик..Ик..',
rm = '$rm',
emo = '0',
bb = '0',
color = '0'
");
$_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'] . "'");
$_SESSION['bot_cron'] = time();
}
if(isset($msg[0])=='!'){
$botSql = '';
$botRow = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE id = '" . $botB->config['id_bot'] . "'"));
$sqlTpl = "
INSERT INTO message SET
user = 'Бармен',
user_id = '0',
time = '".(time()+1)."',
msg = '%s',
rm = '$rm',
emo = '0',
bb = '0',
color = '0'
";
switch ($botB->analysis($msg)) {
case '1':
$botSql = sprintf($sqlTpl, mysql_real_escape_string('<b>' . $user['user'] . '</b>, ' . $botB->youDrunk()));
break;
case '2':
$botSql = sprintf($sqlTpl, mysql_real_escape_string('<b>' . $user['user'] . '</b>, У тебя не достаточно денег'));
break;
case '3':
$_SESSION['bot_cron'] = time();
$tost = !$botB->eda ? '<b>Тост:</b> ' . $botB->toast() : '';
$botSql = sprintf($sqlTpl, mysql_real_escape_string("<b>" . $user['user'] . "</b>, заказал " . $botB->team . ". Заказ выполнен.\n".$tost));
mysql_query("UPDATE users SET rur = '" . $botB->update_money . "', alcohol = '" . $botB->update_alcohol . "' WHERE id = '" . $user['id'] . "'");
break;
}
$msg = $botB->msg;
if ($botSql != '') mysql_query ($botSql);
}
//print_r($user);
//print_r($botB->config);
?>