bind pub - !idle idleinfo_fnc # # nos_idlerpg.tcl fetches IdleRPG-stats of a given player # # v0.1 - nostromo, Thu Dec 29 16:28:41 2005 # # +---------------------------------------------------------------------------------+ # | EGGDROP_HOME/scripts/idlerpg_stats.pl: | # +---------------------------------------------------------------------------------+ # | | # | #!/usr/bin/perl | # | | # | # | # | # v0.1 - nostromo, Thu Dec 29 16:28:41 2005 | # | # | # | # func::time_to by idlerpg-adv (11-22-2003) by daxxar (http://mental.mine.nu) | # | # | # | | # | use LWP::Simple; | # | use XML::Simple; | # | | # | my $nick = shift(@ARGV); | # | my $username = shift(@ARGV); | # | | # | unless($username) | # | { | # | if($nick =~ /nostromo/) | # | { | # | $username = "nostromo"; | # | } | # | elsif($nick =~ //i) | # | { | # | $username = ""; | # | } | # | elsif [...] | # | else | # | { | # | print "check out http://idlerpg.krameria.net/ for more infos...\n"; | # | exit; | # | } | # | } | # | | # | my $page = get "http://idlerpg.krameria.net/xml.php?player=$username"; | # | | # | my $ref = XMLin("$page"); | # | | # | exit if($ref->{username} =~ /HASH/); | # | | # | print "" . $ref->{username} . " (\"" . $ref->{class} . "\") is currently " . | # | ($ref->{online} ? "online" : "offline") . ", with an item-sum of " . | # | $ref->{items}->{total} . ", leveling up in " . (time_to($ref->{ttl})) . | # | " to level " . ($ref->{level} + 1) . ", on position [" . $ref->{xpos} . | # | "/" . $ref->{ypos} . "]\n"; | # | | # | sub time_to { | # | my @timeunits = ('yr', 'month', 'week', 'day', 'hr', 'min', 'sec'); | # | my @timecalc = (31104000, 2592000, 604800, 86400, 3600, 60, 1); | # | my $seconds = shift; my $output; | # | if ($seconds == 0) { return "0 seconds"; } | # | for my $x (0 .. $#timecalc) { | # | my $y = int($seconds / $timecalc[$x]); | # | if ($y != 0 && $seconds != 0 && $seconds >= $timecalc[$x]) { | # | $seconds = ($seconds % $timecalc[$x]); | # | $output .= "$y $timeunits[$x]"; | # | $output .= 's' unless $y == 1; | # | if ($seconds == 0) { last; } | # | $output .= ', ' if $x < $#timecalc - 1 && ($seconds % $timecalc[$x+1]) | # | && $seconds != 0; | # | $output .= ' and ' if !($seconds % $timecalc[$x+1]); | # | } | # | } | # | return $output; | # | } | # | | # +---------------------------------------------------------------------------------+ # proc idleinfo_fnc {nick uhost hand channel arg} { if { ($channel != "#hgb") } { return } if { ($arg == "") } { putchan $channel "$nick, you should provide at least one username!" } else { putchan $channel "$nick, [get_infos $arg]" } return 1 } proc get_infos { arg } { catch {exec perl /home/nostromo/bin/eggdrop/scripts/idlerpg_stats.pl $arg} rval if { ($rval == "") } { return "there is no such user playing IdleRPG." } return $rval } putlog "\002IdleRPG-Stats\002 by nostromo loaded... (c) 2005"