mirror of https://github.com/miaowware/qrm2.git
Merge pull request #126 from classabbyamp/all-embedded
fix commands that do not use embeds
This commit is contained in:
commit
5c95b9ff12
|
@ -37,11 +37,16 @@ class AE7QCog(commands.Cog):
|
||||||
callsign = callsign.upper()
|
callsign = callsign.upper()
|
||||||
desc = ''
|
desc = ''
|
||||||
base_url = "http://ae7q.com/query/data/CallHistory.php?CALL="
|
base_url = "http://ae7q.com/query/data/CallHistory.php?CALL="
|
||||||
|
embed = cmn.embed_factory(ctx)
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(base_url + callsign) as resp:
|
async with session.get(base_url + callsign) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
return await ctx.send('Could not load AE7Q')
|
embed.title = "Error in AE7Q call command"
|
||||||
|
embed.description = 'Could not load AE7Q'
|
||||||
|
embed.colour = cmn.colours.bad
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
return
|
||||||
page = await resp.text()
|
page = await resp.text()
|
||||||
|
|
||||||
soup = BeautifulSoup(page, features="html.parser")
|
soup = BeautifulSoup(page, features="html.parser")
|
||||||
|
@ -59,7 +64,6 @@ class AE7QCog(commands.Cog):
|
||||||
rows = None
|
rows = None
|
||||||
|
|
||||||
if rows is None:
|
if rows is None:
|
||||||
embed = cmn.embed_factory(ctx)
|
|
||||||
embed.title = f"AE7Q History for {callsign}"
|
embed.title = f"AE7Q History for {callsign}"
|
||||||
embed.colour = cmn.colours.bad
|
embed.colour = cmn.colours.bad
|
||||||
embed.url = f"{base_url}{callsign}"
|
embed.url = f"{base_url}{callsign}"
|
||||||
|
|
|
@ -62,6 +62,7 @@ class MorseCog(commands.Cog):
|
||||||
@commands.command(name="cwweight", aliases=["weight", 'cww'], category=cmn.cat.ref)
|
@commands.command(name="cwweight", aliases=["weight", 'cww'], category=cmn.cat.ref)
|
||||||
async def _weight(self, ctx: commands.Context, *, msg: str):
|
async def _weight(self, ctx: commands.Context, *, msg: str):
|
||||||
'''Calculates the CW Weight of a callsign or message.'''
|
'''Calculates the CW Weight of a callsign or message.'''
|
||||||
|
embed = cmn.embed_factory(ctx)
|
||||||
with ctx.typing():
|
with ctx.typing():
|
||||||
msg = msg.upper()
|
msg = msg.upper()
|
||||||
weight = 0
|
weight = 0
|
||||||
|
@ -70,13 +71,13 @@ class MorseCog(commands.Cog):
|
||||||
cw_char = self.ascii2morse[char].replace('-', '==')
|
cw_char = self.ascii2morse[char].replace('-', '==')
|
||||||
weight += len(cw_char) * 2 + 2
|
weight += len(cw_char) * 2 + 2
|
||||||
except KeyError:
|
except KeyError:
|
||||||
res = f'Unknown character {char} in callsign'
|
embed.title = 'Error in calculation of CW weight'
|
||||||
await ctx.send(res)
|
embed.description = f'Unknown character {char} in callsign'
|
||||||
|
embed.colour = cmn.colours.bad
|
||||||
|
await ctx.send(embed=embed)
|
||||||
return
|
return
|
||||||
res = f'The CW weight is **{weight}**'
|
|
||||||
embed = cmn.embed_factory(ctx)
|
|
||||||
embed.title = f'CW Weight of {msg}'
|
embed.title = f'CW Weight of {msg}'
|
||||||
embed.description = res
|
embed.description = f'The CW weight is **{weight}**'
|
||||||
embed.colour = cmn.colours.good
|
embed.colour = cmn.colours.good
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ class StudyCog(commands.Cog):
|
||||||
gen_pool = 'E3_2019'
|
gen_pool = 'E3_2019'
|
||||||
extra_pool = 'E4_2016'
|
extra_pool = 'E4_2016'
|
||||||
|
|
||||||
|
embed = cmn.embed_factory(ctx)
|
||||||
with ctx.typing():
|
with ctx.typing():
|
||||||
selected_pool = None
|
selected_pool = None
|
||||||
try:
|
try:
|
||||||
|
@ -49,15 +50,22 @@ class StudyCog(commands.Cog):
|
||||||
if (level is None) or (level == 'all'): # no pool given or user wants all, so pick a random pool
|
if (level is None) or (level == 'all'): # no pool given or user wants all, so pick a random pool
|
||||||
selected_pool = random.choice([tech_pool, gen_pool, extra_pool])
|
selected_pool = random.choice([tech_pool, gen_pool, extra_pool])
|
||||||
if (level is not None) and (selected_pool is None): # unrecognized pool given by user
|
if (level is not None) and (selected_pool is None): # unrecognized pool given by user
|
||||||
await ctx.send('The question pool you gave was unrecognized. ' +
|
embed.title = 'Error in HamStudy command'
|
||||||
'There are many ways to call up certain question pools - try ?rq t, g, or e. ' +
|
embed.description = ('The question pool you gave was unrecognized. '
|
||||||
'(Note that only the US question pools are available).')
|
'There are many ways to call up certain question pools - try ?rq t, g, or e. '
|
||||||
|
'\n\nNote that currently only the US question pools are available.')
|
||||||
|
embed.colour = cmn.colours.bad
|
||||||
|
await ctx.send(embed=embed)
|
||||||
return
|
return
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(f'https://hamstudy.org/pools/{selected_pool}') as resp:
|
async with session.get(f'https://hamstudy.org/pools/{selected_pool}') as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
return await ctx.send('Could not load questions...')
|
embed.title = 'Error in HamStudy command'
|
||||||
|
embed.description = 'Could not load questions'
|
||||||
|
embed.colour = cmn.colours.bad
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
return
|
||||||
pool = json.loads(await resp.read())['pool']
|
pool = json.loads(await resp.read())['pool']
|
||||||
|
|
||||||
# Select a question
|
# Select a question
|
||||||
|
@ -65,7 +73,6 @@ class StudyCog(commands.Cog):
|
||||||
pool_questions = random.choice(pool_section)['questions']
|
pool_questions = random.choice(pool_section)['questions']
|
||||||
question = random.choice(pool_questions)
|
question = random.choice(pool_questions)
|
||||||
|
|
||||||
embed = cmn.embed_factory(ctx)
|
|
||||||
embed.title = question['id']
|
embed.title = question['id']
|
||||||
embed.description = self.source
|
embed.description = self.source
|
||||||
embed.colour = cmn.colours.good
|
embed.colour = cmn.colours.good
|
||||||
|
|
Loading…
Reference in New Issue