# Type: Input # Category: Common # Description: Tells current version number of Orangutan # Author: Andriy Lesyuk new Orangutan::Context( response => [ '^(?:Please )?show(?: me)?(?: your)?(?: current)? version!*\.*$', '^What(?:\'s| is)?(?: your)?(?: current)? version\?*!*\.*$' ], handler => sub { my ($context, $user, $item, $answer) = @_; my $changelog = $main::config->Get('orangutan', 'changelog'); if (defined($changelog)) { my $version = undef; if (open(CLOG, '<', $changelog)) { my $firstline = ; if ($firstline =~ /^ *Orangutan *\(([0-9\.-]+)\)/i) { $version = $1; } close(CLOG); } if (defined($version)) { my $format = Orangutan::Context::Random( 'What version?.. Do you have a version?! Kidding... :) My version is %s.', 'Looks like my version is %s...', 'My current version is %s.' ); $user->SendMessage(sprintf($format, $version)); } else { $user->SendMessage([ 'Oops! Please find my creator and tell him that something is wrong on the server... '. 'The changelog file seems to be corrupted... :( Please help!' ]); } } else { $user->SendMessage([ "I'm not some user application! I don't have versions! I'm the one and the only and unique!", 'Well... I was programmed to take a version from changelog file... But I cannot find it. :(' ]); } } ); # kate: syntax perl