From ce62c93d03436db6fe61bca85a384374dea196fc Mon Sep 17 00:00:00 2001 From: 0x5c Date: Mon, 12 Apr 2021 10:00:11 -0400 Subject: [PATCH] Fixed ?call crash on empty adress fields Fixes #419 --- CHANGELOG.md | 2 ++ exts/callsign.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb7db6c..4c7ff3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added - Helpful LaTeX hints for rendering errors in `?tex`. +### Fixed +- Bug where `?call` would crash if the found profile only had empty address fields. ## [2.7.0] - 2021-04-03 diff --git a/exts/callsign.py b/exts/callsign.py index 76403f7..4328336 100644 --- a/exts/callsign.py +++ b/exts/callsign.py @@ -78,7 +78,7 @@ class QRZCog(commands.Cog): embed.set_thumbnail(url=data.image.url) for title, val in qrz_process_info(data).items(): - if val is not None: + if val: embed.add_field(name=title, value=val, inline=True) await ctx.send(embed=embed) @@ -99,7 +99,11 @@ def qrz_process_info(data: qrztools.QrzCallsignData) -> Dict: if data.address != qrztools.Address(): state = ", " + data.address.state + " " if data.address.state else "" - address = "\n".join([data.address.attn, data.address.line1, data.address.line2 + state, data.address.zip]) + address = "\n".join( + [x for x + in [data.address.attn, data.address.line1, data.address.line2 + state, data.address.zip] + if x] + ) else: address = None