]> jfr.im git - irc/SurrealServices/srsv.git/commitdiff
Added SpamServ SET, SAVE, REHASH, LISTCONF, as well as
authormusashix90 <redacted>
Wed, 24 Feb 2010 16:58:04 +0000 (16:58 +0000)
committermusashix90 <redacted>
Wed, 24 Feb 2010 16:58:04 +0000 (16:58 +0000)
help docs for each command, and more detailed WATCH
help docs.  Fixed a typo in SpamServ, also changed the
permissions to access SpamServ to IRCOp.

git-svn-id: http://svn.tabris.net/repos/srsv@3376 70d4eda1-72e9-0310-a436-91e5bd24443c

branches/0.4.3/help/spamserv/listconf.txt [new file with mode: 0644]
branches/0.4.3/help/spamserv/rehash.txt [new file with mode: 0644]
branches/0.4.3/help/spamserv/save.txt [new file with mode: 0644]
branches/0.4.3/help/spamserv/set.txt [new file with mode: 0644]
branches/0.4.3/help/spamserv/watch/add.txt [new file with mode: 0644]
branches/0.4.3/help/spamserv/watch/del.txt [new file with mode: 0644]
branches/0.4.3/help/spamserv/watch/list.txt [new file with mode: 0644]
branches/0.4.3/modules/spamserv.pm

diff --git a/branches/0.4.3/help/spamserv/listconf.txt b/branches/0.4.3/help/spamserv/listconf.txt
new file mode 100644 (file)
index 0000000..b91ace1
--- /dev/null
@@ -0,0 +1,4 @@
+%BSpamServ LISTCONF%B lists the known settings of
+the current configuration.
+
+Syntax: %LISTCONF%B
diff --git a/branches/0.4.3/help/spamserv/rehash.txt b/branches/0.4.3/help/spamserv/rehash.txt
new file mode 100644 (file)
index 0000000..294daec
--- /dev/null
@@ -0,0 +1,5 @@
+%BSpamServ REHASH%B reloads the values of
+the configuration.  This does not save any
+recently set values with the %BSET%B command.
+
+Syntax: %BREHASH%B
diff --git a/branches/0.4.3/help/spamserv/save.txt b/branches/0.4.3/help/spamserv/save.txt
new file mode 100644 (file)
index 0000000..b2de278
--- /dev/null
@@ -0,0 +1,4 @@
+%BSpamServ SAVE%B saves the list of watched channels
+as well as the current configuration.
+
+Syntax: %BSAVE%B
diff --git a/branches/0.4.3/help/spamserv/set.txt b/branches/0.4.3/help/spamserv/set.txt
new file mode 100644 (file)
index 0000000..058895e
--- /dev/null
@@ -0,0 +1,8 @@
+%BSpamServ SET%B allows you to modify the
+configuration on the fly.
+
+Syntax: %BSET%B %Uoption%U <%Uvalue%U>
+
+Caveats: This command is limited toi previously
+known options in the configuration file. Use 
+%BSpamServ LISTCONF%B to list those options.
diff --git a/branches/0.4.3/help/spamserv/watch/add.txt b/branches/0.4.3/help/spamserv/watch/add.txt
new file mode 100644 (file)
index 0000000..21a51c6
--- /dev/null
@@ -0,0 +1,4 @@
+%SpamServ WATCH ADD%B adds the specified channel
+to be watched by the SpamServ pseudoclients.
+
+Syntax: %BWATCH ADD%B %U#channel%U
diff --git a/branches/0.4.3/help/spamserv/watch/del.txt b/branches/0.4.3/help/spamserv/watch/del.txt
new file mode 100644 (file)
index 0000000..d75cda8
--- /dev/null
@@ -0,0 +1,5 @@
+%BSpamServ WATCH DEL%B removes a channel from the watch
+list, causing the SpamServ pseudoclient to part the
+channel.
+
+Syntax: %BWATCH DEL%B %U#channel%U
diff --git a/branches/0.4.3/help/spamserv/watch/list.txt b/branches/0.4.3/help/spamserv/watch/list.txt
new file mode 100644 (file)
index 0000000..2d6d3f9
--- /dev/null
@@ -0,0 +1,4 @@
+%BSpamServ WATCH LIST%B lists the currently watched
+channels.
+
+Syntax: %BWATCH LIST%B
index f388edf6fea9fb3185091c716a46e3160e31a726..48f0d3c191edc59a9e63fec1ba40b10750c93460 100644 (file)
@@ -16,10 +16,11 @@ use SrSv::SimpleHash qw(readHash writeHash);
 my $ssnick = 'SpamServ';
 my %chanlist;
 
