]> Pileus Git - ~andy/rhawk/blob - sfvlug.awk
Move SFVLUG code to separate file
[~andy/rhawk] / sfvlug.awk
1 # SFV Lug
2 function email(to, from, subj, body, sendmail)
3 {
4         from     = NICK "<andy@pileus.org>"
5         subj     = "Update sfvlug.org!"
6         body     = "The next SFVLUG meeting is TBA!"
7         sendmail = "/usr/sbin/sendmail '" to "'"
8         print "To: " to        | sendmail
9         print "From: " from    | sendmail
10         print "Subject: " subj | sendmail
11         print ""               | sendmail
12         print body             | sendmail
13         say("Topic out of date, emailing " to);
14         close(sendmail)
15 }
16
17 BEGIN { pollchan = "#sfvlug" }
18 (CMD == "PING"    && systime()-lastpoll > 60*60*24) ||
19 (CMD == "PRIVMSG" && /^\.poll/) {
20         if (!TOPICS[pollchan]) {
21                 debug("Unknown topic for " pollchan);
22                 send("TOPIC " pollchan)
23                 next
24         }
25         _curl     = "curl -s http://sfvlug.org/"
26         _day      = "(Sun|Mon|Tue|Wed|Thu|Fri|Sat)"
27         _web_tba  = "next meeting is: TBA"
28         _web_ptrn = "next meeting.*" _day "\\w+[, ]+([A-Z]\\w+) +([0-9]+)[, ]+([0-9]+)"
29         _irc_ptrn = _day "\\w*[, ]+([A-Z]\\w+) +([0-9]+)"
30         while (_curl | getline _line) {
31                 #if (match(_line, _web_tba))
32                 #       email("Brian <brian@zimage.com>");
33                 if (match(_line, _web_ptrn, _parts)) {
34                         _date  = _parts[1] " " _parts[2] " " _parts[3]
35                         _topic = TOPICS[pollchan]
36                         sub(_irc_ptrn, _date, _topic)
37                         if (_topic != TOPICS[pollchan])
38                                 topic(pollchan, TOPICS[pollchan] = _topic)
39                         else
40                                 debug("topic is already correct")
41                         break
42                 }
43         }
44         lastpoll = systime()
45         close(_curl)
46 }
47