X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=purple%2Fanswerscripts.d%2F10-menu.pl;h=d055f84eaa7cb6d1f421d21a4852d46f2e3ba8a5;hb=b9de4161887e9793f7792ebb743525a1cb62c8a0;hp=d7afa4e14020d4d71d199095f45b09b3acc985ae;hpb=8be8249a6d931dd8c89bebb2930cdfe721bba02a;p=mirrors%2Flibpurple-core-answerscripts.git diff --git a/purple/answerscripts.d/10-menu.pl b/purple/answerscripts.d/10-menu.pl index d7afa4e..d055f84 100755 --- a/purple/answerscripts.d/10-menu.pl +++ b/purple/answerscripts.d/10-menu.pl @@ -2,15 +2,16 @@ #Just for you to see that you can use almost any language :-) use strict; use warnings; -use Switch; +use v5.10; #given/when (if you need to use older PERL, you can find older version in GIT) -switch ($ENV{ANSW_MSG}) { - case /^!help$/ { print "What did you expected? A help?! :-P"; } - case /^!ping$/ { print "PONG"; } - case /^!whoami$/ { print "You are: $ENV{ANSW_FROM}"; } - case /^!(reboot|reset|restart|halt)$/ { print "Broadcast message: The system is going down for reboot NOW !!"; } - case /^!google/ { print "UTFG Yourself: http://google.com/"; } - case /^!uptime$/ { print qx{uptime}; } - case /^!date$/ { print qx{date}; } - case /^!dmesg$/ { print qx{ dmesg | tail -n 5 | tr '\n' '^' } } +given ($ENV{ANSW_MSG}) { + when (/^!help$/) { print qx{ grep -o 'when \(/[^\$/]*' "$0" | grep -o '!.*' | tr '\n' ',' }; } + when (/^!ping$/) { print "PONG"; } + when (/^!whoami$/) { print "You are: $ENV{ANSW_FROM}"; } + when (/^!status$/) { print "[$ENV{ANSW_STATUS}] $ENV{ANSW_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 (/^!uptime$/) { print qx{uptime}; } + when (/^!date$/) { print qx{date}; } + when (/^!dmesg$/) { print qx{ dmesg | tail -n 5 | tr '\n' '\t' } } }