Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
THis bot need for anonymous communication.
<?php
include_once 'db_connect.php';
$response = json_decode(file_get_contents('php://input'), TRUE);
if (!(isset($response)))
{
exit();
}
if (!empty($response['message']['forward_date']))
{
exit();
}
if (isset($response['message']['text']))
{
$text = $response['message']['text']; // Текст сообщения
$chat_id = $response['message']['chat']['id']; // Telegram ID пользователя
$first_name = md5($response['message']['chat']['first_name']); // Имя пользователя
$last_name = md5($response['message']['chat']['last_name']); // Фамилия
if (mb_substr($text, 0, 6) == '/start')
{
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM `users` WHERE `telegram_id`=?");
$stmt->bind_param("i", $chat_id);
$stmt->execute();
$stmt->bind_result($search_user);
$stmt->fetch();
$stmt->close();
if ($search_user == 0)
{
$mysqli->query("INSERT INTO `users` (`telegram_id`, `first_name`, `last_name`) VALUES ('".$chat_id."', '".$first_name."', '".$last_name."')");
}
$message = 'Hello, '.$first_name.' '.$last_name.'.
Show/update chat: /chat
Send message: /send hello
Plus/minus karma: /plus_karma id, /minus_karma id
Top 15 users: /top
THis bot need for anonymous communication.
Our advantages:
+ Chat ONLY for elite hackers
+ NO FBI, NO ADMINS, NO FSB, NO ADS
+ Messages self-destruct in 5 minutes
+ You can edit karma members in chat
More info type about';
sendMessage($chat_id, $message);
}
else if ($text == '/chat')
{
$limit = '20';
$message = TakeTextChat($text, $limit);
$time_now = time();
$time_need = 60*5;
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM messages WHERE data_timestamp+".$time_need.">".$time_now."");
$stmt->execute();
$stmt->bind_result($search_count);
$stmt->fetch();
$stmt->close();
if ($search_count != 0)
{
sendMessage($chat_id, $message);
}
else
{
$message = 'Сообщений в чате нет';
sendMessage($chat_id, $message);
}
}
else if (mb_substr($text, 0, 5) == '/send')
{
$search_time = $mysqli->query("SELECT last_time FROM `users` WHERE `telegram_id`=".$chat_id." LIMIT 1");
$row = $search_time->fetch_row();
$time_now = time();
if ($row[0]+(60*5)>time())
{
$message = 'Попробуйте отправить сообщение через 5 минут!';
sendMessage($chat_id, $message);
die();
}
$search_id = $mysqli->query("SELECT id FROM `users` WHERE `telegram_id`=".$chat_id." LIMIT 1");
$row = $search_id->fetch_row();
$mysqli->query("UPDATE `users` SET last_time=".$time_now." WHERE `telegram_id`=".$chat_id."");
$resultStr = str_replace("/send ", "", $text);
$time_now = time();
$stmt = $mysqli->prepare("INSERT INTO `messages` (`text`, `id_user`, `data_timestamp`) VALUES (?, ?, ?)");
$stmt->bind_param("sii", $resultStr, $row[0], $time_now);
$stmt->execute();
$stmt->close();
$message = 'Сообщение успешно анонимно отправлено в чат!';
sendMessage($chat_id, $message);
}
else if (mb_substr($text, 0, 11) == '/plus_karma')
{
$search_time = $mysqli->query("SELECT last_time2 FROM `users` WHERE `telegram_id`=".$chat_id." LIMIT 1");
$row = $search_time->fetch_row();
$time_now = time();
if ($row[0]+(60*5)>time())
{
$message = 'Попробуйте сделать +1 к карме через 5 минут!';
sendMessage($chat_id, $message);
die();
}
$resultStr = str_replace("/plus_karma ", "", $text);
$stmt = $mysqli->prepare("UPDATE `users` SET karma=karma+1 WHERE `id`=?");
$stmt->bind_param("i", $resultStr);
$stmt->execute();
$stmt->close();
$search_karma = $mysqli->query("SELECT karma FROM `users` WHERE `id`=".$resultStr." LIMIT 1");
$row = $search_karma->fetch_row();
$mysqli->query("UPDATE `users` SET last_time2=".$time_now." WHERE `telegram_id`=".$chat_id."");
$message = 'Вы успешно добавили +1 к карме id'.$resultStr.'
Его карма: '.$row[0].'';
sendMessage($chat_id, $message);
}
else if (mb_substr($text, 0, 12) == '/minus_karma')
{
$search_time = $mysqli->query("SELECT last_time2 FROM `users` WHERE `telegram_id`=".$chat_id." LIMIT 1");
$row = $search_time->fetch_row();
$time_now = time();
if ($row[0]+(60*5)>time())
{
$message = 'Попробуйте сделать -1 к карме через 5 минут!';
sendMessage($chat_id, $message);
die();
}
$mysqli->query("UPDATE `users` SET last_time2=".$time_now." WHERE `telegram_id`=".$chat_id."");
$resultStr = str_replace("/minus_karma ", "", $text);
$search_karma = $mysqli->query("SELECT karma FROM `users` WHERE `id`=".$resultStr." LIMIT 1");
$row = $search_karma->fetch_row();
$message = 'Вы успешно отняли -1 у id'.$resultStr.'
Его карма: '.$row[0].'';
sendMessage($chat_id, $message);
$stmt = $mysqli->prepare("UPDATE `users` SET karma=karma-1 WHERE `id`=?");
$stmt->bind_param("i", $resultStr);
$stmt->execute();
$stmt->close();
}
else if (mb_substr($text, 0, 4) == '/top')
{
$top_q = $mysqli->query("SELECT id, karma FROM users ORDER BY `karma` DESC LIMIT 15");
$message = "<b>TOP 15 users:</b>
";
while ($top_user = mysqli_fetch_array($top_q))
{
$message.= '
<b>id'.$top_user['id'].'</b>: '.$top_user['karma'].'';
}
sendMessage($chat_id, $message);
}
else if (mb_substr($text, 0, 6) == '/about')
{
$message = "THis bot need for anonymous communication. http://wallscollection.net/wp-content/uploads/2016/12/Anonymous-Wallpaper-Hd-For-Desktop-.jpg
Our advantages:
+ Chat ONLY for elite hackers
+ NO FBI, NO ADMINS, NO FSB, NO ADS
+ Super encrypt (MD5) your name and surname
+ Messages self-destruct in 5 minutes
+ You can edit karma members in chat
+ Open Source! <a href='https://github.com/Surzhikov/Telegram-Site-Helper-2.0/blob/master/telegram-site-helper-install.php'>https://gist.github.com/dragon996/d6a4d77e175cfe26853a94057096915e</a>";
sendMessage($chat_id, $message);
}
}
function TakeTextChat($text, $limit, $number = 1)
{
global $mysqli;
$time_now = time();
$time_need = 60*5;
$stmt = $mysqli->prepare("SELECT COUNT(*) FROM messages WHERE data_timestamp+".$time_need.">".$time_now."");
$stmt->execute();
$stmt->bind_result($count_mes);
$stmt->fetch();
$stmt->close();
if ($count_mes > 0)
{
$message = '<b>Anonymous Chat:</b>
';
$messages_q = $mysqli->query("SELECT text, id_user FROM messages WHERE data_timestamp+".$time_need.">".$time_now." ORDER BY `id` DESC LIMIT ".$limit);
while ($messages = mysqli_fetch_array($messages_q))
{
$message.= '
<b>id'.$messages['id_user'].'</b>: '.$messages['text'].'';
}
}
else
{
$message = '0';
}
return $message;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.