Technical-13 / Signal

Signal is the bot for the Geocaching Discord server.
https://discord.me/Geocaching
GNU Affero General Public License v3.0
2 stars 1 forks source link

Pretty formatted links to GC codes #4

Open bwjmackie opened 1 month ago

bwjmackie commented 1 month ago

Describe the solution you'd like A new command (eg: /gc) that will create pretty-formatted links to geocaches. The command would have one required parameter (GC Code) and three optional parameters (SolvedCoords^1, SolutionDetails^2 and TargetChannel^3). For all GC codes, the bot would look up details (how? TBD^4) such as title, type, owner, D/T, container size, country, region, posted coords) and post them to the current channel in the following manner:

TypeIcon GCCode Title by OwnerName <- link is bolded, not owner D/T rating, Container size, CountryFlag Country, Region Posted Coords

If Solved Coords are provided, then Posted Coords would be omitted, the Corrected Coordinates icon would be added after the Type icon, and Solved Coords would be included as a spoiler tag like this:

Coords: ||Solved Coords||

If Solution Details are provided, then they would be appended as follows:

Solution: ||Solution Details||

Solved Coords and/or Solution Details would be ignored/discarded for any cache types where they are not applicable: All types of events, GCHQ, Traditionals, Earthcaches, Virtuals, Locationless, Adventure Labs, GPS Maze, Webcam, APE.

If Target Channel is provided, subject to sufficient permissions, the output can be redirected to any valid channel on the server. Default if not provided, or if insufficient permissions, is the current channel.

  1. Try to accept any common coordinate format and attempt to parse and convert to the usual DDM (N 00° 00.000' W 00° 00.000') format. Throw an error if unable to parse or if coords are invalid.
  2. This may be multiple lines of text.
  3. Staff-only. Ignore if insufficient permissions.
  4. Maybe API, maybe website scraping... Up to the developer!

Describe alternatives you've considered Manually gathering details and formatting them nicely.

Additional context Apparently @Brain on Discord created an app that does something similar. Perhaps he has some reusable code to get you started.

bwjmackie commented 1 month ago

Two examples. image Commands used:

  1. /gc [GCAVG88]
  2. /gc [GC8F18N] [N 51° 30.635 W 000° 06.879] [Use your IP address for ABC.DEF.GHI.JKL with the formula displayed. Lock code (2920) provided in geochecker again referencing your IP.] For the second one, the Corrected Coordinates icon is used following the Type icon since the SolvedCoords parameter was provided. I also fudged a different country/region for illustrative purposes.
Technical-13 commented 1 month ago

This would require access to the Groundspeak API of which they've historically been unwilling to grant access to. I did read someplace the API is at least open again after being closed for many years. I've been intending to look more into it, but I don't have the amount of free time required to do that at this stage in my life. If someone wanted to fork this code and do a pull request, I'd be happy to test it out and merge it to be accessible.