Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2. use Nuwani \ Bot;
  3.  
  4. class Warning extends ModuleBase
  5. {
  6. public $warnings = array();
  7. public function onChannelPrivmsg (Bot $bot, $chan, $nick, $msg)
  8. {
  9. $swears = array('fuck', 'shit', 'cunt', 'bitch', 'faggot', ' ass', 'dick', 'nigger', 'dumbass', 'jackass');
  10. $exceptions = array('assess', 'scunthorpe', 'assoc');
  11. $swearcount = 0;
  12. $exceptioncount = 0;
  13. $msg = strtolower($msg);
  14. foreach($swears as $swear) {
  15. $swearcount += substr_count($msg, $swear);
  16. if($msg == trim($swear))
  17. $swearcount++;
  18. }
  19. foreach($exceptions as $exception) {
  20. $exceptioncount += substr_count($msg, $exception);
  21. }
  22. $netswear = $swearcount-$exceptioncount;
  23. if($netswear>0) {
  24. if(!isset($this->warnings[$nick])) {
  25. $this->warnings[$nick] = 1;
  26. $bot->send('PRIVMSG '.$chan." :pls2language $nick");
  27. return;
  28. }
  29. else if($this->warnings[$nick]<5) {
  30. $this->warnings[$nick]++;
  31. $bot->send('PRIVMSG '.$chan." :pls2language $nick");
  32. return;
  33. }
  34. else if(($this->warnings[$nick])%5 == 0) {
  35. $this->warnings[$nick]++;
  36. $bot->send('PRIVMSG '.$chan." :pls2language $nick (".$this->warnings[$nick]." warnings)");
  37. return;
  38. }
  39. else {
  40. $this->warnings[$nick]++;
  41. $bot->send('PRIVMSG '.$nick." :pls2language $nick (".$this->warnings[$nick]." warnings)");
  42. return;
  43. }
  44. }
  45. return;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement