diff --git a/bin/auto b/bin/auto index 0be2214..d16be22 100755 --- a/bin/auto +++ b/bin/auto @@ -105,12 +105,46 @@ println "* ".NAME." (version ".VER.".".SVER.".".REV.RSTAGE.") is starting up..." our ($APID, %TIMERS); -# Check for debug mode. +# Get arguments. our $DEBUG = 0; +our $NUC = 0; if (defined $ARGV[0]) { - if ($ARGV[0] eq '-d') { - $DEBUG = 1; - } + foreach (@ARGV) { + given ($_) { + when ('-d') { $DEBUG = 1; } + when ('-nuc') { $NUC = 1; } + } + } +} + +# Check for updates. +if (!$NUC and RSTAGE ne 'd') { + println "* Connecting to update server..."; + my $uss = IO::Socket::INET->new( + 'Proto' => 'tcp', + 'PeerAddr' => 'dist.xelhua.org', + 'PeerPort' => 80, + 'Timeout' => 30 + ) or err(1, "Cannot connect to update server! Aborting update check."); + send($uss, "GET http://dist.xelhua.org/auto/version.txt\n", 0); + my $dll = ''; + while (my $data = readline($uss)) { + $data =~ s/(\n|\r)//g; + my ($v, $c) = split('=', $data); + + if ($v eq "url") { + $dll = $c; + } + elsif ($v eq "version") { + if (VER.".".SVER.".".REV.RSTAGE ne $c) { + println("!!! NOTICE !!! Your copy of Auto is outdated. Current version: ".VER.".".SVER.".".REV.RSTAGE." - Latest version: ".$c); + println("!!! NOTICE !!! You can get the latest Auto by downloading ".$dll); + } + else { + println("* Auto is up-to-date."); + } + } + } } # Parse configuration file. diff --git a/doc/CHANGELOG b/doc/CHANGELOG index bc111a4..b0878af 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev ================================================================== + * Added update check for non-indev releases. * Added Git revision to version string for dev releases. * Added an FML module for retrieving random FML quotes. * Privilege to use a command is now handled by the priv arg of