Skip to content

Commit

Permalink
reformat and strikethrough old messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tblanarik committed Oct 19, 2024
1 parent 00a778c commit effdde9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions spotbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down

0 comments on commit effdde9

Please sign in to comment.