Skip to content

Commit

Permalink
moving url to source field
Browse files Browse the repository at this point in the history
  • Loading branch information
tblanarik committed Sep 28, 2024
1 parent 5aa7e55 commit f013340
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 @@ -33,15 +33,15 @@ def create_content(req_body):
spot_deeplink = create_spot_deeplink(source, callsign, wwffRef)

# flags = 4 means it will suppress embeds: https://discord.com/developers/docs/resources/message#message-object-message-flags
content = {"content": f"{callsign} | {source} | freq: {frequency} | mode: {mode} | loc: {summitRef}{wwffRef} | {spot_deeplink}", "flags": 4}
content = {"content": f"{callsign} | {spot_deeplink} | freq: {frequency} | mode: {mode} | loc: {summitRef}{wwffRef}", "flags": 4}
return content

def create_spot_deeplink(source, callsign, wwffRef):
match source:
case "sotawatch":
return f"[See their latest spot](https://sotl.as/activators/{callsign})"
return f"[{source}](https://sotl.as/activators/{callsign})"
case "pota":
return f"[See their latest spot](https://api.pota.app/spot/comments/{callsign}/{wwffRef})"
return f"[{source}](https://api.pota.app/spot/comments/{callsign}/{wwffRef})"
case _:
return ""

Expand Down
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class TestSpotBot(unittest.TestCase):
def test_function_app_basic(self):
req_body = {"callsign":"KI7HSG", "source": "pota", "frequency": "14.074", "mode": "FT8", "wwffRef":"US-0052"}
content = spotbot.create_content(req_body)
expected = {'content': 'KI7HSG | pota | freq: 14.074 | mode: FT8 | loc: US-0052 | [See their latest spot](https://api.pota.app/spot/comments/KI7HSG/US-0052)', 'flags': 4}
expected = {'content': 'KI7HSG | [pota](https://api.pota.app/spot/comments/KI7HSG/US-0052) | freq: 14.074 | mode: FT8 | loc: US-0052', 'flags': 4}
self.assertDictEqual(content, expected)

def test_function_app(self):
req_body = {"callsign":"KI7HSG", "source": "sotawatch", "frequency": "14.074", "mode": "FT8", "summitRef": "ABCD"}
content = spotbot.create_content(req_body)
expected = {'content': 'KI7HSG | sotawatch | freq: 14.074 | mode: FT8 | loc: ABCD | [See their latest spot](https://sotl.as/activators/KI7HSG)', 'flags': 4}
expected = {'content': 'KI7HSG | [sotawatch](https://sotl.as/activators/KI7HSG) | freq: 14.074 | mode: FT8 | loc: ABCD', 'flags': 4}
self.assertDictEqual(content, expected)

if __name__ == '__main__':
Expand Down

0 comments on commit f013340

Please sign in to comment.