Log something more useful when an announcement with no text is made.
authorCMDR furrycat <elite@furrycat.net>
Wed, 2 Nov 2016 19:46:09 +0000 (19:46 +0000)
committerCMDR furrycat <elite@furrycat.net>
Wed, 2 Nov 2016 19:46:09 +0000 (19:46 +0000)
plugin/announcements/announcements.py

index 166e0ff..b8984a8 100644 (file)
@@ -836,19 +836,25 @@ class Announcements(DBConnection):
         filename = 'meow.wav'
 
     try:
+      logtext = text
+      if not logtext:
+        if attachment is not None:
+          logtext = attachment['filename']
+        else:
+          logtext = 'No text'
       if bot.get('dryrun'):
         if not already_posted:
           if voice_only:
             log.info('Dryrun: Not playing announcement {} {} in {}'.format(announcement['id'], filename, channel))
           else:
-            log.info('Dryrun: Not posting announcement {} to {}: {}'.format(announcement['id'], channel, text))
+            log.info('Dryrun: Not posting announcement {} to {}: {}'.format(announcement['id'], channel, logtext))
       else:
         announce = random.random() <= announcement['probability'] if not already_posted else 0
         if announce:
           if voice_only:
             yield from bot.wake_up()
           else:
-            log.info('Posting announcement {} to {}: {}'.format(announcement['id'], channel, text))
+            log.info('Posting announcement {} to {}: {}'.format(announcement['id'], channel, logtext))
             message = yield from bot.say(channel, text, attachment = attachment)
             update['digest'] = bot.digest(message.content)
         else: