use "first recipient"'s name for DM log file

we were using the message author before, which made sense for incoming
messages, but then all the replies were getting dumped to a directory
for the bot, which doesn't make much sense. this will use the "first
recipient", which sounds kind of like a backwards-compat attribute but
does what we want for single-user DMs

if we ever care heavily about multi-user DMs we should maybe look at
channel.recipients, but that probably changes over time, so we'd need
to use channel.id?
This commit is contained in:
Brian S. Stephan 2018-01-17 10:49:29 -06:00
parent 6cef90cf7b
commit 8be039da80
1 changed files with 2 additions and 2 deletions

View File

@ -67,8 +67,8 @@ async def on_message_edit(before, after):
def log_file_for_message(message):
"""For the given message, figure out where we'd log the message."""
if message.channel.is_private:
log_directory = 'DM/{0:s}/'.format(str(message.author))
log_file = '{0:s}-{1:s}.log'.format(str(message.author), str(message.timestamp.strftime('%Y%m')))
log_directory = 'DM/{0:s}/'.format(str(message.channel.user.name))
log_file = '{0:s}-{1:s}.log'.format(str(message.channel.user.name), str(message.timestamp.strftime('%Y%m')))
else:
log_directory = '{0:s}-{1:s}/{2:s}/'.format(str(message.server.id), str(message.server),
str(message.channel))