-use SrSv::Process::InParent qw(list_conf loadconf saveconf);
+use SrSv::Process::InParent qw(list_conf loadconf loadchans saveconf savechans);
 
 # should load both spamserv.conf and chans.conf (if available)
 loadconf();
+loadchans();
 
 addhandler('PRIVMSG', undef, undef, 'spamserv::ss_privmsg');
 addhandler('NOTICE', undef, undef, 'spamserv::ss_notice');
@@ -76,15 +77,42 @@ sub ss_privmsg {
        }
        elsif (lc $dst eq "spamserv") {
                my $user = { NICK => $src, AGENT => $dst };
-               unless(adminserv::is_svsop($user, adminserv::S_ROOT())) {
+               unless(adminserv::is_ircop($user)) {
                        notice($user, "Permission denied");
                        return;
                }
                my @args = split(/\s+/, $msg);
                my $cmd = shift @args;
-               if ($cmd =~ /^help$/) {
+
+               if ($cmd =~ /^help$/i) {
                        sendhelp($user, 'spamserv', @args);
                }
+
+               elsif ($cmd =~ /^rehash/i) {
+                       notice($user, "Loading configuration");
+                       loadconf();
+               }
+
+               if ($cmd =~ /^listconf$/i) {
+                       notice($user, "Configuration:", list_conf);
+               }
+
+               elsif ($cmd =~ /^save/i) {
+                       notice($user, "Saving configuration");
+                       saveconf();
+               }
+
+               elsif ($msg =~ /^set (\S+) (.*)/i) {
+                       if (!adminserv::is_svsop($user, adminserv::S_ROOT())) {
+                               notice($user, 'You do not have sufficient rank for this command');
+                               return;
+                       }
+                       if (update_conf($1, $2)) {
+                               notice($user, "Configuration: $1 = $2");
+                       } else {
+                               notice($user, "This appears to be an invalid option");
+                       }
+               }
                elsif ($cmd =~ /^watch$/i) {
                        ss_watch($user, shift @args, @args);
                }
@@ -148,7 +176,7 @@ sub ss_watch($$@) {
 
 sub ss_list($) {
        my ($user) = @_;
-       notice($user, 'Channels currently being being watched');
+       notice($user, 'Channels currently being watched');
        foreach my $cn (keys(%chanlist)) {
                notice($user, '  '.$cn);
        }
@@ -160,7 +188,7 @@ sub add_channel($$) {
                $chanlist{lc $cn} = 1;
                agent_join((split /!/, $fakehost)[0], $cn) if defined $fakehost;
                notice($user, "Channel \002$cn\002 will now be watched");
-               saveconf();
+               savechans();
                return 1;
        } else {
                notice($user, "Channel \002$cn\002 is already being watched");
@@ -174,7 +202,7 @@ sub del_channel($$) {
                delete($chanlist{lc $cn});
                agent_part((split /!/, $fakehost)[0], $cn, '') if defined $fakehost;
                notice($user, "Channel \002$cn\002 will not be watched");
-               saveconf();
+               savechans();
                return 1;
        } else {
                notice($user, "Channel \002$cn\002 is not being watched");
@@ -182,15 +210,32 @@ sub del_channel($$) {
        }
 }
 
-sub saveconf() {
+sub savechans() {
        my @channels = keys(%chanlist);
        Storable::nstore(\@channels, "config/spamserv/chans.conf");
 }
 
+sub saveconf() {
+       writeHash(\%conf, "config/spamserv/spamserv.conf");
+}
+
+sub list_conf() {
+       my @k = keys(%conf);
+       my @v = values(%conf);
+       my @reply;
+
+       for(my $i=0; $i<@k; $i++) {
+               push @reply, $k[$i]." = ".$v[$i];
+       }
+       return @reply;
+}
+
 sub loadconf() {
        # doesn't seem to pick up any of the values
        %conf = readHash("config/spamserv/spamserv.conf");
+}
 
+sub loadchans() {
        return unless(-f "config/spamserv/chans.conf");
        my @channels = @{Storable::retrieve("config/spamserv/chans.conf")};
        foreach my $cn (@channels) {
@@ -198,6 +243,16 @@ sub loadconf() {
        }
 }
 
+sub update_conf($$) {
+       my ($k,$v) = @_;
+       if (exists($conf{$k})) {
+               $conf{$k} = $v;
+               return 1;
+       } else {
+               return 0;
+       }
+}
+
 sub join_chans() {
        foreach my $cn (keys(%chanlist)) {
                agent_join((split /!/, $fakehost)[0], $cn);
@@ -207,6 +262,6 @@ sub join_chans() {
 sub init { }
 sub begin { }
 sub end { }
-sub unload { saveconf(); }
+sub unload { savechans(); saveconf(); }
 
 1;