mirror of
https://github.com/miaowware/qrm2.git
synced 2025-09-02 13:17:47 -04:00
parent
02192a7ea9
commit
4368e0b603
@ -141,8 +141,7 @@ class BaseCog(commands.Cog):
|
|||||||
@commands.command(name="echo", aliases=["e"], hidden=True)
|
@commands.command(name="echo", aliases=["e"], hidden=True)
|
||||||
@commands.check(cmn.check_if_owner)
|
@commands.check(cmn.check_if_owner)
|
||||||
async def _echo(self, ctx: commands.Context, channel: commands.TextChannelConverter, *, msg: str):
|
async def _echo(self, ctx: commands.Context, channel: commands.TextChannelConverter, *, msg: str):
|
||||||
"""Send a message in a channel as qrm. Only works within a server or DM to server,
|
"""Send a message in a channel as qrm. Only works within a server or DM to server, not between servers."""
|
||||||
not between servers."""
|
|
||||||
await channel.send(msg)
|
await channel.send(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,14 +48,10 @@ class LookupCog(commands.Cog):
|
|||||||
while query:
|
while query:
|
||||||
if query in self.cty.keys():
|
if query in self.cty.keys():
|
||||||
data = self.cty[query]
|
data = self.cty[query]
|
||||||
embed.add_field(name="Entity",
|
embed.add_field(name="Entity", value=data['entity'])\
|
||||||
value=data['entity'])\
|
.add_field(name="CQ Zone", value=data['cq'])\
|
||||||
.add_field(name="CQ Zone",
|
.add_field(name="ITU Zone", value=data['itu'])\
|
||||||
value=data['cq'])\
|
.add_field(name="Continent", value=data['continent'])\
|
||||||
.add_field(name="ITU Zone",
|
|
||||||
value=data['itu'])\
|
|
||||||
.add_field(name="Continent",
|
|
||||||
value=data['continent'])\
|
|
||||||
.add_field(name="Time Zone",
|
.add_field(name="Time Zone",
|
||||||
value=f'+{data["tz"]}' if data['tz'] > 0 else str(data['tz']))
|
value=f'+{data["tz"]}' if data['tz'] > 0 else str(data['tz']))
|
||||||
embed.title += query
|
embed.title += query
|
||||||
|
15
exts/qrz.py
15
exts/qrz.py
@ -42,8 +42,7 @@ class QRZCog(commands.Cog):
|
|||||||
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
||||||
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
||||||
|
|
||||||
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session',
|
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
||||||
namespaces={'x': 'http://xmldata.qrz.com'})
|
|
||||||
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
||||||
if 'Error' in resp_session:
|
if 'Error' in resp_session:
|
||||||
if 'Session Timeout' in resp_session['Error']:
|
if 'Session Timeout' in resp_session['Error']:
|
||||||
@ -59,8 +58,7 @@ class QRZCog(commands.Cog):
|
|||||||
return
|
return
|
||||||
raise ValueError(resp_session['Error'])
|
raise ValueError(resp_session['Error'])
|
||||||
|
|
||||||
resp_xml_data = resp_xml.xpath('/x:QRZDatabase/x:Callsign',
|
resp_xml_data = resp_xml.xpath('/x:QRZDatabase/x:Callsign', namespaces={'x': 'http://xmldata.qrz.com'})
|
||||||
namespaces={'x': 'http://xmldata.qrz.com'})
|
|
||||||
resp_data = {el.tag.split('}')[1]: el.text for el in resp_xml_data[0].getiterator()}
|
resp_data = {el.tag.split('}')[1]: el.text for el in resp_xml_data[0].getiterator()}
|
||||||
|
|
||||||
embed = cmn.embed_factory(ctx)
|
embed = cmn.embed_factory(ctx)
|
||||||
@ -101,8 +99,7 @@ async def qrz_login(user: str, passwd: str, session: aiohttp.ClientSession):
|
|||||||
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
||||||
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
||||||
|
|
||||||
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session',
|
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
||||||
namespaces={'x': 'http://xmldata.qrz.com'})
|
|
||||||
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
||||||
if 'Error' in resp_session:
|
if 'Error' in resp_session:
|
||||||
raise ConnectionError(resp_session['Error'])
|
raise ConnectionError(resp_session['Error'])
|
||||||
@ -118,8 +115,7 @@ async def qrz_test_session(key: str, session: aiohttp.ClientSession):
|
|||||||
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
||||||
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
||||||
|
|
||||||
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session',
|
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
||||||
namespaces={'x': 'http://xmldata.qrz.com'})
|
|
||||||
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
||||||
if 'Error' in resp_session:
|
if 'Error' in resp_session:
|
||||||
raise ConnectionError(resp_session['Error'])
|
raise ConnectionError(resp_session['Error'])
|
||||||
@ -174,8 +170,7 @@ def qrz_process_info(data: dict):
|
|||||||
('CQ Zone', data.get('cqzone', None)),
|
('CQ Zone', data.get('cqzone', None)),
|
||||||
('ITU Zone', data.get('ituzone', None)),
|
('ITU Zone', data.get('ituzone', None)),
|
||||||
('IOTA Designator', data.get('iota', None)),
|
('IOTA Designator', data.get('iota', None)),
|
||||||
('Born', data.get('born', None)),
|
('Born', data.get('born', None))])
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
@ -78,8 +78,7 @@ class StudyCog(commands.Cog):
|
|||||||
embed.add_field(name='Answers:', value='**A:** ' + question['answers']['A'] +
|
embed.add_field(name='Answers:', value='**A:** ' + question['answers']['A'] +
|
||||||
'\n**B:** ' + question['answers']['B'] +
|
'\n**B:** ' + question['answers']['B'] +
|
||||||
'\n**C:** ' + question['answers']['C'] +
|
'\n**C:** ' + question['answers']['C'] +
|
||||||
'\n**D:** ' + question['answers']['D'],
|
'\n**D:** ' + question['answers']['D'], inline=False)
|
||||||
inline=False)
|
|
||||||
embed.add_field(name='Answer:', value='Type _?rqa_ for answer', inline=False)
|
embed.add_field(name='Answer:', value='Type _?rqa_ for answer', inline=False)
|
||||||
if 'image' in question:
|
if 'image' in question:
|
||||||
image_url = f'https://hamstudy.org/_1330011/images/{selected_pool.split("_",1)[1]}/{question["image"]}'
|
image_url = f'https://hamstudy.org/_1330011/images/{selected_pool.split("_",1)[1]}/{question["image"]}'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user