# misogynist.irc: Temporarily kickban someone using a misogynist term. # # COPYRIGHT (C) 2010 Zachary White # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby granted, # provided that the above copyright notice appear in all copies and # that both that copyright notice and this permission notice appear in # supporting documentation. # # THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS # SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY # SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER # RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # Use the pf loader if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; }; package misogynist; # Ensure we start with a clean slate, since this is intended to be a bot if (symbolctl(GET logmsg 1) == "ALIAS") { logmsg Loading misogynist.irc; }{ xecho -b Loading misogynist.irc; }; //dump alias on; load global; set mode_stripper on; # Create our /sets load addset; unless (@getsets(wordban_ban_time)) { addset wordban_ban_time int; set wordban_ban_time 1; }; unless (@getsets(wordban_kick_message)) { addset wordban_kick_message str; set wordban_kick_message $$wordban_ban_time minute ban: http://darkstar.frop.org/how-it-is.html; }; unless (@getsets(wordban_latest_nick)) { addset wordban_latest_nick str; set wordban_latest_nick pinky; }; unless (@getsets(wordban_probation_max)) { addset wordban_probation_max int; set wordban_probation_max 3600; }; unless (@getsets(wordban_target)) { addset wordban_target str; set wordban_target *pinky@*; }; unless (@getsets(wordban_words)) { addset wordban_words str; set wordban_words babe bitch broad chicks cunt dyke skank slut whore; }; unless (@getsets(wordban_ban_expires)) { addset wordban_ban_expires int; set wordban_ban_expires $time(); }; unless (@getsets(wordban_probation_expires)) { addset wordban_probation_expires int; set wordban_probation_expires $time(); }; # Functions alias ban_expires (void) { # Returns a text string describing when the user's ban expires if (time() > wordban_ban_expires) { return Ban expired at $stime($wordban_ban_expires) UTC; }{ return Ban expires $stime($wordban_ban_expires) UTC; }; }; alias probation_expires (void) { # Returns a text string describing when the user's probation expires if (time() > wordban_probation_expires) { return Probation expired at $stime($wordban_probation_expires) UTC; }{ return Probation expires $stime($wordban_probation_expires) UTC; }; }; # Aliases alias expunge (void) { # Clear the target's record and let them start from scratch logmsg Expunging target's record.; ^set wordban_probation_expires $time(); unban $C; status; }; alias kickban (nick, channel, reason) { # Kick the user from the channel mode $channel -o+b $nick $wordban_target; kick $channel $nick $reason; }; alias logfile (message) { # Log a message to the logfile @write($misogynist_log $strftime(%Y-%m-%d %H:%M:%S) $message); }; alias logmsg (message) { # Log a message to the logfile and output it xecho -b $message; logfile $message; }; alias probation (nick, channel, void) { @:probation_period=(rand($wordban_probation_max) + 60); ^set wordban_latest_nick $nick; # Determine the length of the ban if (time() > wordban_probation_expires) { # Not in probation period @:expires=(time() + probation_period); set wordban_ban_time 1; set wordban_probation_expires $expires; }{ # Currently in probation period @:newbantime=(wordban_ban_time * 2); set wordban_ban_time $newbantime; @:expires=((newbantime * 60) + wordban_probation_expires + probation_period); set wordban_probation_expires $expires; }; # Kickban the user logmsg $nick has offended. Kickbanning for $wordban_ban_time minutes; eval kickban $nick $channel $wordban_kick_message; # Release the ban at the appropriate time @:bantime=(wordban_ban_time * 60); @:banexpires=(time() + bantime); set wordban_ban_expires $banexpires; status; ^timer -delete wordban; timer -refnum wordban $bantime unban $channel; }; alias status (void) { # Display the current expiration for the ban and the probation logmsg $ban_expires(); logmsg $probation_expires(); }; alias unban (channel default "$C") { # Unban the target ^set wordban_ban_expires $time(); mode $channel -b $wordban_target; ^timer -delete wordban; invite $channel $wordban_latest_nick; }; # Setup our logging unless (@misogynist_log) { @misogynist_log=open(~/misogynist.log W); logmsg Logfile opened.; }; # Hooks on #^channel_sync 23 "*" (channel, void) { logmsg I have joined $channel; }; on #^msg 23 "skullY expunge" (requester, void) { logmsg Expunge request from ${requester}!$userhost(); if (userhost() == "zwhite@127.0.0.1") { expunge; }; }; on #^msg 23 "skullY reload" (requester, void) { logmsg Reload request from ${requester}!$userhost(); if (userhost() == "zwhite@127.0.0.1") { logmsg Reloading...; //load ~/misogynist.irc; }; }; on #^msg 23 "% help" (requester, void) { # Respond to the "help" command if anyone but the target asks logmsg Help request from ${requester}!$userhost(); if (userhost() !~ wordban_target) { logmsg Help request from $requester!$userhost() fulfilled; notice $requester Available commands: status unban; }; }; on #^msg 23 "% status" (requester, void) { # Respond to the "status" command if anyone but the target asks logmsg Status request from ${requester}!$userhost(); if (userhost() !~ wordban_target) { logmsg Status request sent to $requester!$userhost(); notice $requester $ban_expires(); notice $requester $probation_expires(); }; }; on #^msg 23 "% unban" (requester, void) { # Respond to the "unban" command if anyone but the target asks logmsg Unban request from ${requester}!$userhost(); if (userhost() !~ wordban_target) { logmsg Unban request from $requester!$userhost() fulfilled; unban $C; }; }; on #^join 23 "% % $wordban_target *" (nick, channel, void) { # Kick the target if they've joined while they're supposed to be banned logfile $nick \($userhost()\) has joined $channel; if (time() < wordban_ban_expires) { @:secsleft=(wordban_ban_expires-time()); kickban $nick $channel You are still banned. $secsleft seconds remain; }; }; on #^kick 23 "*" (target, source, channel, message) { # Treat kicks the same as a bad word if (userhost($source) =~ wordban_target) { probation $source $channel $message; }; logfile $source has kicked $target from $channel \($message\); }; on #^mode_stripped 23 "*" (nick, target, mode, argument) { # Prevent the target from banning or deopping anyone if (userhost() =~ wordban_target) { logfile Mode change "$mode $argument" for $target by $nick; switch ($mode) { (+b) { mode $target -b $argument; notice $nick Your banning priviledges have been revoked.; }; (+i) { mode $target -i; notice $nick Your invite only priviledges have been revoked.; }; (+k) { mode $target -k $argument; notice $nick Your key setting priviledges have been revoked.; }; (-o) { mode $target +o $argument; notice $nick Your deopping priviledges have been revoked.; }; }; }; }; on #^public 23 "*" (nick, channel, message) { if (userhost() =~ wordban_target) { # Message sent by the target user. Check for a banned word. logfile <$nick:$channel> $message; fe ($wordban_words) badword { if ("$message" =~ "*${badword}*") { # Target has used a banned word. probation $nick $channel; break; }; }; }; }; logmsg Finished loading misogynist.irc;