X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=email.awk;h=7f007b5e277942c830f171521bda2ca03c99da2d;hb=6eac07af1ef9ef8c977778e0209e74a6d8f1f267;hp=090a91312c2c6b6190b033786f47ceb670fe3649;hpb=7e1d7e593b94530039f68321b55d0ef700834a68;p=~andy%2Frhawk diff --git a/email.awk b/email.awk index 090a913..7f007b5 100644 --- a/email.awk +++ b/email.awk @@ -1,21 +1,31 @@ @include "json.awk" # Save email addresses -BEGIN { json_load("var/mail.txt", mail_enable) } -END { json_save("var/mail.txt", mail_enable) } +END { + json_save("var/mail.json", mail_enable) +} + +BEGIN { + json_load("var/mail.json", mail_enable) + for (_user in mail_enable) + debug("watching " mail_enable[_user] " for " _user) +} + +TO == NICK && /^sync/ { + json_load("var/mail.json", mail_enable) + for (_user in mail_enable) + debug("watching " mail_enable[_user] " for " _user) +} # Email notifications BEGIN { - mail_hist = 2*60 # If the users has not spoken withn mail_before before - mail_before = 2*60 # someone mentions their name and does not reply within - mail_after = 2*60 # mail_after seconds, email them hist seconds of the backlog + mail_hist = 5*60 # If the users has not spoken withn mail_before before + mail_before = 5*60 # someone mentions their name and does not reply within + mail_after = 5*60 # mail_after seconds, email them hist seconds of the backlog mail_from = NICK "" mail_err = "If you received this message in error,\n" \ "someone in #rhnoise is being a jerk" - - for (_user in mail_enable) - debug("watching " mail_enable[_user] " for " _user) } function mail_send(addr, subj, body, @@ -43,7 +53,7 @@ function mail_prep(user, chan, for (si = 1; si <= sn; si++) { sec = ss[si] mn = length(mail_log[chan][sec]) - for (mi = 0; mi < mn; mi++) { + for (mi = 0; mi < mn; mi++) { msg = mail_log[chan][sec][mi] if (sec > mail_ready[user][chan] - mail_hist) { if (msg ~ user) @@ -54,7 +64,7 @@ function mail_prep(user, chan, } } } - privmsg(chan, "notifying " user " at " addr) + say(chan, "notifying " user " at " addr) mail_send(addr, "Message for " user " in " chan, body) delete mail_ready[user][chan] } @@ -70,7 +80,7 @@ function mail_run( user, chan, ready, time) } } -FROM ~ OWNER && +AUTH == OWNER && TO == NICK && /^e?mail .* .*/ { reply("notifying " $2 " for " $3) @@ -87,7 +97,7 @@ TO == NICK && mail_enable[_user] = _addr } -FROM ~ OWNER && +AUTH == OWNER && TO == NICK && /^stfu .*/ { reply("well fine then")