mirror of
https://github.com/miaowware/qrm2.git
synced 2024-10-31 14:27:11 -04:00
parent
b091b22c17
commit
6dfc05217f
@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
### Added
|
### Added
|
||||||
- MUF and foF2 maps from [prop.kc2g.com](https://prop.kc2g.com/).
|
- MUF and foF2 maps from [prop.kc2g.com](https://prop.kc2g.com/).
|
||||||
- Commands to show METAR (`?metar`) and TAF (`?taf`) (aeronautical weather conditions).
|
- Commands to show METAR (`?metar`) and TAF (`?taf`) (aeronautical weather conditions).
|
||||||
|
- The ability to select an element of a pool in `?hamstudy`.
|
||||||
### Changed
|
### Changed
|
||||||
- New colour theme for `?greyline`.
|
- New colour theme for `?greyline`.
|
||||||
- Moved great circle distance and bearing calculation from `?ungrid` to `?griddistance`.
|
- Moved great circle distance and bearing calculation from `?ungrid` to `?griddistance`.
|
||||||
|
@ -31,13 +31,14 @@ class StudyCog(commands.Cog):
|
|||||||
self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
|
self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
|
||||||
|
|
||||||
@commands.command(name="hamstudy", aliases=["rq", "randomquestion", "randomq"], category=cmn.cat.study)
|
@commands.command(name="hamstudy", aliases=["rq", "randomquestion", "randomq"], category=cmn.cat.study)
|
||||||
async def _random_question(self, ctx: commands.Context, country: str = "", level: str = ""):
|
async def _random_question(self, ctx: commands.Context, country: str = "", level: str = "", element: str = ""):
|
||||||
"""Gets a random question from [HamStudy's](https://hamstudy.org) question pools."""
|
"""Gets a random question from [HamStudy's](https://hamstudy.org) question pools."""
|
||||||
with ctx.typing():
|
with ctx.typing():
|
||||||
embed = cmn.embed_factory(ctx)
|
embed = cmn.embed_factory(ctx)
|
||||||
|
|
||||||
country = country.lower()
|
country = country.lower()
|
||||||
level = level.lower()
|
level = level.lower()
|
||||||
|
element = element.upper()
|
||||||
|
|
||||||
if country in study.pool_names.keys():
|
if country in study.pool_names.keys():
|
||||||
if level in study.pool_names[country].keys():
|
if level in study.pool_names[country].keys():
|
||||||
@ -115,7 +116,19 @@ class StudyCog(commands.Cog):
|
|||||||
pool = json.loads(await resp.read())["pool"]
|
pool = json.loads(await resp.read())["pool"]
|
||||||
|
|
||||||
# Select a question
|
# Select a question
|
||||||
pool_section = random.choice(pool)["sections"]
|
if element:
|
||||||
|
els = [el["id"] for el in pool]
|
||||||
|
if element in els:
|
||||||
|
pool_section = pool[els.index(element)]["sections"]
|
||||||
|
else:
|
||||||
|
embed.title = "Element Not Found!"
|
||||||
|
embed.description = f"Possible Elements for Country `{country}` and Level `{level}` are:"
|
||||||
|
embed.colour = cmn.colours.bad
|
||||||
|
embed.description += "\n\n" + "`" + "`, `".join(els) + "`"
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
pool_section = random.choice(pool)["sections"]
|
||||||
pool_questions = random.choice(pool_section)["questions"]
|
pool_questions = random.choice(pool_section)["questions"]
|
||||||
question = random.choice(pool_questions)
|
question = random.choice(pool_questions)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user