Skip to content

Commit

Permalink
adds secret endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tblanarik committed Nov 11, 2024
1 parent 42c7217 commit 1d30aa8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Description

Spotbot is an Azure Function App to convert [HamAlert](https://hamalert.org/) alerts from [POTA](https://pota.app) or [SOTA](https://www.sota.org.uk/) in to a message format that can be forwarded on to a Discord channel webhook.
Spotbot is an application to convert [HamAlert](https://hamalert.org/) alerts from [POTA](https://pota.app) or [SOTA](https://www.sota.org.uk/) in to a message format that can be forwarded on to a Discord channel webhook.

| HamAlert Configuration |
| -- |
Expand All @@ -19,15 +19,17 @@ You can find a live, working version of this bot in the [Cascadia Radio](https:/

## Config

The Azure Function App expects three environment variables:
The app expects four environment variables:
- `TARGET_URL` - the webhook URL from the target Discord channel.
- `LOOKBACK_SECONDS` - the number of seconds to look backwards for previous messages to update instead of posting a new one
- `TABLE_NAME` - the name of the table in the Azure Storage Account where the last messageIds will be stored for each callsign
- `AzureWebJobsStorage` - the full connection string to the Azure Storage Account
- `SECRET_ENDPOINT` - the name of the endpoint, kept secret to prevent abuse / unwanted messages

## Deploy Notes

- Some basic tests run in `tests.py` on the creation of a new PR
- To deploy, manually run `main_hamalertspotbot.yml`
- To deploy, manually run `deploy-docker.yml`
- This will deploy to the staging slot for testing.
- The staging `TARGET_URL` points to my private Discord server
- `LOOKBACK_SECONDS` is set to only 300 (instead of 7200) for easier testing.
4 changes: 3 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
from flask import Flask, request, make_response
import logging
import spotbot as sb
import tables
import discord_http
app = Flask(__name__)
endpoint = os.environ.get('SECRET_ENDPOINT')

@app.route(f'/message', methods=["POST"])
@app.route(f'/{endpoint}', methods=["POST"])
def run():
try:
sb.SpotBot(request, tables.HamAlertTable(), discord_http.DiscordHttp()).process()
Expand Down

0 comments on commit 1d30aa8

Please sign in to comment.