[vhffs-dev] [1092] Fixed quotacheck and add getquota and setquota to modobot.pl

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


Revision: 1092
Author:   misric
Date:     2007-11-22 16:42:59 +0000 (Thu, 22 Nov 2007)

Log Message:
-----------
Fixed quotacheck and add getquota and setquota to modobot.pl

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


Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl	2007-11-21 20:25:09 UTC (rev 1091)
+++ trunk/vhffs-irc/modobot.pl	2007-11-22 16:42:59 UTC (rev 1092)
@@ -260,7 +260,34 @@
   }
 }
 
+sub get_quota
+{
+        my $groupname = shift;
+        my $group = Vhffs::Group::get_by_groupname( $vhffs , $groupname );
+        unless( defined $group )
+        {
+                irc_msg ($groupname.' : No such group');
+                return;
+        }
+  irc_msg("Group ".$groupname.": ".$group->get_quota_used." / ".$group->get_quota);
 
+}
+
+sub set_quota
+{
+        my $groupname = shift;
+        my $quotavalue = shift;
+        my $group = Vhffs::Group::get_by_groupname( $vhffs , $groupname );
+        unless( defined $group )
+        {
+                irc_msg ($groupname.' : No such group');
+                return;
+        }
+irc_msg("Group ".$groupname.": Setting quota from ".$group->get_quota." to ".$quotavalue);
+$group->set_quota($quotavalue);
+
+}
+
 sub irc_msg
 {
     my $text = shift;
@@ -313,6 +340,8 @@
         irc_msg("owner <group> - give owner information of <group>");
         irc_msg("lsgroup <group> - give the list of users of <group>");
         irc_msg("quotacheck <limit> - give the list of <limit> users where quota limit nearly reach "); 
+        irc_msg("getquota <group> - give quota for <group>");
+        irc_msg("setquota <group> <newquota> - change quota for <group> to <newquota>");
 	irc_msg("whois <domain> - give NS for <domain>");
 
    }
@@ -347,13 +376,33 @@
         $groupid =~ s/^${mynick}: lsgroup //;
         fetch_usergroup ($groupid);
     }
-    elsif ($texte =~ m/^${mynick}: quotacheck$/)
+    elsif ($texte =~ m/^${mynick}: quotacheck [0-9]+$/)
     {
         my $limit = $texte;
-        $limit =~ s/^{mynick}: quotacheck //;
+        $limit =~ s/^${mynick}: quotacheck //;
         quotacheck($limit);
     }
 
+    elsif ($texte =~ m/^${mynick}: getquota [a-z0-9]+$/)
+    {
+        my $groupquota = $texte;
+        $groupquota =~ s/^${mynick}: getquota //;
+        get_quota($groupquota);
+    }
+
+    elsif ($texte =~ m/^${mynick}: setquota [a-z0-9]+ .*$/)
+    {
+        if (is_modo ($nick) == 1)
+        {
+            my $groupname = $texte;
+            my $quotavalue = $texte;
+            $quotavalue =~ s/^${mynick}: setquota [a-z0-9]+ //;
+            $groupname =~ s/^${mynick}: setquota ([a-z0-9]+) .*$/$1/;
+            set_quota($groupname,$quotavalue);
+        }
+
+    }
+
     elsif ($texte =~ m/^${mynick}: whois [a-z0-9\.\-]+$/)
     {
 	my $whois = $texte;


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