]> Pileus Git - ~andy/rhawk/commitdiff
Move SFVLUG code to separate file
authorAndy Spencer <andy753421@gmail.com>
Sun, 21 Dec 2014 10:54:51 +0000 (10:54 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 21 Dec 2014 10:54:51 +0000 (10:54 +0000)
rhawk
sfvlug.awk [new file with mode: 0644]

diff --git a/rhawk b/rhawk
index e9ee570c5ea472da83d0a691266dc2432b4114d5..b2173fc1a7d05d169a2d5324004e4fe0c98aa932 100755 (executable)
--- a/rhawk
+++ b/rhawk
@@ -4,6 +4,7 @@
 @include "json.awk"
 @include "spades.awk"
 @include "email.awk"
 @include "json.awk"
 @include "spades.awk"
 @include "email.awk"
+@include "sfvlug.awk"
 
 # Initialization
 BEGIN {
 
 # Initialization
 BEGIN {
@@ -97,53 +98,6 @@ CMD == "NICK" && FROM in bots {
        json_save("var/nocolor.json", nocolor);
 }
 
        json_save("var/nocolor.json", nocolor);
 }
 
-# SFV Lug
-function email(to, from, subj, body, sendmail)
-{
-       from     = NICK "<andy@pileus.org>"
-       subj     = "Update sfvlug.org!"
-       body     = "The next SFVLUG meeting is TBA!"
-       sendmail = "/usr/sbin/sendmail '" to "'"
-       print "To: " to        | sendmail
-       print "From: " from    | sendmail
-       print "Subject: " subj | sendmail
-       print ""               | sendmail
-       print body             | sendmail
-       say("Topic out of date, emailing " to);
-       close(sendmail)
-}
-
-BEGIN { pollchan = "#sfvlug" }
-(CMD == "PING"    && systime()-lastpoll > 60*60*24) ||
-(CMD == "PRIVMSG" && /^\.poll/) {
-       if (!TOPICS[pollchan]) {
-               debug("Unknown topic for " pollchan);
-               send("TOPIC " pollchan)
-               next
-       }
-       _curl     = "curl -s http://sfvlug.org/"
-       _day      = "(Sun|Mon|Tue|Wed|Thu|Fri|Sat)"
-       _web_tba  = "next meeting is: TBA"
-       _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_tba))
-               #       email("Brian <brian@zimage.com>");
-               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
-               }
-       }
-       lastpoll = systime()
-       close(_curl)
-}
-
 # Versin/Uptime
 function head(cmd, var) {
        cmd | getline var
 # Versin/Uptime
 function head(cmd, var) {
        cmd | getline var
diff --git a/sfvlug.awk b/sfvlug.awk
new file mode 100644 (file)
index 0000000..0426aa4
--- /dev/null
@@ -0,0 +1,47 @@
+# SFV Lug
+function email(to, from, subj, body, sendmail)
+{
+       from     = NICK "<andy@pileus.org>"
+       subj     = "Update sfvlug.org!"
+       body     = "The next SFVLUG meeting is TBA!"
+       sendmail = "/usr/sbin/sendmail '" to "'"
+       print "To: " to        | sendmail
+       print "From: " from    | sendmail
+       print "Subject: " subj | sendmail
+       print ""               | sendmail
+       print body             | sendmail
+       say("Topic out of date, emailing " to);
+       close(sendmail)
+}
+
+BEGIN { pollchan = "#sfvlug" }
+(CMD == "PING"    && systime()-lastpoll > 60*60*24) ||
+(CMD == "PRIVMSG" && /^\.poll/) {
+       if (!TOPICS[pollchan]) {
+               debug("Unknown topic for " pollchan);
+               send("TOPIC " pollchan)
+               next
+       }
+       _curl     = "curl -s http://sfvlug.org/"
+       _day      = "(Sun|Mon|Tue|Wed|Thu|Fri|Sat)"
+       _web_tba  = "next meeting is: TBA"
+       _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_tba))
+               #       email("Brian <brian@zimage.com>");
+               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
+               }
+       }
+       lastpoll = systime()
+       close(_curl)
+}
+