]> Pileus Git - ~andy/rhawk/commitdiff
update sfvlug, avoid excess topic setting
authorAndy Spencer <andy753421@gmail.com>
Fri, 22 Jun 2012 20:56:37 +0000 (20:56 +0000)
committerAndy Spencer <andy753421@gmail.com>
Fri, 22 Jun 2012 20:56:37 +0000 (20:56 +0000)
rhawk

diff --git a/rhawk b/rhawk
index 34a1ad5e5b9ccfa4f21efef2b10dd80cc398c581..62c1bc983f2d1b9582df1d74b6cbeb6d7e28375e 100755 (executable)
--- a/rhawk
+++ b/rhawk
@@ -80,15 +80,19 @@ BEGIN { pollchan = "#sfvlug" }
                debug("Unknown topic for " pollchan);
                next
        }
-       cmd = "curl -s http://sfvlug.org/"
-       day = "(Sun|Mon|Tue|Wed|Thu|Fri|Sat)"
-       web = "next meeting.*" day "\\w+[, ]+([A-Z]\\w+) +([0-9]+)[, ]+([0-9]+)"
-       irc = day "\\w*[, ]+([A-Z]\\w+) +([0-9]+)"
-       while (cmd | getline line) {
-               if (match(line, web, arr)) {
-                       new = arr[1] " " arr[2] " " arr[3]
-                       sub(irc, new, topics[pollchan])
-                       topic(pollchan, topics[pollchan])
+       _curl     = "curl -s http://sfvlug.org/"
+       _day      = "(Sun|Mon|Tue|Wed|Thu|Fri|Sat)"
+       _web_ptrn = "next meeting.*" _day "\\w+[, ]+([A-Z]\\w+) +([0-9]+)[, ]+([0-9]+)"
+       _irc_ptrn = _day "\\w*[, ]+([A-Z]\\w+) +([0-9]+)"
+       while (_curl | getline _line) {
+               if (match(_line, _web_ptrn, _parts)) {
+                       _date  = _parts[1] " " _parts[2] " " _parts[3]
+                       _topic = topics[pollchan]
+                       sub(_irc_ptrn, _date, _topic)
+                       if (_topic != topics[pollchan])
+                               topic(pollchan, topics[pollchan] = _topic)
+                       else
+                               debug("topic is already correct")
                        break
                }
        }