Announcement debugging.
authorCMDR furrycat <elite@furrycat.net>
Fri, 11 Nov 2016 11:10:14 +0000 (11:10 +0000)
committerCMDR furrycat <elite@furrycat.net>
Fri, 11 Nov 2016 11:10:14 +0000 (11:10 +0000)
plugin/announcements/announcements.py

index ec47595..77b8aae 100644 (file)
@@ -804,6 +804,7 @@ class Announcements(DBConnection):
       attachment = bot.parse_attachment(announcement['attachment'])
 
     voice_only = attachment is None and announcement['voice_id'] == announcement['channel_id']
+    log.debug('Announcement {} {}.'.format(announcement['id'], 'is voice only' if voice_only else 'has text'))
     already_posted = False
     if voice_only:
       text = None
@@ -822,11 +823,13 @@ class Announcements(DBConnection):
       # Always post private messages.  Try not to spam public announcements.
       if not private and not bot.parse_boolean(announcement['asap']):
         cutoff = datetime.datetime.utcnow() - datetime.timedelta(0, interval)
+        log.debug('Getting logs from {}.'.format(cutoff))
         result = yield from client.logs_from(channel, after = cutoff)
         logs = list(result)
         # Don't spam the same message in a quiet channel even if it hasn't
         # been posted since the cutoff.
         if len(logs) < bot.get('message_limit'):
+          log.debug('Fewer than {} messages ({}).'.format(bot.get('message_limit'), len(logs)))
           logs = yield from client.logs_from(channel, limit = bot.get('message_limit'))
         for message in logs:
           raw = re.sub(r'^(<?@\S+\s)+', '', message.content).strip()
@@ -839,6 +842,7 @@ class Announcements(DBConnection):
       filename = announcement['sound']
       if not filename:
         filename = 'meow.wav'
+        log.debug('Will play {} for announcement {}.'.format(filename, announcement['id']))
 
     try:
       logtext = text