From 9b70445c80efefd905b539376a1f057368fc04ae Mon Sep 17 00:00:00 2001 From: missytake Date: Mon, 9 Oct 2023 17:03:23 +0200 Subject: [PATCH] feat: handle group name and avatar changes in outside groups. closes #3 --- src/teams_bot/bot.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/teams_bot/bot.py b/src/teams_bot/bot.py index d0ccffe..782ad37 100644 --- a/src/teams_bot/bot.py +++ b/src/teams_bot/bot.py @@ -48,8 +48,21 @@ class RelayPlugin: ) if message.is_system_message(): - logging.debug("This is a system message") - """:TODO handle chat name changes""" + if message.chat.id == self.crew.id: + return + if self.is_relay_group(message.chat): + logging.debug("This is a system message in a relay group.") + else: + logging.debug("This is a system message in an outside group.") + relay_group = self.get_relay_group(message.chat.id) + if 'image changed by' in message.text: + relay_group.set_profile_image(message.chat.get_profile_image()) + if 'name changed from' in message.text: + group_name = "[%s] %s" % ( + self.account.get_config("addr").split("@")[0], + message.chat.get_name(), + ) + relay_group.set_name(group_name) return if message.chat.id == self.crew.id: @@ -137,7 +150,8 @@ class RelayPlugin: relay_group = self.account.create_group_chat( group_name, crew_members, verified=False ) - # relay_group.set_profile_image("assets/avatar.jpg") + if message.chat.get_profile_image(): + relay_group.set_profile_image(message.chat.get_profile_image()) if started_by_crew: explanation = f"We started a chat with {message.chat.get_name()}. This was our first message:" else: