[vhffs-dev] [1579] fixed (or probably fixed, not tested at all ;-) ) many regexp

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1579
Author:   gradator
Date:     2010-03-28 23:50:38 +0200 (Sun, 28 Mar 2010)
Log Message:
-----------
fixed (or probably fixed, not tested at all ;-) ) many regexp

Modified Paths:
--------------
    trunk/vhffs-irc/modobot.pl

Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl	2010-03-27 22:31:58 UTC (rev 1578)
+++ trunk/vhffs-irc/modobot.pl	2010-03-28 21:50:38 UTC (rev 1579)
@@ -364,30 +364,24 @@
     my $user = Vhffs::User::get_by_ircnick($vhffs, $nick);
     $user = Vhffs::User::get_by_username($vhffs, $nick) unless(defined $user);
 
-    if ($texte =~ m/^${mynick}: accept [0-9]+.*$/)
+    if ($texte =~ m/^${mynick}:\s+accept\s+[0-9]+.*$/)
     {
-        if (is_modo ($user) == 1)
+		if (is_modo ($user) == 1)
 		{
-		    my $oid = $texte;
-		    my $raison = $texte;
-			Vhffs::Main::current_user_uid($user->get_uid);
-		    $raison =~ s/^${mynick}: accept [0-9]+ *//;
-		    $oid =~ s/^${mynick}: accept ([0-9]+).*$/$1/;
-       	    moderate( $oid , 1 , $raison);
+			my ( $oid , $reason ) = ( $texte =~ /^${mynick}:\s+accept\s+([0-9]+)(?:\s+)?(.+)?$/ );
+			Vhffs::Main::current_user_uid( $user->get_uid );
+			moderate( $oid , 1 , $reason );
 		}
     }
-    elsif ($texte =~ m/^${mynick}: refuse [0-9]+ .*$/)
+    elsif ($texte =~ m/^${mynick}:\s+refuse\s+[0-9]+\s+.+$/)
     {
-        if (is_modo ($user) == 1) {
-			my $oid = $texte;
-			my $raison = $texte;
+		if (is_modo ($user) == 1) {
+			my ( $oid , $reason ) = ( $texte =~ /^${mynick}:\s+refuse\s+([0-9]+)(?:\s+)(.+)$/ );
 			Vhffs::Main::current_user_uid($user->get_uid);
-			$raison =~ s/^${mynick}: refuse [0-9]+ +//;
-			$oid =~ s/^${mynick}: refuse ([0-9]+) .*$/$1/;
-			moderate( $oid , 0 , $raison);
+			moderate( $oid , 0 , $reason );
 		}
     }
-    elsif ($texte =~ m/^${mynick}: help$/)
+    elsif ($texte =~ m/^${mynick}:\s+help\s+$/)
     {
         irc_msg("Commands :");
         irc_msg("help - show this help");
@@ -404,69 +398,69 @@
 	irc_msg("whois <domain> - give NS for <domain>");
 
    }
-    elsif ($texte =~ m/^${mynick}: list$/)
+    elsif ($texte =~ m/^${mynick}:\s+list\s+$/)
     {
 	list_moderation( 0 );
     }
-    elsif ($texte =~ m/^${mynick}: desc [a-z0-9]+$/)
+    elsif ($texte =~ m/^${mynick}:\s+desc\s+[a-z0-9]+\s+$/)
     {
         my $groupid = $texte;
-	$groupid =~ s/^${mynick}: desc //;
+	$groupid =~ s/^${mynick}:\s+desc\s+//;
         get_desc ($groupid);
     }
 
-    elsif ($texte =~ m/^${mynick}: web2group [a-z0-9\.\-]+$/)
+    elsif ($texte =~ m/^${mynick}:\s+web2group\s+[a-z0-9\.\-]+\s+$/)
     {
         my $webtogroup = $texte;
-        $webtogroup =~ s/^${mynick}: web2group //;
+        $webtogroup =~ s/^${mynick}:\s+web2group\s+//;
         find_group_from_web($webtogroup);
     }
 
-    elsif ($texte =~ m/^${mynick}: owner [a-z0-9]+$/)
+    elsif ($texte =~ m/^${mynick}:\s+owner\s+[a-z0-9]+\s+$/)
     {
         my $groupid = $texte;
-        $groupid =~ s/^${mynick}: owner //;
+        $groupid =~ s/^${mynick}:\s+owner\s+//;
         owner_info ($groupid);
     }
 
-    elsif ($texte =~ m/^${mynick}: lsgroup [a-z0-9]+$/)
+    elsif ($texte =~ m/^${mynick}:\s+lsgroup\s+[a-z0-9]+\s+$/)
     {
         my $groupid = $texte;
         $groupid =~ s/^${mynick}: lsgroup //;
         fetch_usergroup ($groupid);
     }
-    elsif ($texte =~ m/^${mynick}: quotacheck [0-9]+$/)
+    elsif ($texte =~ m/^${mynick}:\s+quotacheck\s+[0-9]+\s+$/)
     {
         my $limit = $texte;
-        $limit =~ s/^${mynick}: quotacheck //;
+        $limit =~ s/^${mynick}:\s+quotacheck\s+//;
         quotacheck($limit);
     }
 
-    elsif ($texte =~ m/^${mynick}: getquota [a-z0-9]+$/)
+    elsif ($texte =~ m/^${mynick}:\s+getquota\s+[a-z0-9]+\s+$/)
     {
         my $groupquota = $texte;
-        $groupquota =~ s/^${mynick}: getquota //;
+        $groupquota =~ s/^${mynick}:\s+getquota\s+//;
         get_quota($groupquota);
     }
 
-    elsif ($texte =~ m/^${mynick}: setquota [a-z0-9]+ .*$/)
+    elsif ($texte =~ m/^${mynick}:\s+setquota\s+[a-z0-9]+\s+.*$/)
     {
         if (is_modo ($user) == 1)
         {
             my $groupname = $texte;
             my $quotavalue = $texte;
 			Vhffs::Main::current_user_uid($user->get_uid);
-            $quotavalue =~ s/^${mynick}: setquota [a-z0-9]+ //;
-            $groupname =~ s/^${mynick}: setquota ([a-z0-9]+) .*$/$1/;
+            $quotavalue =~ s/^${mynick}:\s+setquota\s+[a-z0-9]+\s+//;
+            $groupname =~ s/^${mynick}:\s+setquota\s+([a-z0-9]+)\s+.*$/$1/;
             set_quota($groupname,$quotavalue);
         }
 
     }
 
-    elsif ($texte =~ m/^${mynick}: whois [a-z0-9\.\-]+$/)
+    elsif ($texte =~ m/^${mynick}:\s+whois\s+[a-z0-9\.\-]+\s+$/)
     {
 	my $whois = $texte;
-	$whois =~ s/^${mynick}: whois //;
+	$whois =~ s/^${mynick}:\s+whois\s+//;
 	my $resolv = Net::DNS::Resolver->new;
 	
 	if (my $query = $resolv->query($whois, "NS")) 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/