Advertisement
GigilinE

Untitled

Mar 7th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. function check_spam($chat_id, $from_id, $user_id, $timestp, $printSettingsStateMsgTime, $printSettingsStateMsgCount) {
  3. if (is_dir("spam_cheks")) {
  4. apiRequest("sendMessage", array(
  5. 'chat_id' => $chat_id,
  6. 'text' => "no"
  7. ));
  8. } else {
  9. $name_file = "spam_checks/" . $chat_id . "_" . $user_id . ".txt";
  10. if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file)) {
  11. $file = fopen($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file, "w+");
  12. fwrite($file, $timestp . "\n1");
  13. } else {
  14. $file = fopen($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file, "r+");
  15. $righe = explode("\n", fread($file, filesize($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file)));
  16. $tim_old = $righe[0];
  17. $cnt = $righe[1];
  18. // SECONDI IMPOSTATO A 1
  19. if (($timestp - $tim_old) <= $printGroupMsgTime) {
  20. $cnt++;
  21. fseek($file, 0);
  22. fwrite($file, $timestp . "\n" . $cnt);
  23. //MESSAGGI 5 IN 1 SECONDO
  24. if ($cnt >= $printGroupMsgCount) {
  25. apiRequest("sendMessage", array(
  26. 'chat_id' => $chat_id,
  27. 'text' => "utente bannato"
  28. ));
  29.  
  30. apiRequest("kickChatMember", array(
  31. 'chat_id' => $chat_id,
  32. "user_id" => $from_id
  33. ));
  34. }
  35. } else {
  36. unlink($_SERVER['DOCUMENT_ROOT'] . "/" . $name_file);
  37. }
  38. }
  39. fclose($file);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement