Merge pull request #251 from FafnerKeyZee/patch-2

Update abstract_chat_object.py
This commit is contained in:
Thirion Aurélien 2024-12-23 23:28:43 +01:00 committed by GitHub
commit e19595daa7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -228,11 +228,14 @@ class AbstractChatObject(AbstractSubtypeObject, ABC):
return stats return stats
def get_message_years(self): def get_message_years(self):
try:
timestamp = datetime.utcfromtimestamp(float(self.get_timestamp_first_message())) timestamp = datetime.utcfromtimestamp(float(self.get_timestamp_first_message()))
year_start = int(timestamp.strftime('%Y')) year_start = int(timestamp.strftime('%Y'))
timestamp = datetime.utcfromtimestamp(float(self.get_timestamp_last_message())) timestamp = datetime.utcfromtimestamp(float(self.get_timestamp_last_message()))
year_end = int(timestamp.strftime('%Y')) year_end = int(timestamp.strftime('%Y'))
return list(range(year_start, year_end + 1)) return list(range(year_start, year_end + 1))
except:
return []
def get_nb_year_messages(self, year): def get_nb_year_messages(self, year):
nb_year = {} nb_year = {}