use Irssi; use strict; use Irssi::Irc; sub cmd_ruptime { my $hourstext; my $minutestext; my $secondstext; my $daystext; my $grabrecord = `ud -d | grep One`; my @temp = split(/:/,$grabrecord); @temp = split(/ /,$temp[1]); my $insert = $temp[2]; my @temp = split(/day/,$grabrecord); @temp = split(/:/,$temp[0]); if (!$insert) { splice @temp,1,0,$insert; } my $days = int($temp[1]); my $hours = int($temp[2]); my $minutes = int($temp[3]); @temp = split(/ /,$temp[4]); my $seconds = int($temp[0]); @temp = split(/,/,$grabrecord); @temp = split(/running/,$temp[1]); my @temp = split(/:/,$temp[0]); if ($days != 0) { $daystext = $days."d "; $hours = int($temp[0]); $minutes = int($temp[1]); $seconds = int($temp[2]); } if ($hours > 0) { $hourstext = $hours."h "; } if ($minutes > 0) { $minutestext = $minutes."m "; } if ($seconds > 0) { $secondstext = $seconds."s "; } @temp = split(/ended/,$grabrecord); @temp = split(/ /,$temp[1]); my $month = $temp[2]; my $date = $temp[3]; my $year = $temp[5]; my @date2 = qw(th st nd rd); my $date2 = substr($date2[0].$date2[int(substr($date, -1))],-2); my $date3 = substr($date,-2,1); if (int($date3) == 1) { $date2 = $date2[0]; } $date = $date.$date2." ".$month." ".$year; my $space = " "; my $output = "Record Uptime: $daystext$hourstext$minutestext$secondstext"."set on $date"; $output =~ s/$space$space/$space/g; Irssi::active_win()->command("say $output"); } Irssi::command_bind("ruptime", "cmd_ruptime");