[vhffs-dev] [1188] Add moderation delay in modobot.pl |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1188
Author: misric
Date: 2008-04-07 11:36:36 +0200 (Mon, 07 Apr 2008)
Log Message:
-----------
Add moderation delay in modobot.pl
Modified Paths:
--------------
trunk/vhffs-irc/modobot.pl
Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl 2008-04-06 22:45:04 UTC (rev 1187)
+++ trunk/vhffs-irc/modobot.pl 2008-04-07 09:36:36 UTC (rev 1188)
@@ -70,8 +70,9 @@
my $user = $obj->get_user;
my $group = $obj->get_group;
my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $obj->{object_id} );
+ my $duration = delay_modo($obj->get_date);
- my $msg = Vhffs::Functions::type_string_from_type_id( $obj->{type} ).': '.$obj->get_oid.' '.$user->get_username;
+ my $msg = '['.$duration.'] '.Vhffs::Functions::type_string_from_type_id( $obj->{type} ).': '.$obj->get_oid.' '.$user->get_username;
$msg .= ' ('.$user->get_note.')' if( $vhffs->get_config->get_users->{'use_notation'} eq 'yes' );
$msg .= ' ['.$user->get_lang.'] '.$group->get_groupname.' '.$object->get_label.' '.$obj->get_description;
irc_msg( $msg );
@@ -81,6 +82,34 @@
}
}
+sub delay_modo
+{
+ my $last = shift;
+ my $diff = int( time() - $last );
+ my $duration = '';
+ if ( $diff >= 31536000 ) {
+ $duration .= int( $diff / 31536000 ).'y ';
+ $diff %= 31536000;
+ }
+ if ( $diff >= 2678400 ) {
+ $duration .= int( $diff / 2678400 ).'M ';
+ $diff %= 2678400;
+ }
+ if ( $diff >= 86400 ) {
+ $duration .= int( $diff / 86400 ).'d ';
+ $diff %= 86400;
+ }
+ if ( $diff >= 3600 ) {
+ $duration .= int( $diff / 3600 ).'h ';
+ $diff %= 3600;
+ }
+
+ $duration .= int( $diff / 60 ).'m' if ( $diff >= 60 );
+
+ return $duration;
+}
+
+
sub moderate
{
my $oid = shift;