[vhffs-dev] [387] Merged misric's modobot patch

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


Revision: 387
Author:   gradator
Date:     2006-12-30 19:25:35 +0000 (Sat, 30 Dec 2006)

Log Message:
-----------
Merged misric's modobot patch

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-irc/modobot.pl
    trunk/vhffs-irc/modobot.pl


Modified: branches/vhffs_4.1/vhffs-irc/modobot.pl
===================================================================
--- branches/vhffs_4.1/vhffs-irc/modobot.pl	2006-12-30 16:14:06 UTC (rev 386)
+++ branches/vhffs_4.1/vhffs-irc/modobot.pl	2006-12-30 19:25:35 UTC (rev 387)
@@ -500,6 +500,55 @@
 
 }
 
+sub owner_info
+{
+  my $groupname = shift;
+  my $group;
+  if ((! defined ($group = new Vhffs::Group( $vhffs , $groupname,'401' ) ) ) || ( $group->fetch < 0 ))
+  {
+    irc_msg ("$groupname : No such groupname");
+  }
+  else
+  {
+    my $user = new Vhffs::User($vhffs,$group->get_owner_username,401);
+    my $ret;
+    $ret = $user->fetch;
+    if ( $ret >= 0 )
+    {
+      irc_msg ($groupname." owned by ". $user->get_username ." (". $user->get_firstname ." ". $user->get_lastname ." [". $user->get_mail ."] )");
+    }
+    else
+    {
+     irc_msg ($groupname." : error fetching user");}
+    }
+}
+
+sub fetch_usergroup
+{
+ my $groupname = shift;
+ my $group;
+ if ((! defined ($group= new Vhffs::Group( $vhffs , $groupname , '401' ) ) ) || ( $group->fetch < 0 ))
+ {
+  irc_msg ("$groupname : No such group");
+ }
+ else
+ {
+  my $users = Vhffs::Group::get_users($group);
+  my $temp;
+  foreach $temp ( @{$users} )
+  {
+   if ( $temp->get_username =~ $group->get_owner_username)
+   {
+    irc_msg(" @ ".$temp->get_username);
+   }
+   else
+   {
+    irc_msg(" + ".$temp->get_username);
+   }
+  }
+ }
+}
+
 sub irc_msg
 {
     my $text = shift;
@@ -551,7 +600,10 @@
 	irc_msg("list - force listing of all objects waiting for moderation");
 	irc_msg("desc <group> - give the description of <group>");
         irc_msg("web2group <website> - give the groupe name of <website>");
-    }
+        irc_msg("owner <group> - give owner information of <group>");
+        irc_msg("lsgroup <group> - give the list of users of <group>"); 
+
+   }
     elsif ($texte =~ m/^${mynick}: list$/)
     {
         @oldgroup = ();
@@ -580,7 +632,20 @@
         find_group_from_web($webtogroup);
     }
 
+    elsif ($texte =~ m/^${mynick}: owner [a-z0-9]+$/)
+    {
+        my $groupid = $texte;
+        $groupid =~ s/^${mynick}: owner //;
+        owner_info ($groupid);
+    }
 
+    elsif ($texte =~ m/^${mynick}: lsgroup [a-z0-9]+$/)
+    {
+        my $groupid = $texte;
+        $groupid =~ s/^${mynick}: lsgroup //;
+        fetch_usergroup ($groupid);
+    }
+
 } # on_public
 
 sub on_kick {

Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl	2006-12-30 16:14:06 UTC (rev 386)
+++ trunk/vhffs-irc/modobot.pl	2006-12-30 19:25:35 UTC (rev 387)
@@ -515,6 +515,55 @@
 
 }
 
+sub owner_info
+{
+  my $groupname = shift;
+  my $group;
+  if ((! defined ($group = new Vhffs::Group( $vhffs , $groupname,'401' ) ) ) || ( $group->fetch < 0 ))
+  {
+    irc_msg ("$groupname : No such groupname");
+  }
+  else
+  {
+    my $user = new Vhffs::User($vhffs,$group->get_owner_username,401);
+    my $ret;
+    $ret = $user->fetch;
+    if ( $ret >= 0 )
+    {
+      irc_msg ($groupname." owned by ". $user->get_username ." (". $user->get_firstname ." ". $user->get_lastname ." [". $user->get_mail ."] )");
+    }
+    else
+    {
+     irc_msg ($groupname." : error fetching user");}
+    }
+}
+
+sub fetch_usergroup
+{
+ my $groupname = shift;
+ my $group;
+ if ((! defined ($group= new Vhffs::Group( $vhffs , $groupname , '401' ) ) ) || ( $group->fetch < 0 ))
+ {
+  irc_msg ("$groupname : No such group");
+ }
+ else
+ {
+  my $users = Vhffs::Group::get_users($group);
+  my $temp;
+  foreach $temp ( @{$users} )
+  {
+   if ( $temp->get_username =~ $group->get_owner_username)
+   {
+    irc_msg(" @ ".$temp->get_username);
+   }
+   else
+   {
+    irc_msg(" + ".$temp->get_username);
+   }
+  }
+ }
+}
+
 sub irc_msg
 {
     my $text = shift;
@@ -566,7 +615,10 @@
 	irc_msg("list - force listing of all objects waiting for moderation");
 	irc_msg("desc <group> - give the description of <group>");
         irc_msg("web2group <website> - give the groupe name of <website>");
-    }
+        irc_msg("owner <group> - give owner information of <group>");
+        irc_msg("lsgroup <group> - give the list of users of <group>"); 
+
+   }
     elsif ($texte =~ m/^${mynick}: list$/)
     {
         @oldgroup = ();
@@ -595,7 +647,20 @@
         find_group_from_web($webtogroup);
     }
 
+    elsif ($texte =~ m/^${mynick}: owner [a-z0-9]+$/)
+    {
+        my $groupid = $texte;
+        $groupid =~ s/^${mynick}: owner //;
+        owner_info ($groupid);
+    }
 
+    elsif ($texte =~ m/^${mynick}: lsgroup [a-z0-9]+$/)
+    {
+        my $groupid = $texte;
+        $groupid =~ s/^${mynick}: lsgroup //;
+        fetch_usergroup ($groupid);
+    }
+
 } # on_public
 
 sub on_kick {


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