rendered paste body#!perl -w
@erlaubt;
###################################################################
# Start Editing here ;)
###################################################################
# Diese Nachricht wird dem User angezeigt, der dich anqueryt.
$deny_message = "Auto-Message: Votre demande a bien été notée, le temps d'attente est estimé à 0.32 euros/min. Merci de bien vouloir patienter";
# Diese Nachricht wird dem User angezeigt, wenn du ihm den erfragten Query erlaubst.
$allow_message = "Auto-Message: Merci d'avoir patienté, un conseiller va répondre à votre demande.";
###################################################################
# 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 est déjà autorisé.");
}
}
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 n'est pas autorisé.");
return 1;
}
else {
$temp = splice(@erlaubt,$idx,1);
}
}
else {
$temp = pop(@erlaubt);
}
IRC::print("Message privé de $temp encore bloqué");
&save_conf();
}
return 1;
}
sub allowliste {
$schleife= 0;
IRC::print("Les messages privés sont autorisés pour:\n");
foreach $temp (@erlaubt) {
IRC::print("($schleife) $temp");
$schleife++; }
return 1;
}
sub qb_on_off {
if($qbs == 1) {
IRC::print("Query-Blocker deactivated!\nTo reactivate /qb");
$qbs = 0;
return 1; }
else {
IRC::print("Query-Blocker activated!\nTo deactivate /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 $QUser Voudrais un privé (Pour accepter: /oki): $QMessage");
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 (<CONF>) {
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;
}
}