#!/usr/bin/mawk -f # MiscMsg - various small yet useful commands, implemented in awk. # # Copyright (C) 2005 Tim Retout # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # $2 == "yarr" {print $1 " Yarr!"} $2 == "hello" {print $1 " Hello, $NICK!"} $2 == "echo" {print $1 " " $3} $2 == "ct" {print $1 " " ct[int(3 * rand())]} $2 == "8ball" {print $1 " " eightball[int(35 * rand())]} $2 == "you" {print $1 " $NICK: no, /you/ " $3} $2 == "date" {"date +'%d %b %Y'" | getline date print $1 " $NICK: The date is " date "."} $2 == "time" {"date +%T" | getline time print $1 " $NICK: The time is " time "."} $2 == "tov" {"uptime" | getline uptime; print $1 " $NICK: " uptime} $2 == "rand" {print $1 " " (1*$3 ? $3 : 1)*rand()} $2 == "flipacoin" { if (NF == 2) {print $1 " $NICK: " coin[int(2 * rand())] "!"} else { num = split($3, flip, /, or |, | or /); if (num == 1) { answer = yesno[int(2 * rand())] } else { answer = flip[1 + int(num * rand())] } print $1 " $NICK: Answer to \"" $3 "\" is " answer "." } } BEGIN { # Split fields on tabs. FS = "\t" # Register the commands print "REG yarr Says 'Yarr!'" print "REG hello Says hello." print "REG echo Says its arguments unchanged." print "REG ct Tests if your connection is working." print "REG 8ball Ask PogoBOT the oracle." print "REG you Replies in kind." print "REG date Prints the current date." print "REG time Prints the current time." print "REG tov Shows the uptime and load average of the server." print "REG rand Returns a random number." print "REG flipacoin Chooses randomly between several options." # Array for !ct ct[0] = "Yes, your connection is working fine." ct[1] = "No, your connection seems to be horribly broken." ct[2] = "I have no idea whether your connection is working or not." # Array for !8ball eightball[0] = "Signs point to yes." eightball[1] = "Yes." eightball[2] = "Reply hazy, try again." eightball[3] = "Without a doubt." eightball[4] = "My sources say yes." eightball[5] = "As I see it, yes." eightball[6] = "You may rely on it." eightball[7] = "Concentrate and ask again." eightball[8] = "Outlook not so good." eightball[9] = "It is decidedly so." eightball[10] = "Better not tell you now." eightball[11] = "Very doubtful." eightball[12] = "Yes - definitely." eightball[13] = "It is certain." eightball[14] = "Cannot predict now." eightball[15] = "Most likely." eightball[16] = "Ask again later." eightball[17] = "My reply is no." eightball[18] = "Outlook good." eightball[19] = "Don't count on it." eightball[20] = "Yes, in due time." eightball[21] = "My sources say no." eightball[22] = "Definitely not." eightball[23] = "No." eightball[24] = "You will have to wait." eightball[25] = "I have my doubts." eightball[26] = "Outlook so so." eightball[27] = "Looks good to me!" eightball[28] = "Who knows?" eightball[29] = "Looking good!" eightball[30] = "Probably." eightball[31] = "Are you kidding?" eightball[32] = "Go for it!" eightball[33] = "Don't bet on it." eightball[34] = "Forget about it." # Arrays for !flipacoin coin[0] = "Heads" coin[1] = "Tails" yesno[0] = "Yes" yesno[1] = "No" }