#!perl -w @erlaubt; ################################################################### # Start Editing here ;) ################################################################### # Diese Nachricht wird dem User angezeigt, der dich anqueryt. $deny_message = "%C4Auto-Message: %ORight now i ignore all querys - perhaps not all :)"; # Diese Nachricht wird dem User angezeigt, wenn du ihm den erfragten Query erlaubst. $allow_message = "%C4Auto-Message: %OQuery accepted"; ################################################################### # Stop Editing here ;) ################################################################### $scriptname = "GodOfGTA's Query Blocker modif by Zap-Zarerap - made usable by gargelkarg+checkit"; $version = "1.2.3"; $home = IRC::get_info(4); $confpath = "$home/queryblocker.conf"; IRC::register ($scriptname, $version, "", ""); IRC::add_command_handler("qb", "qb_on_off"); IRC::add_command_handler("oki", "erlauben"); IRC::add_command_handler("weg", "nichterlauben"); IRC::add_command_handler("wer", "allowliste"); IRC::add_command_handler("qbhelp", "hilfesystem"); IRC::add_command_handler("query", "eigenerquery"); IRC::add_message_handler(PRIVMSG,auto_answer); IRC::print("Query-Blocker Script loaded and activated!"); IRC::print("To deactivate the script /qb\nHelp with /qbhelp"); $qbs = 1; $letzternick = " "; &load_conf(); $MyName = (IRC::get_info(1)); if (&check_in_list($MyName) == -1) { push(@erlaubt,$MyName); } sub check_in_list { local($nick) = @_; $cnt = 0; CYCLE: foreach (@erlaubt) { if (uc($_) eq uc($nick)) { return $cnt; } $cnt++; } return -1; } sub eigenerquery { local($line) = @_; if($qbs==1) { if (&check_in_list($line) == -1) { push(@erlaubt,$line); } &save_conf(); } return 0; } sub erlauben { local($nick) = @_; if($qbs==1) { if ($nick ne "") { if (&check_in_list($nick) == -1) { push(@erlaubt,$nick); } else { IRC::print("$nick is already in the allow-list."); } } else { if($letzternick eq " ") { return 1; } push(@erlaubt,$letzternick); IRC::command("/query $letzternick"); IRC::command("/msg $letzternick $allow_message "); } &save_conf(); } return 1; } sub nichterlauben { local($nick) = @_; my $idx; if($qbs==1) { if($nick ne "") { $idx = &check_in_list($nick); if ($idx == -1) { IRC::print("$nick is not in the allow-list."); return 1; } else { $temp = splice(@erlaubt,$idx,1); } } else { $temp = pop(@erlaubt); } IRC::print("Query's from $temp will be blocked again"); &save_conf(); } return 1; } sub allowliste { $schleife= 0; IRC::print("Query is allowed to these users:\n"); foreach $temp (@erlaubt) { IRC::print("($schleife) $temp"); $schleife++; } return 1; } sub qb_on_off { if($qbs == 1) { IRC::print("The Query-Blocker has been deactivated!\nTo reactivate it just type /qb"); $qbs = 0; return 1; } else { IRC::print("The Query-Blocker has been activated!\nTo deactivate it just type /qb"); $qbs = 1; return 1; } } sub auto_answer { if($qbs != 0) { local($line) = @_; $MyName = (IRC::get_info(1)); if($line =~ m/:(.+?)\!.+? PRIVMSG $MyName :(\w.*)/) { $QUser = $1; $letzternick = $1; $QMessage = $2; foreach $temp (@erlaubt) { if($temp eq $QUser) { return 0; } } IRC::command("/notice $MyName %B$QUser %OTries to start aquery: $QMessage"); IRC::command("/notice $MyName To allow the query type: %B/oki"); IRC::command("/msg $QUser $deny_message "); return 1; } else { return 0; } } else { return 0; } } sub hilfesystem { IRC::print("\n$scriptname\n---------------------------------------- v$version\n"); IRC::print("Commands: /qb -> Switches the Query-Blocker on or off\n"); IRC::print(" /oki -> Adds the last user, who tried query you,\n"); IRC::print(" to the allow-list (Query accepted).\n"); IRC::print(" /oki nick -> Adds the given nick to the allow-list.\n"); IRC::print(" /wer -> Show's the allow-list (these users may query you).\n"); IRC::print(" /weg -> Removes the last user, you added to the allow-list,\n"); IRC::print(" from the allow list.\n"); IRC::print(" /weg nick -> Removes the given nick from the allow-list.\n"); IRC::print(" If you start a query, the user will be automaticly added to the allow-list.\n"); IRC::print(" The allow-list is NOT case sensitive.\n"); IRC::print(" /qbhelp -> These help :)\n\n"); return 1; } sub load_conf { open (CONF, "<$confpath"); if ( -f CONF) { while () { chop; push (@erlaubt, $_); } close CONF; IRC::print("Config file $confpath loaded"); } } sub save_conf { open (CONF, ">$confpath"); if ( -f CONF) { foreach (@erlaubt) { print CONF $_."\n"; } close CONF; } }