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
# 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()
filename = announcement['sound']
if not filename:
filename = 'meow.wav'
+ log.debug('Will play {} for announcement {}.'.format(filename, announcement['id']))
try:
logtext = text