@include "irc.awk"
@include "spades.awk"
+#@include "email.awk"
# Initialization
BEGIN {
OWNER = "andy753421"
connect("localhost", "rhawk", "#rhtest");
- join("#rhnoise")
- join("#rhspades")
- join("#sfvlug")
+ if (FIRST) {
+ join("#rhnoise")
+ join("#rhspades")
+ join("#sfvlug")
+ }
}
# Admin
}
# 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 == "TOPIC" && systime()-lastpoll > 60*60*24) ||
(CMD == "PING" && systime()-lastpoll > 60*60*24) ||
-(CMD == "PRIVMSG" && DST == pollchan && /^\.poll/) {
+(CMD == "PRIVMSG" && /^\.poll/) {
if (!topics[pollchan]) {
debug("Unknown topic for " pollchan);
+ send("TOPIC " 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_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(cmd)
+ close(_curl)
+}
+
+# Versin/Uptime
+function uptime(time, fmt) {
+ fmt = "%d:%02d:%02d:%02d"
+ fmt = "%d days %02d:%02d:%02d"
+ return sprintf(fmt,
+ time / (60*60*24),
+ time / (60*60 ) % 24,
+ time / (60 ) % 60,
+ time / (1 ) % 60)
+}
+BEGIN {
+ _cmd = "git describe --always --dirty";
+ _cmd | getline up_version;
+ close(_cmd);
+ up_reload = systime();
+}
+/^\.version/ {
+ say("version: " up_version)
+}
+/^\.uptime/ {
+ _now = systime();
+ say("uptime: " uptime(_now - START) ", " \
+ "reload: " uptime(_now - up_reload))
}
# Fortune
-TO == NICK && /^/ { extra = "" }
+TO == NICK && /^/ { extra = "" }
TO == NICK && /^\.?fortune.*-o/ { extra = "-o" }
TO == NICK && /^\.?fortune/ {
gsub(/.*\.?fortune *|-[a-z]* *|[^a-zA-Z0-9 ]/, "", MSG)
cmd = "fortune " extra " " (MSG ? "-m '" MSG "'" : "-s")
- while (cmd | getline _fortune && lines < 5) {
+ _lines = 0
+ while (cmd | getline _fortune && _lines < 5) {
say(_fortune)
- lines++
+ _lines++
}
close(cmd)
next
say(".delay " i " seconds; .woop " i)
}
+function woop(msg) {
+ gsub(/[^Oo]/, "", $1)
+ _len = length($1)
+ if (_len == 2)
+ _len = 10
+ if ($2)
+ _len = $2
+ _woop = msg
+ for (i=1; i<_len; i++)
+ _woop = _woop " " msg
+ say(_woop)
+}
+
+TO == NICK && /^[Ww][Oo]+[Pp] *([0-9]*)/ {
+ woop("WOOP")
+}
+
+/^~WOOP *([0-9]*)/ {
+ woop("(00/")
+}
+
+/^~woop *([0-9]*)/ {
+ woop("^H^P^P^O")
+}
+
TO == NICK && DST ~ /^#/ {
#say("Hello, " FROM)
}
+#DST != "#sfvlug" &&
!(FROM in bots) &&
MSG !~ /^\./ &&
/awk/ {
say("Awk, awk, awk! I'm a bird!")
}
-/^\.help/ {
+!(FROM in bots) &&
+((TO == NICK && /(help|halp)/) ||
+ /^[^.](help|halp)/) {
reply("Nothing can help you now..")
}
-/Ho.*Ho.*Ho/ {
+/(\<[Hh][Oo]\>.*){3}/ {
say("\00309Merry \00304Christmas!")
}
+!(FROM in bots) &&
+tolower($0) ~ /\<cloud\>/ {
+ _cmd = "shuf clouds.txt"
+ _cmd | getline _cloud
+ close(_cmd)
+ say(_cloud)
+}
+
+/^headshot [Cc]hristmas/ {
+ say(".load Christmas")
+ say(".jingle")
+ say(".unload Christmas")
+}
+
+FROM == "rhnoise" && $2 == "slaps" && $3 == NICK {
+ say(".spin")
+}
+
+/^[Aa]nd now[.,]/ {
+ say("And now...");
+ say("THE LARCH");
+}
+
+# God damn commands
+FROM == "rhnoise" && load_mod {
+ say(".load " load_mod)
+ say("rhnoise: You slag!")
+}
+// {
+ load_mod = ""
+}
+(TO == "rhnoise" && /^load \w+/) ||
+(DST == "#rhniose" && /^\.load [a-z]\w+/) {
+ gsub(/[^a-zA-Z0-9_]/, " ")
+ load_mod = toupper(substr($2,1,1)) substr($2,2);
+}
+
+(DST == "#rhnoise" && /^\.line /) {
+ sub(/\./, "!");
+ say($0);
+ say("scalawag: You slag!")
+}
+
+(DST == "#rhnoise" && /^\.qdb 268$/) {
+ say(".diediedie");
+ next
+}
+(DST == "#rhnoise" && /\.qdb *268/) {
+ say(".slap " FROM);
+ next
+}
+
+# Decrementer
+#BEGIN {
+# user_scores[0] = 1
+#}
+#
+#FROM == "rhnoise" && !length(user_scores) {
+# if (split(MSG, _parts, /, /)) {
+# for (_i=1; _i<=length(_parts); _i++) {
+# split(_parts[_i], _tmp, ": ");
+# user_scores[_i]["user"] = _tmp[1];
+# user_scores[_i]["score"] = _tmp[2];
+# }
+# }
+#}
+#
+#FROM == "rhnoise" && /^User Scores:$/ {
+# delete user_scores
+#}
+#
+#FROM == OWNER && length(user_scores) &&
+#tolower($0) ~ /\<nuclear launch detected\>/ {
+# for (_i=1; _i<=length(user_scores); _i++)
+# say(user_scores[_i]["user"] "--");
+#}
+
+# Misc
{ fflush("") }
# vim: ft=awk