<?
if ($_POST['msg']!==NULL){

$bot = mysql_fetch_assoc(mysql_query("SELECT * FROM `bot_tasks` WHERE `words` like '%$_POST[msg]%' LIMIT 1"));




$result=mysql_result(mysql_query("SELECT COUNT(*) FROM `bot_tasks` WHERE `words` like '%$_POST[msg]%'"),0);
if (!$result){
$k_comedy=mysql_result(mysql_query("SELECT COUNT(*) FROM `bot_comedy`"),0);
$comedy = mysql_fetch_assoc(mysql_query("SELECT * FROM `bot_comedy` LIMIT ".rand(1,$k_comedy).",1"));

$bot_msg=$comedy[msg]; 


mysql_query("INSERT INTO `bot_tasks_new` (`id_user`, `time`, `msg`) values('$user[id]', '$time', '".my_esc($_POST[msg])."')");
}else{ $bot_msg=$bot[answer];}

if ($bot_answer==NULL)
$bot_answer='Я даже не знаю, что ответить :)';
$bot_post=$user['nick'].', '.$bot_msg; mysql_query("INSERT INTO `chat_post` (`bot`, `time`, `msg`, `room`, `privat`) values('$user[id]', '$time', '$bot_post', '$room[id]', '0')");
}
//Автор скрипта PiloT
?>