Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function check_spam($chat_id, $from_id, $user_id, $timestp, $printSettingsStateMsgTime, $printSettingsStateMsgCount) {
- if (is_dir("spam_cheks")) {
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- 'text' => "no"
- ));
- } else {
- $name_file = "spam_checks/" . $chat_id . "_" . $user_id . ".txt";
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file)) {
- $file = fopen($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file, "w+");
- fwrite($file, $timestp . "\n1");
- } else {
- $file = fopen($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file, "r+");
- $righe = explode("\n", fread($file, filesize($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file)));
- $tim_old = $righe[0];
- $cnt = $righe[1];
- // SECONDI IMPOSTATO A 1
- if (($timestp - $tim_old) <= $printGroupMsgTime) {
- $cnt++;
- fseek($file, 0);
- fwrite($file, $timestp . "\n" . $cnt);
- //MESSAGGI 5 IN 1 SECONDO
- if ($cnt >= $printGroupMsgCount) {
- apiRequest("sendMessage", array(
- 'chat_id' => $chat_id,
- 'text' => "utente bannato"
- ));
- apiRequest("kickChatMember", array(
- 'chat_id' => $chat_id,
- "user_id" => $from_id
- ));
- }
- } else {
- unlink($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file);
- }
- }
- fclose($file);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement