diff --git a/spotbot.py b/spotbot.py index b800182..41c7b02 100644 --- a/spotbot.py +++ b/spotbot.py @@ -24,8 +24,8 @@ def run(req): if is_entity_recent(entity): messageId = entity['MessageId'] - existingMessage = get_previous_message(messageId) - content = existingMessage + "\n" + content + existingMessage = get_previous_message(messageId).replace("~", "") + content = "~~" + existingMessage + "~~\n" + content # flags = 4 means it will suppress embeds: https://discord.com/developers/docs/resources/message#message-object-message-flags content_payload = {"content":content, "flags": 4} @@ -44,7 +44,7 @@ def create_content(req_body, dd): spot_deeplink = create_spot_deeplink(source, callsign, wwffRef) formatted_time = dd.strftime("%H:%M") - content = f"{callsign} | {spot_deeplink} | freq: {frequency} | mode: {mode} | loc: {summitRef}{wwffRef} | {formatted_time}" + content = f"{formatted_time} | {callsign} | {spot_deeplink} | freq: {frequency} | mode: {mode} | loc: {summitRef}{wwffRef}" return content def create_spot_deeplink(source, callsign, wwffRef): diff --git a/test.py b/test.py index 52e5fc4..51348e1 100644 --- a/test.py +++ b/test.py @@ -9,14 +9,14 @@ def test_function_app_basic(self): dd = datetime.strptime("2024-10-13T01:05:03", "%Y-%m-%dT%H:%M:%S") req_body = {"callsign":"KI7HSG", "source": "pota", "frequency": "14.074", "mode": "FT8", "wwffRef":"US-0052"} content = spotbot.create_content(req_body, dd) - expected = 'KI7HSG | [pota](https://api.pota.app/spot/comments/KI7HSG/US-0052) | freq: 14.074 | mode: FT8 | loc: US-0052 | 01:05' + expected = '01:05 | KI7HSG | [pota](https://api.pota.app/spot/comments/KI7HSG/US-0052) | freq: 14.074 | mode: FT8 | loc: US-0052' self.assertEqual(content, expected) def test_function_app(self): dd = datetime.strptime("2024-10-13T01:05:03", "%Y-%m-%dT%H:%M:%S") req_body = {"callsign":"KI7HSG", "source": "sotawatch", "frequency": "14.074", "mode": "FT8", "summitRef": "ABCD"} content = spotbot.create_content(req_body, dd) - expected = 'KI7HSG | [sotawatch](https://sotl.as/activators/KI7HSG) | freq: 14.074 | mode: FT8 | loc: ABCD | 01:05' + expected = '01:05 | KI7HSG | [sotawatch](https://sotl.as/activators/KI7HSG) | freq: 14.074 | mode: FT8 | loc: ABCD' self.assertEqual(content, expected) if __name__ == '__main__':