]> Pileus Git - ~andy/rhawk/commitdiff
Move mail_from address to mail_send function
authorAndy Spencer <andy753421@gmail.com>
Sat, 25 Oct 2014 17:17:02 +0000 (17:17 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 25 Oct 2014 17:30:36 +0000 (17:30 +0000)
BEGIN blocks should only setup local variables since it runs before the
connection is created to the IRC server. I.e. the NICK variable has not
been set yet.

email.awk

index fbcf7dbc91b0fdaf08b0339fe166a21403e35cb9..eec7bd675c0a525644f53cc1d09868eaf9826a82 100644 (file)
--- a/email.awk
+++ b/email.awk
@@ -18,23 +18,24 @@ BEGIN {
        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 "<" NICK "@pileus.org>"
-       mail_err    = "If you received this message in error,\n" \
-                     "someone in #rhnoise is being a jerk"
 }
 
 function mail_send(addr, subj, body,
-                  sendmail, errmsg)
+                  from, error, sendmail, errmsg)
 {
+       from  = NICK "<" NICK "@pileus.org>"
+       error = "If you received this message in error,\n" \
+               "someone in #rhnoise is being a jerk"
+
        gsub(/[^a-zA-Z0-9_+@.-]/, "", addr)
        sendmail = "/usr/sbin/sendmail " addr
-       print "To: " addr        | sendmail
-       print "From: " mail_from | sendmail
-       print "Subject: " subj   | sendmail
-       print ""                 | sendmail
-       print body               | sendmail
-       print mail_err           | sendmail
+       print "To: " addr      | sendmail
+       print "From: " from    | sendmail
+       print "Subject: " subj | sendmail
+       print ""               | sendmail
+       print body             | sendmail
+       print ""               | sendmail
+       print error            | sendmail
        close(sendmail)
 }