Greatly improved 10-menu.pl
[mirrors/libpurple-core-answerscripts.git] / purple / answerscripts.d / 10-menu.pl
1 #!/usr/bin/env perl
2 #Just for you to see that you can use almost any language :-)
3 use strict;
4 use warnings;
5 use v5.10; #given/when (if you need to use older PERL, you can find older version in GIT)
6
7 $ENV{ANSW_MSG} =~ m/^([^\s]*)\s*(.*)$/;
8 my $args = $2;
9 given ($1) {
10 when (/^!help$/) { print qx{ grep -o 'when \(/[^\$/]*' "$0" | grep -o '!.*' | tr '\n' ',' }."\n"; }
11 when (/^!ping$/) { print "PONG"; }
12 when (/^!whoami$/) { print "You are $ENV{ANSW_R_ALIAS} also known as $ENV{ANSW_R_NAME}"; }
13 when (/^!whoareyou$/) { print "Hello, my name is $ENV{ANSW_L_ALIAS} ($ENV{ANSW_L_NAME}) ;-)"; }
14 when (/^!version$/) { print "$ENV{ANSW_L_AGENT} $ENV{ANSW_L_AGENT_VERSION}"; }
15 when (/^!status$/) { print "[$ENV{ANSW_L_STATUS}] $ENV{ANSW_L_STATUS_MSG}"; }
16 when (/^!(reboot|reset|restart|halt)$/) { print "Broadcast message: The system is going down for reboot NOW !!"; }
17 when (/^!google$/) { my $q = $args; $q =~ s/ /+/g; print "UTFG Yourself: http://google.com/search?q=$q"; }
18 when (/^!uptime$/) { print qx{uptime}; }
19 when (/^!date$/) { print qx{date}; }
20 when (/^!dmesg$/) { print qx{ dmesg | tail -n 5 | tr '\n' '\t' } }
21 when (/^!df$/) { print qx{ df -hlP / | tail -n 1 } }
22 }
This page took 0.366035 seconds and 4 git commands to generate.