Fix gpxebotrc nick string instead of Who() bug
[people/stefanha/gpxebot.git] / utils.py
index f25663b..4d8e733 100644 (file)
--- a/utils.py
+++ b/utils.py
@@ -9,7 +9,7 @@ def dbg(msg):
     if config.DEBUG:
         sys.stderr.write(msg + '\n')
 
-def email_log(to_address, channel, logfile, aliases):
+def email_log(to_address, subject, logfile, aliases):
     email_addresses = []
     unrecognized = []
     for a in to_address.split(','):
@@ -22,12 +22,13 @@ def email_log(to_address, channel, logfile, aliases):
     if email_addresses:
         header = '''From: %(from_address)s
 To: %(to_address)s
-Subject: irc %(channel)s log
+Subject: %(subject)s
 
-''' % {'from_address': config.FROM_ADDRESS,
-            'to_address': ','.join(email_addresses),
-            'channel': channel,
-            }
+''' % {
+    'from_address': config.FROM_ADDRESS,
+    'to_address': ','.join(email_addresses),
+    'subject': subject,
+}
         msg = header + open(logfile).read()
         s = smtplib.SMTP(config.MTA)
         s.sendmail(config.FROM_ADDRESS, email_addresses, msg)
@@ -45,5 +46,5 @@ def make_log(channel):
 
 def do_log(logs, target, nick, msg):
     if target in logs:
-        (name, f) = logs[target]
-        f.write('%s <%s> %s\n' % (get_time(), nick, msg))
+        log = logs[target]
+        log['fileobj'].write('%s <%s> %s\n' % (get_time(), nick, msg))