Merge pull request #205 from miaowware/fix-typing

Added/fixed/removed typing managers
This commit is contained in:
0x5c 2020-02-25 20:57:07 -05:00 committed by GitHub
commit f6ed8430b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 216 additions and 224 deletions

View File

@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
### Fixed ### Fixed
- Fixed issue where HamStudy questions with images would cause an error. - Fixed issue where HamStudy questions with images would cause an error.
- Added/fixed/removed typing indicators in numerous commands.
## [2.2.1] - 2020-02-20 ## [2.2.1] - 2020-02-20

View File

@ -39,7 +39,6 @@ class FunCog(commands.Cog):
@commands.command(name="funetics", aliases=["fun"], category=cmn.cat.fun) @commands.command(name="funetics", aliases=["fun"], category=cmn.cat.fun)
async def _funetics_lookup(self, ctx: commands.Context, *, msg: str): async def _funetics_lookup(self, ctx: commands.Context, *, msg: str):
"""Generates fun/wacky phonetics for a word or phrase.""" """Generates fun/wacky phonetics for a word or phrase."""
with ctx.typing():
result = "" result = ""
for char in msg.lower(): for char in msg.lower():
if char.isalpha(): if char.isalpha():

View File

@ -23,7 +23,6 @@ class GridCog(commands.Cog):
async def _grid_sq_lookup(self, ctx: commands.Context, lat: str, lon: str): async def _grid_sq_lookup(self, ctx: commands.Context, lat: str, lon: str):
("""Calculates the grid square for latitude and longitude coordinates, """ ("""Calculates the grid square for latitude and longitude coordinates, """
"""with negative being latitude South and longitude West.""") """with negative being latitude South and longitude West.""")
with ctx.typing():
grid = "**" grid = "**"
latf = float(lat) + 90 latf = float(lat) + 90
lonf = float(lon) + 180 lonf = float(lon) + 180
@ -53,7 +52,6 @@ class GridCog(commands.Cog):
async def _location_lookup(self, ctx: commands.Context, grid: str, grid2: str = None): async def _location_lookup(self, ctx: commands.Context, grid: str, grid2: str = None):
"""Calculates the latitude and longitude for the center of a grid square. """Calculates the latitude and longitude for the center of a grid square.
If two grid squares are given, the distance and azimuth between them is calculated.""" If two grid squares are given, the distance and azimuth between them is calculated."""
with ctx.typing():
if grid2 is None or grid2 == "": if grid2 is None or grid2 == "":
try: try:
grid = grid.upper() grid = grid.upper()

View File

@ -25,7 +25,6 @@ class HamCog(commands.Cog):
@commands.command(name="qcode", aliases=["q"], category=cmn.cat.ref) @commands.command(name="qcode", aliases=["q"], category=cmn.cat.ref)
async def _qcode_lookup(self, ctx: commands.Context, qcode: str): async def _qcode_lookup(self, ctx: commands.Context, qcode: str):
"""Looks up the meaning of a Q Code.""" """Looks up the meaning of a Q Code."""
with ctx.typing():
qcode = qcode.upper() qcode = qcode.upper()
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
if qcode in qcodes.qcodes: if qcode in qcodes.qcodes:
@ -40,7 +39,6 @@ class HamCog(commands.Cog):
@commands.command(name="phonetics", aliases=["ph", "phoneticize", "phoneticise", "phone"], category=cmn.cat.ref) @commands.command(name="phonetics", aliases=["ph", "phoneticize", "phoneticise", "phone"], category=cmn.cat.ref)
async def _phonetics_lookup(self, ctx: commands.Context, *, msg: str): async def _phonetics_lookup(self, ctx: commands.Context, *, msg: str):
"""Returns NATO phonetics for a word or phrase.""" """Returns NATO phonetics for a word or phrase."""
with ctx.typing():
result = "" result = ""
for char in msg.lower(): for char in msg.lower():
if char.isalpha(): if char.isalpha():
@ -57,7 +55,6 @@ class HamCog(commands.Cog):
@commands.command(name="utc", aliases=["z"], category=cmn.cat.ref) @commands.command(name="utc", aliases=["z"], category=cmn.cat.ref)
async def _utc_lookup(self, ctx: commands.Context): async def _utc_lookup(self, ctx: commands.Context):
"""Returns the current time in UTC.""" """Returns the current time in UTC."""
with ctx.typing():
now = datetime.utcnow() now = datetime.utcnow()
result = "**" + now.strftime("%Y-%m-%d %H:%M") + "Z**" result = "**" + now.strftime("%Y-%m-%d %H:%M") + "Z**"
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)

View File

@ -40,7 +40,6 @@ class LookupCog(commands.Cog):
@commands.command(name="dxcc", aliases=["dx"], category=cmn.cat.lookup) @commands.command(name="dxcc", aliases=["dx"], category=cmn.cat.lookup)
async def _dxcc_lookup(self, ctx: commands.Context, query: str): async def _dxcc_lookup(self, ctx: commands.Context, query: str):
"""Gets DXCC info about a callsign prefix.""" """Gets DXCC info about a callsign prefix."""
with ctx.typing():
query = query.upper() query = query.upper()
full_query = query full_query = query
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)

View File

@ -21,7 +21,6 @@ class MorseCog(commands.Cog):
@commands.command(name="morse", aliases=["cw"], category=cmn.cat.ref) @commands.command(name="morse", aliases=["cw"], category=cmn.cat.ref)
async def _morse(self, ctx: commands.Context, *, msg: str): async def _morse(self, ctx: commands.Context, *, msg: str):
"""Converts ASCII to international morse code.""" """Converts ASCII to international morse code."""
with ctx.typing():
result = "" result = ""
for char in msg.upper(): for char in msg.upper():
try: try:
@ -38,7 +37,6 @@ class MorseCog(commands.Cog):
@commands.command(name="unmorse", aliases=["demorse", "uncw", "decw"], category=cmn.cat.ref) @commands.command(name="unmorse", aliases=["demorse", "uncw", "decw"], category=cmn.cat.ref)
async def _unmorse(self, ctx: commands.Context, *, msg: str): async def _unmorse(self, ctx: commands.Context, *, msg: str):
"""Converts international morse code to ASCII.""" """Converts international morse code to ASCII."""
with ctx.typing():
result = "" result = ""
msg0 = msg msg0 = msg
msg = msg.split("/") msg = msg.split("/")
@ -60,7 +58,6 @@ class MorseCog(commands.Cog):
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) embed = cmn.embed_factory(ctx)
with ctx.typing():
msg = msg.upper() msg = msg.upper()
weight = 0 weight = 0
for char in msg: for char in msg:

View File

@ -36,6 +36,7 @@ class QRZCog(commands.Cog):
await ctx.send(f"http://qrz.com/db/{callsign}") await ctx.send(f"http://qrz.com/db/{callsign}")
return return
async with ctx.typing():
try: try:
await qrz_test_session(self.key, self.session) await qrz_test_session(self.key, self.session)
except ConnectionError: except ConnectionError: