Fix active_members when there are no messages

master
Dan Elkouby 2019-12-31 22:58:06 +00:00
parent 0ca6f4eebd
commit 59b2fc7412
1 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,8 @@
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import datetime
import html import html
import time import time
@ -81,7 +83,8 @@ async def _(event):
from_user=member, from_user=member,
limit=1 limit=1
) )
date = messages[0].date date = (messages[0].date if messages
else datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc))
members.append(( members.append((
date, date,
f"{date:%Y-%m-%d} - {get_who_string(member)}" f"{date:%Y-%m-%d} - {get_who_string(member)}"
@ -90,4 +93,4 @@ async def _(event):
m[1] for m in sorted(members, key=lambda m: m[0], reverse=True) m[1] for m in sorted(members, key=lambda m: m[0], reverse=True)
) )
await event.edit("\n".join(members), parse_mode='html') await event.edit("\n".join(members), parse_mode='html')