Merge pull request #335 from miaowware/glts

Fixed ?greyline caching (set date url param)
This commit is contained in:
0x5c 2021-01-18 01:12:12 -05:00 committed by GitHub
commit 31a4fca70e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Moved great circle distance and bearing calculation from `?ungrid` to `?griddistance`.
- `?ungrid` to `?latlong`.
- Renamed `?cond` to `?solar`.
### Fixed
- Weird image caching situation for `?greyline` on Discord's side.
### Deprecated
- `?ungrid`.
- Deprecated old `?solar` aliases (`?cond`, etc).

View File

@ -9,6 +9,7 @@ the GNU General Public License, version 2.
import aiohttp
from datetime import datetime
import discord
import discord.ext.commands as commands
@ -17,7 +18,7 @@ import common as cmn
class ImageCog(commands.Cog):
gl_url = "https://www.fourmilab.ch/cgi-bin/uncgi/Earth?img=ETOPO1_day-m.evif&dynimg=y&opt=-p"
gl_baseurl = "https://www.fourmilab.ch/cgi-bin/uncgi/Earth?img=ETOPO1_day-m.evif&dynimg=y&opt=-p"
def __init__(self, bot: commands.Bot):
self.bot = bot
@ -85,9 +86,8 @@ class ImageCog(commands.Cog):
embed = cmn.embed_factory(ctx)
embed.title = "Current Greyline Conditions"
embed.colour = cmn.colours.good
# Generate a nonce to force discord to recache this
cachenonce = (ctx.message.id >> 22) // 1000 // 600 # nonce will stay the same for ~10min
embed.set_image(url=self.gl_url + f"&cachenonce={cachenonce}")
date_params = f"&date=1&utc={datetime.utcnow():%Y-%m-%d+%H:%M:%S}"
embed.set_image(url=self.gl_baseurl + date_params)
await ctx.send(embed=embed)