Greatly improved 10-menu.pl
authorHarvie <tomas@mudrunka.cz>
Tue, 22 Feb 2011 03:03:55 +0000 (04:03 +0100)
committerHarvie <tomas@mudrunka.cz>
Tue, 22 Feb 2011 03:03:55 +0000 (04:03 +0100)
purple/answerscripts.d/10-menu.pl

index e64ad6a28063f67cda3df3e7d4275c1c10c5f0bc..0fcccb0f1b7333475efbe497a0e011b83b7fdbf4 100755 (executable)
@@ -4,16 +4,19 @@ use strict;
 use warnings;
 use v5.10; #given/when (if you need to use older PERL, you can find older version in GIT)
 
 use warnings;
 use v5.10; #given/when (if you need to use older PERL, you can find older version in GIT)
 
-given ($ENV{ANSW_MSG}) {
-       when (/^!help$/)        { print qx{ grep -o 'when \(/[^\$/]*' "$0" | grep -o '!.*' | tr '\n' ',' }; }
+$ENV{ANSW_MSG} =~ m/^([^\s]*)\s*(.*)$/;
+my $args = $2;
+given ($1) {
+       when (/^!help$/)        { print qx{ grep -o 'when \(/[^\$/]*' "$0" | grep -o '!.*' | tr '\n' ',' }."\n"; }
        when (/^!ping$/)        { print "PONG"; }
        when (/^!ping$/)        { print "PONG"; }
-       when (/^!whoami$/)      { print "You are: $ENV{ANSW_R_NAME}"; }
-       when (/^!whoareyou$/)   { print "Hello, my name is $ENV{ANSW_L_NAME} ;-)"; }
+       when (/^!whoami$/)      { print "You are $ENV{ANSW_R_ALIAS} also known as $ENV{ANSW_R_NAME}"; }
+       when (/^!whoareyou$/)   { print "Hello, my name is $ENV{ANSW_L_ALIAS} ($ENV{ANSW_L_NAME}) ;-)"; }
        when (/^!version$/)     { print "$ENV{ANSW_L_AGENT} $ENV{ANSW_L_AGENT_VERSION}"; }
        when (/^!status$/)      { print "[$ENV{ANSW_L_STATUS}] $ENV{ANSW_L_STATUS_MSG}"; }
        when (/^!(reboot|reset|restart|halt)$/) { print "Broadcast message: The system is going down for reboot NOW !!"; }
        when (/^!version$/)     { print "$ENV{ANSW_L_AGENT} $ENV{ANSW_L_AGENT_VERSION}"; }
        when (/^!status$/)      { print "[$ENV{ANSW_L_STATUS}] $ENV{ANSW_L_STATUS_MSG}"; }
        when (/^!(reboot|reset|restart|halt)$/) { print "Broadcast message: The system is going down for reboot NOW !!"; }
-       when (/^!google/)       { print "UTFG Yourself: http://google.com/"; }
+       when (/^!google$/)      { my $q = $args; $q =~ s/ /+/g; print "UTFG Yourself: http://google.com/search?q=$q"; }
        when (/^!uptime$/)      { print qx{uptime}; }
        when (/^!date$/)        { print qx{date}; }
        when (/^!dmesg$/)       { print qx{ dmesg | tail -n 5 | tr '\n' '\t' } }
        when (/^!uptime$/)      { print qx{uptime}; }
        when (/^!date$/)        { print qx{date}; }
        when (/^!dmesg$/)       { print qx{ dmesg | tail -n 5 | tr '\n' '\t' } }
+       when (/^!df$/)  { print qx{ df -hlP / | tail -n 1 } }
 }
 }
This page took 0.150046 seconds and 4 git commands to generate.