From 56225780f4e066ca1a93e953205c9aaf59329489 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sat, 18 Feb 2012 19:29:07 +0000 Subject: [PATCH] Better? --- irc.awk | 23 +++++++++++++---------- rhawk | 2 +- spades.awk | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/irc.awk b/irc.awk index 84b88f4..3fbd613 100644 --- a/irc.awk +++ b/irc.awk @@ -36,13 +36,14 @@ function debug(msg) { } function set() { - debug("CMD: " CMD) - debug("SRC: " SRC) - debug("DST: " DST) - debug("FROM: " FROM) - debug("TO: " TO) - debug("ARG: " ARG) - debug("MSG: " MSG) + debug("CMD: [" CMD "]") + debug("SRC: [" SRC "]") + debug("DST: [" DST "]") + debug("FROM: [" FROM "]") + debug("TO: [" TO "]") + debug("ARG: [" ARG "]") + debug("MSG: [" MSG "]") + debug("$0: [" $0 "]") } # Functions @@ -109,10 +110,10 @@ function reload() { # Input parsing // { + gsub(/\s+/, " ") + gsub(/^ | $/, "") + gsub(/\3[0-9]*/, "") match($0, /(:([^ ]+) +)?(([A-Z0-9]+) +)(([^ ]+) +)?(([^: ]+) +)?(:(.*))/, arr); - gsub(/\s+/, " ", arr[8]) - gsub(/^ | $/, "", arr[8]) - gsub(/\3[0-9]*/, "", arr[8]) SRC = arr[2] CMD = arr[4] DST = arr[6] @@ -128,6 +129,8 @@ function reload() { if (CMD == "PRIVMSG" && DST == NICK && FROM) TO = DST + + set() } # IRC client diff --git a/rhawk b/rhawk index 75c9e3f..282fa0e 100755 --- a/rhawk +++ b/rhawk @@ -116,7 +116,7 @@ TO == NICK && DST ~ /^#/ { !(FROM in bots) && MSG !~ /^\./ && -/\/ { +/awk/ { say("Awk, awk, awk! I'm a bird!") } diff --git a/spades.awk b/spades.awk index 51d18d6..efd4769 100644 --- a/spades.awk +++ b/spades.awk @@ -270,7 +270,7 @@ FROM == OWNER && # Setup -/^\.newgame ?([0-9]+)?$/ { +/^\.newgame ?([0-9]+)?/ { if (sp_state != "new") { reply("There is already a game in progress.") } else { -- 2.43.2