[vhffs-dev] another patch for modobot.pl |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Hi !
Add 2 functions to modobot.pl :
owner <group> to get owner information (firstname - lastname and email)
of <group>
lsgroup <group> to get userlist of <group>
misric
diff -Naur vhffs/trunk/vhffs-irc/modobot.pl vhffs-dev/trunk/vhffs-irc/modobot.pl
--- vhffs/trunk/vhffs-irc/modobot.pl 2006-12-30 18:30:26.000000000 +0100
+++ vhffs-dev/trunk/vhffs-irc/modobot.pl 2006-12-30 18:44:09.000000000 +0100
@@ -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,6 +647,19 @@
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