Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Nuwani \ Bot;
- class Warning extends ModuleBase
- {
- public $warnings = array();
- public function onChannelPrivmsg (Bot $bot, $chan, $nick, $msg)
- {
- $swears = array('fuck', 'shit', 'cunt', 'bitch', 'faggot', ' ass', 'dick', 'nigger', 'dumbass', 'jackass');
- $exceptions = array('assess', 'scunthorpe', 'assoc');
- $swearcount = 0;
- $exceptioncount = 0;
- $msg = strtolower($msg);
- foreach($swears as $swear) {
- $swearcount += substr_count($msg, $swear);
- if($msg == trim($swear))
- $swearcount++;
- }
- foreach($exceptions as $exception) {
- $exceptioncount += substr_count($msg, $exception);
- }
- $netswear = $swearcount-$exceptioncount;
- if($netswear>0) {
- if(!isset($this->warnings[$nick])) {
- $this->warnings[$nick] = 1;
- $bot->send('PRIVMSG '.$chan." :pls2language $nick");
- return;
- }
- else if($this->warnings[$nick]<5) {
- $this->warnings[$nick]++;
- $bot->send('PRIVMSG '.$chan." :pls2language $nick");
- return;
- }
- else if(($this->warnings[$nick])%5 == 0) {
- $this->warnings[$nick]++;
- $bot->send('PRIVMSG '.$chan." :pls2language $nick (".$this->warnings[$nick]." warnings)");
- return;
- }
- else {
- $this->warnings[$nick]++;
- $bot->send('PRIVMSG '.$nick." :pls2language $nick (".$this->warnings[$nick]." warnings)");
- return;
- }
- }
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement