[vhffs-dev] [373] Corrected a bug which killed modobot when connection was taking too much time |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [373] Corrected a bug which killed modobot when connection was taking too much time
- From: vhffs-dev@xxxxxxxxx
- Date: Thu, 14 Dec 2006 21:25:51 +0100
Revision: 373
Author: beuss
Date: 2006-12-14 20:25:50 +0000 (Thu, 14 Dec 2006)
Log Message:
-----------
Corrected a bug which killed modobot when connection was taking too much time
Modobot uses new fetching functions
Modified Paths:
--------------
branches/vhffs_4.1/vhffs-irc/modobot.pl
Modified: branches/vhffs_4.1/vhffs-irc/modobot.pl
===================================================================
--- branches/vhffs_4.1/vhffs-irc/modobot.pl 2006-12-11 06:18:29 UTC (rev 372)
+++ branches/vhffs_4.1/vhffs-irc/modobot.pl 2006-12-14 20:25:50 UTC (rev 373)
@@ -24,10 +24,10 @@
use constant
{
- SERVER => "PUT YOUR IRC SERVER HERE",
- PORT => "6667",
- CHANNEL => "IRC CHANNEL TO JOIN",
- NAME => "BOT NAME",
+ SERVER => "PUT YOUR IRC SERVER HERE",
+ PORT => "6667",
+ CHANNEL => "IRC CHANNEL TO JOIN WITH #",
+ NAME => "BOT NAME",
};
@@ -368,15 +368,10 @@
$oid = shift;
$status = shift;
- $object = new Vhffs::Object( $vhffs , $oid , '51' );
+ $object = Vhffs::Object::get_by_id( $vhffs , $oid );
if( ! defined $object )
{
- irc_msg ("Error : Object is null");
- return ( -1 );
- }
- elsif( $object->fetch < 0 )
- {
irc_msg ("Error : Cannot fetch object");
return ( -1 );
}
@@ -390,9 +385,8 @@
if( $status == 1 )
{
$object->set_status( Vhffs::Constants::WAITING_FOR_CREATION );
- my $username = Vhffs::User::get_name_by_uid( $vhffs , $object->get_owner_uid );
- my $userbis = new Vhffs::User( $vhffs , $username , '401' );
- if( $userbis->fetch > 0 )
+ my $userbis = Vhffs::User::get_by_uid( $vhffs , $object->get_owner_uid );
+ if( defined $userbis )
{
my $mail;
$mail = gettext("Your request on VHFFS was accepted\n");
@@ -415,9 +409,8 @@
$raison = shift;
$object->set_status( Vhffs::Constants::VALIDATION_REFUSED );
$object->set_description( $raison );
- my $username = Vhffs::User::get_name_by_uid( $vhffs , $object->get_owner_uid );
- my $userbis = new Vhffs::User( $vhffs , $username , '401' );
- if( $userbis->fetch > 0 )
+ my $userbis = Vhffs::User::get_by_uid( $vhffs , $object->get_owner_uid );
+ if( defined $userbis )
{
if( $vhffs->get_config->use_notation == 1 )
{
@@ -469,21 +462,13 @@
$bot=$self;
$self->join($chan);
irc_msg ("--> Pacman started");
+ &CatchAlrm();
} # on_connect
sub is_modo
{
- my $user = new Vhffs::User( $vhffs, shift, 401 );
- my $ret;
- $ret = $user->fetch;
- if ( $ret >= 0 )
- {
- if( ($user->is_moderator == 1 ) || ( $user->is_admin ) == 1 )
- {
- return 1;
- }
- }
- return 0;
+ my $user = Vhffs::User::get_by_username( $vhffs, shift );
+ return ( (defined $user) && ($user->is_moderator == 1 || $user->is_admin == 1) );
} # is_modo
sub get_desc
@@ -593,7 +578,5 @@
local $SIG{ALRM} = \&CatchAlrm;
-alarm 5;
-
$irc->start;