Added and switched to the Resource Manager

- Added Resource Manager
- Migrated most exts to it
- Added config entry for the resources URL
- Added my ID to template
- Bumped copyright on edited files

Fixes #246
This commit is contained in:
0x5c 2021-03-18 09:17:30 -04:00
parent 54960e8237
commit 0241d1856a
No known key found for this signature in database
GPG Key ID: A57F71C3176B9581
39 changed files with 302 additions and 1856 deletions

View File

@ -11,3 +11,5 @@ docker-compose.yml
Makefile
README*.md
/resource_schemas.py

View File

@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Reduced `?hamstudy` timeout to 5 minutes.
- Library used for QRZ lookups.
- Python>=3.9 now required.
- Most resources are now stored on a website. New indexes are pulled at start and the images linked instead of uploaded.
### Fixed
- Weird image caching situation for `?greyline` on Discord's side.
- The help command was not using the prefix it was invoked with.

View File

@ -1,7 +1,7 @@
"""
Common tools for the bot.
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
Copyright (C) 2019-2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
@ -67,10 +67,7 @@ emojis = SimpleNamespace(
paths = SimpleNamespace(
data=Path("./data/"),
resources=Path("./resources/"),
img=Path("./resources/img/"),
bandcharts=Path("./resources/img/bandcharts/"),
maps=Path("./resources/img/maps/"),
resources=Path("./data/resources/"),
)

View File

@ -0,0 +1,52 @@
{
"title": "Index",
"type": "object",
"properties": {
"last_updated": {
"title": "Last Updated",
"type": "string",
"format": "date-time"
},
"resources": {
"title": "Resources",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Resource"
}
}
},
"required": [
"last_updated",
"resources"
],
"definitions": {
"File": {
"title": "File",
"type": "object",
"properties": {
"filename": {
"title": "Filename",
"type": "string"
},
"hash": {
"title": "Hash",
"type": "string"
}
},
"required": [
"filename",
"hash"
]
},
"Resource": {
"title": "Resource",
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/definitions/File"
}
}
}
}
}

View File

@ -0,0 +1,18 @@
from pathlib import Path
from utils.resources_manager import ResourcesManager
path = Path("./data/resources")
url = "https://qrmresources.miaow.io/resources/"
versions = {
"bandcharts": "v1",
"img": "v1",
"maps": "v1",
"morse": "v1",
"phonetics": "v1",
"qcodes": "v1",
"funetics": "v1"
}
rm = ResourcesManager(path, url, versions)
print(rm.index)

View File

@ -1,25 +1,29 @@
"""
Fun extension for qrm
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
Copyright (C) 2019-2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
"""
import json
import random
import discord
import discord.ext.commands as commands
import common as cmn
import data.options as opt
class FunCog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
with open(cmn.paths.resources / "words") as words_file:
with open(cmn.paths.resources / "imgs.1.json") as file:
self.imgs: dict = json.load(file)
with open(cmn.paths.resources / "words.1.txt") as words_file:
self.words = words_file.read().lower().splitlines()
@commands.command(name="xkcd", aliases=["x"], category=cmn.cat.fun)
@ -40,12 +44,10 @@ class FunCog(commands.Cog):
@commands.command(name="worksplit", aliases=["split", "ft8"], category=cmn.cat.fun)
async def _worksplit(self, ctx: commands.Context):
"""Posts "Work split you lids"."""
fn = "worksplit.jpg"
embed = cmn.embed_factory(ctx)
embed.title = "Work Split, You Lids!"
embed.set_image(url="attachment://" + fn)
img = discord.File(cmn.paths.img / fn, filename=fn)
await ctx.send(embed=embed, file=img)
embed.set_image(url=opt.resources_url + self.imgs["worksplit"])
await ctx.send(embed=embed)
@commands.command(name="xd", hidden=True, category=cmn.cat.fun)
async def _xd(self, ctx: commands.Context):

View File

@ -1,36 +1,41 @@
"""
Ham extension for qrm
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
Copyright (C) 2019-2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
"""
import json
from datetime import datetime
import discord.ext.commands as commands
import common as cmn
from resources import callsign_info
from resources import phonetics
from resources import qcodes
class HamCog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
self.pfxs = callsign_info.options
with open(cmn.paths.resources / "phonetics.1.json") as file:
d = json.load(file)
self.phonetics: dict[str, str] = d["phonetics"]
self.pweights: dict[str, int] = d["pweights"]
with open(cmn.paths.resources / "qcodes.1.json") as file:
self.qcodes: dict = json.load(file)
@commands.command(name="qcode", aliases=["q"], category=cmn.cat.ref)
async def _qcode_lookup(self, ctx: commands.Context, qcode: str):
"""Looks up the meaning of a Q Code."""
qcode = qcode.upper()
embed = cmn.embed_factory(ctx)
if qcode in qcodes.qcodes:
if qcode in self.qcodes:
embed.title = qcode
embed.description = qcodes.qcodes[qcode]
embed.description = self.qcodes[qcode]
embed.colour = cmn.colours.good
else:
embed.title = f"Q Code {qcode} not found"
@ -43,7 +48,7 @@ class HamCog(commands.Cog):
result = ""
for char in msg.lower():
if char.isalpha():
result += phonetics.phonetics[char]
result += self.phonetics[char]
else:
result += char
result += " "
@ -105,7 +110,7 @@ class HamCog(commands.Cog):
weight = 0
for char in msg:
try:
weight += phonetics.pweights[char]
weight += self.pweights[char]
except KeyError:
embed.title = "Error in calculation of phonetic weight"
embed.description = f"Unknown character `{char}` in message"

View File

@ -1,7 +1,7 @@
"""
Image extension for qrm
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
Copyright (C) 2019-2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
@ -11,19 +11,20 @@ the GNU General Public License, version 2.
import aiohttp
from datetime import datetime
import discord
import discord.ext.commands as commands
import common as cmn
import data.options as opt
class ImageCog(commands.Cog):
gl_baseurl = "https://www.fourmilab.ch/cgi-bin/uncgi/Earth?img=ETOPO1_day-m.evif&dynimg=y&opt=-p"
def __init__(self, bot: commands.Bot):
self.bot = bot
self.bandcharts = cmn.ImagesGroup(cmn.paths.bandcharts / "meta.json")
self.maps = cmn.ImagesGroup(cmn.paths.maps / "meta.json")
self.bandcharts = cmn.ImagesGroup(cmn.paths.resources / "bandcharts.1.json")
self.maps = cmn.ImagesGroup(cmn.paths.resources / "maps.1.json")
self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.command(name="bandplan", aliases=["plan", "bands"], category=cmn.cat.ref)
@ -42,16 +43,14 @@ class ImageCog(commands.Cog):
await ctx.send(embed=embed)
return
metadata: cmn.ImageMetadata = self.bandcharts[arg]
img = discord.File(cmn.paths.bandcharts / metadata.filename,
filename=metadata.filename)
if metadata.description:
embed.description = metadata.description
if metadata.source:
embed.add_field(name="Source", value=metadata.source)
embed.title = metadata.long_name + (" " + metadata.emoji if metadata.emoji else "")
embed.colour = cmn.colours.good
embed.set_image(url="attachment://" + metadata.filename)
await ctx.send(embed=embed, file=img)
embed.set_image(url=opt.resources_url + metadata.filename)
await ctx.send(embed=embed)
@commands.command(name="map", category=cmn.cat.maps)
async def _map(self, ctx: commands.Context, map_id: str = ""):
@ -69,16 +68,14 @@ class ImageCog(commands.Cog):
await ctx.send(embed=embed)
return
metadata: cmn.ImageMetadata = self.maps[arg]
img = discord.File(cmn.paths.maps / metadata.filename,
filename=metadata.filename)
if metadata.description:
embed.description = metadata.description
if metadata.source:
embed.add_field(name="Source", value=metadata.source)
embed.title = metadata.long_name + (" " + metadata.emoji if metadata.emoji else "")
embed.colour = cmn.colours.good
embed.set_image(url="attachment://" + metadata.filename)
await ctx.send(embed=embed, file=img)
embed.set_image(url=opt.resources_url + metadata.filename)
await ctx.send(embed=embed)
@commands.command(name="grayline", aliases=["greyline", "grey", "gray", "gl"], category=cmn.cat.maps)
async def _grayline(self, ctx: commands.Context):

View File

@ -1,22 +1,27 @@
"""
Morse Code extension for qrm
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
Copyright (C) 2019-2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
"""
import json
import discord.ext.commands as commands
import common as cmn
from resources import morse
class MorseCog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
with open(cmn.paths.resources / "morse.1.json") as file:
d = json.load(file)
self.morse: dict[str, str] = d["morse"]
self.ascii: dict[str, int] = d["ascii"]
@commands.command(name="morse", aliases=["cw"], category=cmn.cat.ref)
async def _morse(self, ctx: commands.Context, *, msg: str):
@ -24,7 +29,7 @@ class MorseCog(commands.Cog):
result = ""
for char in msg.upper():
try:
result += morse.morse[char]
result += self.morse[char]
except KeyError:
result += "<?>"
result += " "
@ -44,7 +49,7 @@ class MorseCog(commands.Cog):
for word in msg:
for char in word:
try:
result += morse.ascii[char]
result += self.ascii[char]
except KeyError:
result += "<?>"
result += " "
@ -62,7 +67,7 @@ class MorseCog(commands.Cog):
weight = 0
for char in msg:
try:
cw_char = morse.morse[char].replace("-", "==")
cw_char = self.morse[char].replace("-", "==")
weight += len(cw_char) * 2 + 2
except KeyError:
embed.title = "Error in calculation of CW weight"

15
main.py
View File

@ -2,7 +2,7 @@
"""
qrm, a bot for Discord
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
Copyright (C) 2019-2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
@ -25,6 +25,7 @@ from discord.ext import commands, tasks
import info
import common as cmn
import utils.connector as conn
from utils.resources_manager import ResourcesManager
import data.keys as keys
import data.options as opt
@ -267,6 +268,18 @@ async def _ensure_activity_fixed():
# --- Run ---
resource_versions = {
"bandcharts": "v1",
"img": "v1",
"maps": "v1",
"morse": "v1",
"phonetics": "v1",
"qcodes": "v1",
"funetics": "v1"
}
bot.qrm.rm = ResourcesManager(cmn.paths.resources, opt.resources_url, resource_versions)
for ext in opt.exts:
bot.load_extension(ext_dir + "." + ext)

View File

@ -5,3 +5,5 @@ qrztools[async]~=1.0
beautifulsoup4
pytz
cairosvg
requests
pydantic

18
resource_schemas.py Normal file
View File

@ -0,0 +1,18 @@
"""
Resource schemas generator for qrm2.
---
Copyright (C) 2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
"""
import utils.resources_models as models
print("Generating schema for index.json")
with open("./dev-notes/rs_index_schema.json", "w") as file:
file.write(models.Index.schema_json(indent=4))
print("Done!")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 441 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -1,12 +0,0 @@
{
"au": ["au.png", "Australia", "Amateur radio bands in Australia", "", "[Radio Amateur Society of Australia](https://vkradioamateurs.org/its-my-frequency-and-ill-cry-if-i-want-to/) [[PDF]](https://vkradioamateurs.org/wp-content/uploads/2018/05/VK-Band-Plan-Quick-Reference-1.pdf)", "🇦🇺"],
"ca": ["ca.png", "Canada", "Amateur radio bands in Canada", "**This bandplan is incomplete**; some bands, like 630m, are simply not present. It also does not cover any band above 30MHz.", "[RAC 0-30MHz Band Plan](https://www.rac.ca/wp-content/uploads/files/pdf/RAC%20Bandplan%20December%201%202015.pdf)", "🇨🇦"],
"cn": ["cn.png", "China", "Amateur radio bands in China", "", "Created by KN8U and NY7H", "🇨🇳"],
"it_hf": ["it_hf.png", "Italy (HF)", "HF amateur radio bands in Italy", "", "[Associazione Radioamatori Italiani](https://www.arimi.it/download/bandplan/) [[PDF]](http://www.arimi.it/wp-content/Plan/BP%20HF%202013%2032.pdf)", "🇮🇹"],
"it_vhf": ["it_vhf.png", "Italy (VHF/UHF)", "VHF/UHF amateur radio bands in Italy", "", "[Associazione Radioamatori Italiani](https://www.arimi.it/download/bandplan/) [[PDF]](https://www.arimi.it/wp-content/Plan/BP%20V_UHF%202013%2032.pdf)", "🇮🇹"],
"it_shf": ["it_shf.png", "Italy (UHF/SHF)", "UHF/SHF amateur radio bands in Italy", "", "[Associazione Radioamatori Italiani](https://www.arimi.it/download/bandplan/) [[PDF]](https://www.arimi.it/wp-content/Plan/BP%20U-SHF.pdf)", "🇮🇹"],
"jp": ["jp.png", "Japan", "Amateur radio bands in Japan", "Pending checks against the latest update from the 総務省 (MIC) of Japan, March 2020", "[JARL Amateur-Use Bandplans](https://jarl.org/Japanese/A_Shiryo/A-3_Band_Plan/bandplan20150105.pdf)", "🇯🇵"],
"mx": ["mx.png", "Mexico", "Radio allocations in Mexico", "Full radio allocations chart for all services. No information specific to amateur radio is shown.", "Secretaría de Comunicaciones y Transportes (SCT) / Instituto Federal de Telecomunicaciones (IFT)", "🇲🇽"],
"nl": ["nl.png", "Netherlands", "Amateur radio bands in the Netherlands", "*This version of this bandplan is no longer hosted on VERNON's website and it's accuracy cannot be guaranteed.*", "[VERNON Global Band Plan van de Telecom Agency, Ministerie van Economische Zaken en Klimaat](https://www.veron.nl/downloads/brochures/)", "🇳🇱"],
"us": ["us.png", "USA", "Amateur radio bands in the USA", "", "*[ARRL Frequency Chart](https://www.arrl.org/shop/ARRL-Frequency-Chart-11-17/)* [[PDF]](http://www.arrl.org/files/file/Regulatory/Band%20Chart/Band%20Chart%20-%2011X17%20Color.pdf)", "🇺🇸"]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

View File

@ -1,10 +0,0 @@
{
"ca": ["ca.png", "Canada's Prefixes", "Map of the prefix regions in Canada", "", "[Denelson83 (Wikimedia Commons)](https://commons.wikimedia.org/wiki/File:Amateur_radio_prefixes_in_Canada.svg)", "🇨🇦"],
"cn": ["cn.png", "China's Prefixes", "Map of prefix regions in China", "", "CRAC", "🇨🇳"],
"us": ["us.png", "USA's Prefixes", "Map of prefix regions in the USA", "", "*[ARRL WAS Map](https://www.arrl.org/was-forms)* [[PDF]](http://www.arrl.org/files/file/Awards%20Application%20Forms/WASmap_Color.pdf)", "🇺🇸"],
"itur": ["itu-regions.png", "ITU Regions", "ITU Regions", "These are also used by the IARU for their regions.", "[EI8IC](https://www.mapability.com/ei8ic/maps/maps.php)", "🇺🇳"],
"ituz": ["itu-zones.png", "ITU Zones", "ITU Zones", "", "[EI8IC](https://www.mapability.com/ei8ic/maps/maps.php)", "🇺🇳"],
"arrl": ["arrl-rac.png", "ARRL Sections", "ARRL Sections", "", "[EI8IC](https://www.mapability.com/ei8ic/maps/maps.php)", "🇺🇸"],
"cq": ["cq-zones.png", "CQ Zones", "CQ Zones", "These are used for the CQWW contest.", "[EI8IC](https://www.mapability.com/ei8ic/maps/maps.php)", "🌐"],
"rac": ["arrl-rac.png", "RAC Sections", "RAC Sections", "", "[EI8IC](https://www.mapability.com/ei8ic/maps/maps.php)", "🇨🇦"]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 KiB

View File

@ -1,136 +0,0 @@
"""
A listing of morse code symbols
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrmbot and is released under the terms of
the GNU General Public License, version 2.
"""
morse = {
"A": ".-",
"B": "-...",
"C": "-.-.",
"D": "-..",
"E": ".",
"F": "..-.",
"G": "--.",
"H": "....",
"I": "..",
"J": ".---",
"K": "-.-",
"L": ".-..",
"M": "--",
"N": "-.",
"O": "---",
"P": ".--.",
"Q": "--.-",
"R": ".-.",
"S": "...",
"T": "-",
"U": "..-",
"V": "...-",
"W": ".--",
"X": "-..-",
"Y": "-.--",
"Z": "--..",
"1": ".----",
"2": "..---",
"3": "...--",
"4": "....-",
"5": ".....",
"6": "-....",
"7": "--...",
"8": "---..",
"9": "----.",
"0": "-----",
".": ".-.-.-",
",": "--..--",
"?": "..--..",
"'": ".----.",
"!": "-.-.--",
"/": "-..-.",
"(": "-.--.",
")": "-.--.-",
"&": ".-...",
":": "---...",
";": "-.-.-.",
"=": "-...-",
"+": ".-.-.",
"-": "-....-",
"\"": ".-..-.",
"@": ".--.-.",
"Ä": ".-.-",
"Å": ".-.-",
"Ą": ".-.-",
"Æ": ".-.-",
"É": "..-..",
"Ñ": "--.--",
"Ö": "---.",
"Ü": "..--",
"Š": "----",
" ": "/"
}
ascii = {
".-": "A",
"-...": "B",
"-.-.": "C",
"-..": "D",
".": "E",
"..-.": "F",
"--.": "G",
"....": "H",
"..": "I",
".---": "J",
"-.-": "K",
".-..": "L",
"--": "M",
"-.": "N",
"---": "O",
".--.": "P",
"--.-": "Q",
".-.": "R",
"...": "S",
"-": "T",
"..-": "U",
"...-": "V",
".--": "W",
"-..-": "X",
"-.--": "Y",
"--..": "Z",
".----": "1",
"..---": "2",
"...--": "3",
"....-": "4",
".....": "5",
"-....": "6",
"--...": "7",
"---..": "8",
"----.": "9",
"-----": "0",
".-.-.-": ".",
"--..--": ",",
"..--..": "?",
".----.": "'",
"-.-.--": "!",
"-..-.": "/",
"-.--.": "(",
"-.--.-": ")",
".-...": "&",
"---...": ":",
"-.-.-.": ";",
"-...-": "=",
".-.-.": "+",
"-....-": "-",
".-..-.": "\"",
".--.-.": "@",
".-.-": "Ä",
"..-..": "É",
"--.--": "Ñ",
"---.": "Ö",
"..--": "Ü",
"----": "Š",
"/": " "
}

View File

@ -1,78 +0,0 @@
"""
A listing of NATO Phonetics
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrmbot and is released under the terms of
the GNU General Public License, version 2.
"""
phonetics = {
"a": "alfa",
"b": "bravo",
"c": "charlie",
"d": "delta",
"e": "echo",
"f": "foxtrot",
"g": "golf",
"h": "hotel",
"i": "india",
"j": "juliett",
"k": "kilo",
"l": "lima",
"m": "mike",
"n": "november",
"o": "oscar",
"p": "papa",
"q": "quebec",
"r": "romeo",
"s": "sierra",
"t": "tango",
"u": "uniform",
"v": "victor",
"w": "whiskey",
"x": "x-ray",
"y": "yankee",
"z": "zulu"
}
pweights = {
"A": 2,
"B": 2,
"C": 2,
"D": 2,
"E": 2,
"F": 2,
"G": 1,
"H": 2,
"I": 3,
"J": 3,
"K": 2,
"L": 2,
"M": 1,
"N": 3,
"O": 2,
"P": 2,
"Q": 2,
"R": 3,
"S": 3,
"T": 2,
"U": 3,
"V": 2,
"W": 2,
"X": 2,
"Y": 2,
"Z": 2,
"0": 2,
"1": 1,
"2": 1,
"3": 1,
"4": 1,
"5": 1,
"6": 1,
"7": 2,
"8": 1,
"9": 2,
"/": 1,
}

View File

@ -1,286 +0,0 @@
"""
A listing of Q Codes
---
Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrmbot and is released under the terms of
the GNU General Public License, version 2.
"""
# flake8: noqa
qcodes = {
"QAB": "May I have clearance (for ...) from ... (place) to ... (place) at flight level/altitude ... ? / You are cleared (or ... is cleared) by ... from ... (place) to ... (place) at flight level/altitude ...",
"QAF": "Will you advise me when you are (were) at (over) ... (place)? / I am (was) at (over) ... (place) (at ... hours) at flight level/altitude ...",
"QAG": "Arrange your flight in order to arrive over ... (place) at ... hours.",
"QAH": "What is your height above ... (datum)? / I am at .... flight level/altitude ... --or-- Arrange your flight so as to reach flight level/altitude ... at ... (hours or place).",
"QAI": "What is the essential traffic respecting my aircraft? / The essential traffic respecting your aircraft is ...",
"QAK": "Is there any risk of collision? / There is risk of collision.",
"QAL": "Are you going to land at ... (place)? I am going to land at ... (place).",
"QAM": "What is the latest available meteorological observation for ... (place)? / Meteorological observation made at ... (place) at ... hours was as follows ...",
"QAN": "What is the surface wind direction and speed at ... (place)? / The surface wind direction and speed at ... (place) at ... hours is ... (direction) ... (speed).",
"QAO": "What is the wind direction in degrees TRUE and speed at ... (position or zone/s) at each of the ... (figures) ... (units) levels above ... (datum)? / The wind direction and speed at (position or zone/s) at flight level/altitude ... is: ... (vertical distance) ... degrees TRUE ... (speed).",
"QAP": "Shall I listen for you (or for ...) on ... kHz (... MHz)? / Listen for me (or for ...) on ... kHz (... MHz).",
"QAQ": "Am I near a prohibited, restricted or danger area?",
"QAR": "May I stop listening on the watch frequency for ... minutes? / You may stop listening on the watch frequency for ... minutes.",
"QAU": "Where may I jettison fuel? / I am about to jettison fuel.",
"QAW": "I am about to carry out overshoot procedure.",
"QAY": "Will you advise me when you pass (passed) ... (place) bearing 090 (270) degrees relative to your heading? / I passed ... (place) bearing ... degrees relative to my heading at ... hours.",
"QAZ": "Are you experiencing communication difficulties through flying in a storm? / I am experiencing communication difficulties through flying in a storm.",
"QBA": "What is the horizontal visibility at ... (place)? / The horizontal visibility at ... (place) at ... hours is ... (distance figures and units).",
"QBB": "What is the amount, type and height above official aerodrome elevation of the base of the cloud [at ... (place)]? / The amount, type and height above official aerodrome elevation of the base of the cloud at ... (place) at ... hours is: ... eights (... type) at ... (figures and units) height above official aerodrome elevation.",
"QBC": "Report meteorological conditions as observed from your aircraft [at ... (position or zone)] [(at ... hours)]. / The meteorological conditions as observed from my aircraft at ... (position or zone) at ... hours at ... (figures and units) height above ... (datum) are ...",
"QBD": "How much fuel have you remaining (expressed as hours and/or minutes of consumption)? / My fuel endurance is ... (hours and/or minutes).",
"QBE": "I am about to wind in my aerial.",
"QBF": "Are you flying in cloud? / I am flying in cloud at ... flight level/altitude ... [and I am ascending (descending) to flight level/altitude ...].",
"QBG": "Are you flying above cloud? / I am flying above cloud and at flight level/altitude ...",
"QBH": "Are you flying below cloud? / I am flying below cloud and at flight level/altitude ...",
"QBI": "Is flight under IFR compulsory at ... (place) [or from ... to ... (place)]? / Flight under IFR is compulsory at ... (place) [or from ... to ... (place)].",
"QBJ": "What is the amount, type and height above ... (datum) of the top of the cloud [at ... (position or zone)]? / At ... hours at ... (position or zone) the top of the cloud is: amount ... eights (... type) at ... (figures and units) height above ... (datum).",
"QBK": "Are you flying with no cloud in your vicinity? / I am flying with no cloud in my vicinity and at flight level/altitude ...",
"QBM": "Has ... sent any messages for me? / Here is the message sent by ... at ... hours.",
"QBN": "Are you flying between two layers of cloud? / I am flying between two layers of cloud and at flight level/altitude ...",
"QBO": "What is the nearest aerodrome at which flight under VFR is permissible and which would be suitable for my landing? / Flying under VFR is permissible at ... (place) which would be suitable for your landing.",
"QBP": "Are you flying in and out of cloud? / I am flying in and out of cloud and at flight level/altitude ...",
"QBS": "Ascend (or descend) to ... (figures and units) height above ... (datum) before encountering instrument meteorological conditions or if visibility falls below ... (distance figures and units) and advise.",
"QBT": "What is the runway visual range at ... (place)? / The runway visual range at ... (place) at ... hours is ... (distance figures and units).",
"QBV": "Have you reached flight level/altitude ... [or ... (area or place)]? / I have reached ... flight level/altitude ... [or ... (area or place)].",
"QBX": "Have you left ... flight level/altitude ... [or ... (area or place)]? / I have left ... flight level/altitude ... [or ... (area or place)].",
"QBZ": "Report your flying conditions in relation to clouds. / The reply to QBZ ? is given by the appropriate answer form of signals QBF, QBG, QBH, QBK, QBN and QBP.",
"QCA": "May I change my flight level/altitude from ... to ... ? / You may change your flight level/altitude from ... to ...",
"QCB": "Delay is being caused by ...",
"QCE": "When may I expect approach clearance? / Expect approach clearance at ... hours.",
"QCF": "Delay indefinite. Expect approach clearance not later than ... hours.",
"QCH": "May I taxi to ... (place)? / Cleared to taxi to ... (place).",
"QCI": "Make a 360-degree turn immediately (turning to the ...).",
"QCS": "My reception on ... frequency has broken down.",
"QCX": "What is your full call sign? / My full call sign is ...",
"QCY": "I am working on a trailing aerial.",
"QDB": "Have you sent message ... to ... ? / I have sent message ... to ...",
"QDF": "What is your D-Value at ... (position)?",
"QDL": "Do you intend to ask me for a series of bearings? / I intend to ask you for a series of bearings.",
"QDM": "Will you indicate the MAGNETIC heading for me to steer towards you (or ...) with no wind? / The MAGNETIC heading for you to steer to reach me (or ...) with no wind was ... degrees (at ... hours).",
"QDP": "Will you accept control (or responsibility) of (for) ... now (or at ... hours)? / I will accept control (or responsibility) of (for) ... now (or at ... hours).",
"QDR": "What is my MAGNETIC bearing from you (or from ...)? / Your MAGNETIC bearing from me (or from ...) was ... degrees (at ... hours).",
"QDT": "Are you flying in visual meteorological condition? / I am flying in visual meteorological condition.",
"QDU": "Cancelling my IFR flight.",
"QDV": "Are you flying in a flight visibility of less than ... (figures and units)? / I am flying in a flight visibility of less than ... (figures and units) at flight level/altitude ...",
"QEA": "May I cross the runway ahead of me? / You may cross the runway ahead of you.",
"QEB": "May I turn at the intersection? / Taxi as follows at the intersection ...",
"QEC": "May I make a 180-degree turn and return down the runway? / You may make a 180-degree turn and return down the runway.",
"QED": "Shall I follow the pilot vehicle? / Follow the pilot vehicle.",
"QEF": "Have I reached my parking area? / You have reached your parking area.",
"QEG": "May I leave the parking area? / You may leave the parking area.",
"QEH": "May I move to the holding position for runway number ... ? / Cleared to the holding position for runway number ...",
"QEJ": "May I assume position for take-off? / Cleared to hold at take-off position for runway number ...",
"QEK": "Are you ready for immediate take-off? / I am ready for immediate take-off.",
"QEL": "May I take-off (and make a ... hand turn after take-off)? / You are cleared to take-off (turn as follows after take-off ...).",
"QEM": "What is the condition of the landing surface at ... (place)? / The condition of the landing surface at ... (place) is ...",
"QEN": "Shall I hold my position? / Hold your position",
"QEO": "Shall I clear the runway (or landing area)? / Clear the runway (or landing area).",
"QES": "Is a right-hand circuit in force at ... (place)? / A right-hand circuit is in force at ... (place).",
"QFA": "What is the meteorological forecast for ... (flight, route, section of route or zone) for the period ... hours until ... hours? / The meteorological forecast for ... (flight, route, section of route or zone) for the period ... hours until ... hours is ...",
"QFB": "The approach/runway lights are out of order.",
"QFC": "What is the amount, the type and the height above ... (datum) of the base of the cloud at ... (place, position or zone)? / At ... (place, position or zone) the base of the cloud is ... eighths ... type at ... (figures and units) height above ... (datum).",
"QFD": "Is the ... visual beacon [at ... (place)] in operation?",
"QFE": "What should I set on the subscale of my altimeter so that the instrument would indicate its height above the reference elevation being used? / If you set the subscale of your altimeter to read ... millibars, the instrument would indicate its height above aerodrome elevation (above threshold, runway number ...).",
"QFF": "[At ... (place)] what is the present atmospheric pressure converted to mean sea level in accordance with meteorological practice? / At ... (place) the atmospheric pressure converted to mean sea level in accordance with meteorological practice is (or was determined at ... hours to be) ... millibars.",
"QFG": "Am I overhead? / You are overhead.",
"QFH": "May I descend below the clouds? / You may descend below the clouds.",
"QFI": "Are the aerodrome lights lit? / The aerodrome lights are lit.",
"QFL": "Will you send up pyrotechnical lights? / I will send up pyrotechnical lights.",
"QFM": "What flight level/altitude should I maintain?",
"QFO": "May I land immediately? / You may land immediately.",
"QFP": "Will you give me the latest information concerning ... facility [at ... (place)]? / The latest information concerning ... facility [at ... (place)] is as follows ...",
"QFQ": "Are the approach and runway lights lit? / The approach and runway lights are lit.",
"QFR": "Does my landing gear appear damaged? / Your landing gear appears damaged.",
"QFS": "Is the radio facility at ... (place) in operation? / The radio facility at ... (place) is in operation (or will be in operation in ... hours).",
"QFT": "Between what heights above ... (datum) has ice formation been observed [at ... (position or zone)]? / Ice formation has been observed at ... (position or zone) in the type of ... and with an accretion rate of ... between ... (figures and units) and ... (figures and units) heights above ... (datum).",
"QFU": "What is the magnetic direction (or number) of the runway to be used? / The magnetic direction (or number) of the runway to be used is ...",
"QFV": "Are the floodlights switched on? / The floodlights are switched on.",
"QFW": "What is the length of the runway in use in ... (units)? / The length of runway ... now in use is ... (figures and units).",
"QFX": "I am working (or am going to work) on a fixed aerial.",
"QFY": "Please report the present meteorological landing conditions [at ... (place)]. / The present meteorological landing conditions at ... (place) are ...",
"QFZ": "What is the aerodrome meteorological forecast for ... (place) for the period ... hours until ... hours? / The aerodrome meteorological forecast for ... (place) for the period ... hours until ... hours is ...",
"QGC": "There are obstructions to the ... of ... runway ...",
"QGD": "Are there on my track any obstructions whose elevation equals or exceeds my altitude? / There are obstructions on your track ... (figures and units) height above ... (datum).",
"QGE": "What is my distance to your station (or to ...)? / Your distance to my station (or to ...) is ... (distance figures and units).",
"QGH": "May I land using ... (procedure or facility)? / You may land using ... (procedure or facility).",
"QGK": "What track should I make good? / Make good a track from ... (place) on ... degrees ... (true or magnetic).",
"QGL": "May I enter the ... (control area or zone) at ... (place)? / You may enter the ... (control area or zone) at ... (place).",
"QGM": "Leave the ... (control area or zone).",
"QGN": "May I be cleared to land [at ... (place)]? / You are cleared to land [at ... (place)].",
"QGO": "Landing is prohibited at ... (place).",
"QGP": "What is my number for landing? / You are number ... to land.",
"QGQ": "May I hold at ... (place)? / Hold at ... (place) at flight level/altitude ... (datum) and await further clearance.",
"QGT": "Fly for ... minutes on a heading what will enable you to maintain a track reciprocal to your present one.",
"QGU": "Fly for ... minutes on a magnetic heading of ... degrees.",
"QGV": "Do you see me? / Can you see the aerodrome? / Can you see ... (aircraft)? / I see you at ... (cardinal or quadrantal point of direction).",
"QGW": "Does my landing gear appear to be down and in place? / Your landing gear appears to be down and in place.",
"QGZ": "Hold on ... direction of ... facility.",
"QHE": "Will you inform me when you are on ... leg of approach? / I am on ...(leg).. of approach.",
"QHG": "May I enter traffic circuit at flight level/altitude ...? / Cleared to enter traffic circuit at flight level/altitude ...",
"QHH": "Are you making an emergency landing? / I am making an emergency landing.",
"QHI": "Are you (or is ...) ... waterborne / on land? ",
"QHQ": "May I make a ... approach [at ... (place)]? / You may make a ... approach [at ... (place)].",
"QHZ": "Shall I circle the aerodrome (or go around)? / Circle the aerodrome (or go around).",
"QIC": "May I establish communication with ... radio station on ... kHz (or ... MHz.) now (or at ... hours)? / Establish communication with ... radio station on ... kHz. (or MHz.) now (or at ...hours).",
"QIF": "What frequency is ... using? / ... is using ... kHz (or ... MHz.).",
"QJA": "Is my tape / mark and space reversed? / Your tape / mark and space is reversed.",
"QJB": "Will you use radio/cable/telegraph/teletype/telephone/receiver/transmitter/reperforator? / I will use ...",
"QJC": "Will you check your transmitter/autohead/perforator/reperfordator/printer/keyboard/antenna? / I will check my ...",
"QJD": "Am I transmitting letters/figures? / You are transmitting ...",
"QJE": "Is my frequency shift wide/narrow/correct? / Your frequency shift is ... (by ... cycles)",
"QJF": "My signal as checked by monitor locally/as radiated is satisfactory.",
"QJG": "Shall I revert to automatic relay? / Revert to automatic relay.",
"QJH": "Shall I run test tape/sentence? / Run test tape/sentence.",
"QJI": "Will you transmit a continuous mark/space? / I am transmitting a continuous mark/space.",
"QJK": "Are you receiving continuous mark/space / mark/space bias? / I am receiving a continuous mark/space / mark/space bias.",
"QKC": "The sea conditions (at ... position) ... permit alighting but not takeoff / render alihting extremely hazardous.",
"QKF": "May I be relieved (at ... hours)? / You may expect to be relieved at ... hours [by aircraft/vessel/callsign/name].",
"QKG": "Will relief take place when ... (identification) establishes visual/comms contact with survivors? / Relief will take place when ... (identification) establishes visual/comms contact with survivors.",
"QKH": "Report details of the parallel sweep (track) search being (or to be) conducted? --or-- In the parallel sweep (track) search being (or to be) conducted, what is (are) the direction/separation/altitude of sweeps employed in the search pattern? / The parallel sweep (track) search is being (or to be) conducted [with direction of sweeps ... degrees ... (true or magnetic) || with ... (distance figures and units) separation between sweeps || flight level/altitude].",
"QKN": "Aircraft plotted (believed to be you) in position ... on track ... degrees at ... hours.",
"QKO": "What other units are (or will be) taking part in the operation [... (identification of operation)]? / In the operation [... (identification)], the following units are (or will be) taking part ... (name of units). --or-- ... (name) unit is taking part in operation [... (identification] (with effect from ... hours).",
"QKP": "Which pattern of search is being followed? / The search pattern is parallel sweep/square search/creeping line ahead/track crawl/contour search/combined search by aircraft and ship/[other].",
"QLB": "Will you monitor ... station and report regarding range, quality, etc.? / I have monitored ... station and report (briefly) as follows ...",
"QLE": "What is your expected signal? / The expected signal is low...",
"QLF": "Are you sending with your left foot? Try sending with your left foot!",
"QLH": "Will you use simultaneous keying on ... frequency and ... frequency? / I will now key simultaneously on ... frequency and ... frequency.",
"QLV": "Is the ... radio facility still required? / The ... radio facility is still required.",
"QMH": "Shift to transmit and receive on ... kHz (or ... MHz.); if communication is not established within 5 minutes, revert to present frequency.",
"QMI": "Report the vertical distribution of cloud [at ... (position or zone)] as observed from your aircraft. / The vertical distribution of cloud as observed from my aircraft at ... hours at ... (position or zone) is : *lowest layer observed* ... eights (... type) with base of ... (figures and units) and tops of ... (figures and units) [*and similarly in sequence for each of the layers observed.] height above ... (datum).",
"QMU": "What is the surface temperature at ... (place) and what is the dew point temperature at that place? / The surface temperature at ... (place) at ... hours is ... degrees and the dew point temperature at that time and place is ... degrees.",
"QMW": "At ... (position or zone) what is (are) the flight level(s)/altitude(s) ... of the zero Celsius isotherm(s)? / At ... (position or zone) the zero Celsius isotherm(s) is (are) at flight level(s)/altitude(s) ...",
"QMX": "What is the air temperature [at ... (position or zone)] (at ... hours) at flight level/altitude ...? / At ... (position or zone) at ... hours the air temperature is ... (degrees and units) at flight level/altitude ... --Note-- Aircraft reporting QMX information will transmit the temperature figures as corrected for airspeed.",
"QMZ": "Have you any amendments to the flight forecast in respect of section of route yet to be traversed? / The following amendment(s) should be made to the flight forecast ... [If no amendments, signal QMZ NIL]",
"QNE": "What indication will my altimeter give on landing at ... (place) at ... hours, my sub-scale being set to 1013.2 millibars (29.92 inches)? / On landing at ... (place) at ... hours, with your sub-scale being set to 1013.2 millibars (29.92 inches), your altimeter will indicate ... (figures and units).",
"QNH": "What should I set on the subscale of my altimeter so that the instrument would indicate its elevation if my aircraft were on the ground at your station? / If you set the subscale of your altimeter to read ... millibars, the instrument would indicate its elevation if your aircraft were on the ground at my station at ... hours. --Note-- When the setting is given in hundredths of inch the abbreviation INS is used to identify the units.",
"QNI": "May I join the net? / You may check in...",
"QNO": "I am not equipped to give the information (or provide the facility) requested.",
"QNR": "I am approaching my point of no return.",
"QNT": "What is the maximum speed of the surface wind at ... (place)? / The maximum speed of the surface wind at ... (place) at ... hours is ... (speed figures and units).",
"QNY": "What is the present weather and the intensity thereof at ... (place, position or zone)? / The present weather and intensity thereof at ... (place, position or zone) at ... hours is ...",
"QOA": "Can you communicate by radiotelegraphy (500 kHz)? / I can communicate by radiotelegraphy (500 kHz).",
"QOB": "Can you communicate by radiotelephony (2182 kHz)? / I can communicate by radiotelephony (2182 kHz).",
"QOC": "Can you communicate by radiotelephony (channel 16 - frequency 156.80 MHz)? / I can communicate by radiotelephony (channel 16 - frequency 156.80 MHz).",
"QOD": "Can you communicate with me in Dutch/English/French/German/Greek/Italian/Japanese/Norwegian/Russian/Spanish? / I can communicate with you in ...",
"QOE": "Have you received the safety signal sent by ... (name and/or call sign)? / I have received the safety signal sent by ... (name and/or call sign).",
"QOF": "What is the commercial quality of my signals? / The quality of your signals is not commercial/marginally commercial/commercial.",
"QOG": "How many tapes have you to send? / I have ... tapes to send.",
"QOH": "Shall I send a phasing signal for ... seconds? / Send a phasing signal for ... seconds.",
"QOI": "Shall I send my tape? / Send your tape.",
"QOJ": "Will you listen on ... kHz (or MHz) for signals of emergency position-indicating radiobeacons? / I am listening on ... kHz (or MHz) for signals of emergency position-indicating radiobeacons.",
"QOK": "Have you received the signals of an emergency position-indicating radiobeacon on ... kHz (or MHz)? / I have received the signals of an emergency position-indicating radiobeacon on ... kHz (or MHz).",
"QOL": "Is your vessel fitted for reception of selective calls? If so, what is your selective call number or signal? / My vessel is fitted for the reception of selective calls. My selective call number or signal is ...",
"QOM": "On what frequencies can your vessel be reached by a selective call? / My vessel can be reached by a selective call on the following frequency/ies ... (periods of time to be added if necessary).",
"QOO": "Can you send on any working frequency? / I can send on any working frequency.",
"QOT": "Do you hear my call; what is the approximate delay in minutes before we may exchange traffic? / I hear your call; the approximate delay is ... minutes.",
"QRA": "What is the name of your vessel (or station)? / The name of my vessel (or station) is ...",
"QRB": "How far approximately are you from my station? / The approximate distance between our stations is ... nautical miles (or km).",
"QRC": "What is your true bearing? / My true bearing is ____ degrees.",
"QRD": "Where are you bound for? / I am bound for ____.",
"QRE": "What is your estimated time of arrival at ... (or over ...) (place)? / My estimated time of arrival at ... (or over ...) (place) is ... hours.",
"QRF": "Where are you bound from? / I am bound from ____.",
"QRG": "Will you tell me my exact frequency (or that of ...)? / Your exact frequency (or that of ...) is ... kHz (or MHz).",
"QRH": "Does my frequency vary? / Your frequency varies.",
"QRI": "How is the tone of my transmission? / The tone of your transmission is ...",
"QRJ": "How many voice contacts do you want to make? / I want to make ... voice contacts.",
"QRK": "How do you receive me? / I am receiving (1-5).",
"QRL": "Are you busy? / I am busy (or I am busy with ...). Please do not interfere.",
"QRM": "Are you being interfered with? / I am being interfered with.",
"QRN": "Are the atmospherics strong? / Atmospherics (noise) are very strong.",
"QRO": "Shall I increase transmitter power? / Increase transmitter power.",
"QRP": "Shall I decrease transmitter power? / Decrease transmitter power.",
"QRQ": "Shall I send faster? / Send faster (... wpm)",
"QRR": "Are you ready for automatic operation? / I am ready for automatic operation. Send at ... words per minute.",
"QRS": "Shall I send more slowly? / Send more slowly (... words per minute).",
"QRT": "Shall I stop sending? / Stop sending.",
"QRU": "Have you anything for me? / I have nothing for you.",
"QRV": "Are you ready? / I am ready.",
"QRW": "Shall I inform ... that you are calling him on ... kHz (or MHz)? / Please inform ... that I am calling him on ... kHz (or MHz).",
"QRX": "When will you call me again? / I will call you again at ... hours (on ... kHz (or MHz)).",
"QRY": "What is my turn? / Your turn is Number ... (or according to any other indication).",
"QRZ": "Who is calling me? / You are being called by ... (on ... kHz (or MHz)).",
"QSA": "What is the strength of my signals (or those of ...)? / The strength of your signals (or those of ...) is ...",
"QSB": "Are my signals fading? / Your signals are fading.",
"QSC": "Are you a cargo vessel? --or-- Are you a low traffic ship? / I am a cargo vessel. --or-- I am a low traffic ship.",
"QSD": "Is my keying defective? --or-- Are my signals mutilated? / Your keying is defective. --or-- Your signals are mutilated.",
"QSE": "What is the estimated drift of the survival craft? / The estimated drift of the survival craft is ... (figures and units).",
"QSF": "Have you effected rescue? / I have effected rescue and am proceeding to ... base (with ... persons injured requiring ambulance).",
"QSG": "Shall I send ... telegrams at a time? / Send ... telegrams at a time.",
"QSH": "Are you able to home on your direction-finding equipment? / I am able to home on my D/F equipment (on station ...).",
"QSI": "I have been unable to break in on your transmission. --or-- Will you inform ... (call sign) that I have been unable to break in on his transmission (on ... kHz (or MHz)).",
"QSJ": "What is the charge to be collected to ... including your internal charge? / The charge to be collected to ... including my internal charge is ... francs.",
"QSK": "Can you hear me between your signals and if so can I break in on your transmission? / I can hear you between my signals; break in on my transmission.",
"QSL": "Can you acknowledge receipt? / I am acknowledging receipt.",
"QSM": "Shall I repeat the last telegram (message) which I sent you, or some previous telegram (message)? / Repeat the last telegram (message) which you sent me (or telegram(s) (message(s)) numbers(s) ...).",
"QSN": "Did you hear me (or ... (call sign)) on ... kHz (or MHz)? / I did hear you (or ... (call sign)) on ... kHz (or MHz).",
"QSO": "Can you communicate with ... direct (or by relay)? / I can communicate with ... direct (or by relay through ...).",
"QSP": "Will you relay to ... free of charge? / I will relay to ... free of charge.",
"QSQ": "Have you a doctor on board (or is ... (name of person) on board)? / I have a doctor on board (or ... (name of person) is on board).",
"QSR": "Shall I repeat the call on the calling frequency? / Repeat your call on the calling frequency; did not hear you (or have interference).",
"QSS": "What working frequency will you use? / I will use the working frequency ... kHz (or MHz) (in the HF bands normally only the last three figures of the frequency need be given).",
"QST": "Here is a broadcast message to all amateurs.",
"QSU": "Shall I send or reply on this frequency (or on ... kHz (or MHz)) (with emissions of class ...)? / Send or reply on this frequency (or on ... kHz (or MHz)) (with emissions of class ...).",
"QSV": "Shall I send a series of Vs on this frequency (or on ... kHz (or MHz))? / Send a series of Vs on this frequency (or on ... kHz (or MHz)).",
"QSW": "Will you send on this frequency (or on ... kHz (or MHz)) (with emissions of class ...)? / I am going to send on this frequency (or on ... kHz (or MHz)) (with emissions of class ...).",
"QSX": "Will you listen to ... (call sign(s)) on ... kHz (or MHz)? --or-- Will you listen to ... (call sign(s)) on ... kHz (or MHz), or in the bands ... / channels ... ? / I am listening to ... (call sign(s)) on ... kHz (or MHz). --or-- I am listening to ... (call sign(s)) on ... kHz (or MHz), or in the bands ... / channels ...",
"QSY": "Shall I change to transmission on another frequency? / Change to transmission on another frequency (or on ... kHz (or MHz)).",
"QSZ": "Shall I send each word or group more than once? / Send each word or group twice (or ... times).",
"QTA": "Shall I cancel telegram (or message) number ... ? / Cancel telegram (or message) number ...",
"QTB": "Do you agree with my counting of words? / I do not agree with your counting of words; I will repeat the first letter or digit of each word or group.",
"QTC": "How many telegrams have you to send? / I have ... telegrams for you (or for ...).",
"QTD": "What has the rescue vessel or rescue aircraft recovered? / ... (identification) has recovered ... survivors/wreckage/bodies.",
"QTE": "What is my TRUE bearing from you? --or-- What is my TRUE bearing from ... (call sign)? --or-- What is the TRUE bearing of ... (call sign) from ... (call sign)? / Your TRUE bearing from me is ... degrees at ... hours. --or-- Your TRUE bearing from ... (call sign) was ... degrees at ... hours. --or-- The TRUE bearing of ... (call sign) from ... (call sign) was ... degrees at ... hours.",
"QTF": "Will you give me the position of my station according to the bearings taken by the direction-finding stations which you control? / The position of your station according to the bearings taken by the D/F stations which I control was ... latitude, ... longitude (or other indication of position), class ... at ... hours.",
"QTG": "Will you send two dashes of ten seconds each followed by your call sign (repeated ... times) (on ... kHz (or MHz))? --or-- Will you request ... to send two dashes of ten seconds followed by his call sign (repeated ... times) on ... kHz (or MHz)? / I am going to send two dashes of ten seconds each followed by my call sign (repeated ... times) (on ... kHz (or MHz)). --or-- I have requested ... to send two dashes of ten seconds followed by his call sign (repeated ... times) on ... kHz (or MHz).",
"QTHR": "At the registered location; Chiefly British in voice or writing, Historically - the location in the printed Callbook. Modernly - as given in online government records for my callsign",
"QTH": "What is your position in latitude and longitude (or according to any other indication)? / My position is ... latitude, ... longitude (or according to any other indication).",
"QTI": "What is your TRUE course? / My TRUE course is ... degrees.",
"QTJ": "What is your speed? / My speed is ... knots (or ... kilometres per hour or ... statute miles per hour).",
"QTK": "What is the speed of your aircraft in relation to the surface of the Earth? / The speed of my aircraft in relation to the surface of the Earth is ... knots (or ... kilometres per hour or ... statute miles per hour).",
"QTL": "What is your TRUE heading? / My TRUE heading is ... degrees.",
"QTM": "What is your MAGNETIC heading? / My MAGNETIC heading is ... degrees.",
"QTN": "At what time did you depart from ... (place)? / I departed from ... (place) at ... hours.",
"QTO": "Have you left dock (or port)? --or-- Are you airborne? / I have left dock (or port). --or-- I am airborne.",
"QTP": "Are you going to enter dock (or port)? --or-- Are you going to alight (or land)? / I am going to enter dock (or port). --or-- I am going to alight (or land).",
"QTQ": "Can you communicate with my station by means of the International Code of Signals (INTERCO)? / I am going to communicate with your station by means of the International Code of Signals (INTERCO).",
"QTR": "What is the correct time? / The correct time is ... hours.",
"QTS": "Will you send your call sign (and/or name) for ... seconds? / I will send my call sign (and/or name) for ... seconds.",
"QTT": "The identification signal which follows is superimposed on another transmission.",
"QTU": "What are the hours during which your station is open? / My station is open from ... to ... hours.",
"QTV": "Shall I stand guard for you on the frequency of ... kHz (or MHz) (from ... to ... hours)? / Stand guard for me on the frequency of ... kHz (or MHz) (from ... to ... hours).",
"QTW": "What is the condition of survivors? / Survivors are in ... condition and urgently need ...",
"QTX": "Will you keep your station open for further communication with me until further notice (or until ... hours)? / I will keep my station open for further communication with you until further notice (or until ... hours).",
"QTY": "Are you proceeding to the position of incident and if so when do you expect to arrive? / I am proceeding to the position of incident and expect to arrive at ... hours (on ... (date)).",
"QTZ": "Are you continuing the search? / I am continuing the search for ... (aircraft, ship, survival craft, survivors or wreckage).",
"QUA": "Have you news of ... (call sign)? / Here is news of ... (call sign).",
"QUB": "Can you give me in the following order information concerning: the direction in degrees TRUE and speed of the surface wind; visibility; present weather; and amount, type and height of base of cloud above surface elevation at ... (place of observation)? / Here is the information requested: ... (The units used for speed and distances should be indicated.)",
"QUC": "What is the number (or other indication) of the last message you received from me (or from ... (call sign))? / The number (or other indication) of the last message I received from you (or from ... (call sign)) is ...",
"QUD": "Have you received the urgency signal sent by ... (call sign of mobile station)? / I have received the urgency signal sent by ... (call sign of mobile station) at ... hours.",
"QUE": "Can you speak in ... (language), - with interpreter if necessary; if so, on what frequencies? / I can speak in ... (language) on ... kHz (or MHz).",
"QUF": "Have you received the distress signal sent by ... (call sign of mobile station)? / I have received the distress signal sent by ... (call sign of mobile station) at ... hours.",
"QUG": "Will you be forced to alight (or land)? / I am forced to alight (or land) immediately. --or-- I shall be forced to alight (or land) at ... (position or place) at ... hours.",
"QUH": "Will you give me the present barometric pressure at sea level? / The present barometric pressure at sea level is ... (units).",
"QUI": "Are your navigation lights working? / My navigation lights are working.",
"QUJ": "Will you indicate the TRUE track to reach you (or ...)? / The TRUE track to reach me (or ...) is ... degrees at ... hours.",
"QUK": "Can you tell me the condition of the sea observed at ... (place or coordinates)? / The sea at ... (place or coordinates) is ...",
"QUL": "Can you tell me the swell observed at ... (place or coordinates)? / The swell at ... (place or coordinates) is ...",
"QUM": "May I resume normal working? / Normal working may be resumed.",
"QUN": "When directed to all stations: Will vessels in my immediate vicinity ... (or in the vicinity of ... latitude, ... longitude) please indicate their position, TRUE course and speed? --or-- When directed to a single station: please indicate their position, TRUE course and speed? / My position, TRUE course and speed are ...",
"QUO": "Shall I search for aircraft/ship/survival craft in the vicinity of ... latitude, ... longitude (or according to any other indication)? / Please search for aircraft/ship/survival craft in the vicinity of ... latitude, ... longitude (or according to any other indication).",
"QUP": "Will you indicate your position by searchlight/black smoke trail/pyrotechnic lights? / My position is indicated by searchlight/black smoke trail/pyrotechnic lights.",
"QUQ": "Shall I train my searchlight nearly vertical on a cloud, occulting if possible and, if your aircraft is seen, deflect the beam up wind and on the water (or land) to facilitate your landing? / Please train your searchlight on a cloud, occulting if possible and, if my aircraft is seen or heard, deflect the beam up wind and on the water (or land) to facilitate my landing.",
"QUR": "Have survivors received survival equipment/been picked up by rescue vessel/been reached by ground rescue party? / Survivors are in possession of survival equipment dropped by ... / have been picked up by rescue vessel/have been reached by ground rescue party.",
"QUS": "Have you sighted survivors or wreckage? / If so, in what position? / Have sighted ... survivors in water/survivors on rafts/wreckage in position ... latitude, ... longitude (or according to any other indication).",
"QUT": "Is position of incident marked? / Position of incident is marked by flame or smoke float/sea marker/sea marker dye/... (specify other marking).",
"QUU": "Shall I home ship or aircraft to my position? / Home ship or aircraft ... (call sign) ... to your position by transmitting your call sign and long dashes on ... kHz (or MHz)/by transmitting on ... kHz (or MHz) TRUE track to reach you.",
"QUW": "Are you in the search area designated as ... (designator or latitude and longitude)? / I am in the ... (designation) search area.",
"QUX": "Do you have any navigational warnings or gale warnings in force? / I have the following navigational warning(s) or gale warning(s) in force: ...",
"QUY": "Is position of survival craft marked? / Position of survival craft was marked at ... hours by flame or smoke float/sea marker/sea marker dye/... (specify other marking).",
"QUZ": "May I resume restricted working? / Distress phase still in force; restricted working may be resumed.",
"QZZ": "Daily key change about to take place (German WWII usage)."
}

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@ debug = False
# A tuple of user IDs that should be considered "bot owners".
# * Those users will have full control over the bot.
# ! This MUST be a tuple of integers. Single element tuple: `(123,)`
owners_uids = (200102491231092736,)
owners_uids = (200102491231092736, 564766093051166729)
# The extensions to load when running the bot.
exts = [
@ -46,6 +46,9 @@ exts = [
"propagation",
]
# URL to the resources
resources_url = "https://qrmresources.miaow.io/resources/"
# If True (default): when doing QRZ callsign lookups, show the nickname in place of the first name, if it exists
# if False: use QRZ's default name format
qrz_only_nickname = True

View File

@ -0,0 +1,86 @@
"""
Resources manager for qrm2.
---
Copyright (C) 2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
"""
from pathlib import Path
import requests
from utils.resources_models import Index
class ResourcesManager:
def __init__(self, basedir: Path, url: str, versions: dict):
self.basedir = basedir
self.url = url
self.versions = versions
self.index: Index = self.sync_start(basedir)
def parse_index(self, index: str):
"""Parses the index."""
return Index.parse_raw(index)
def sync_fetch(self, filepath: str):
"""Fetches files in sync mode."""
self.print_msg(f"Fetching {filepath}", "sync")
with requests.get(self.url + filepath) as resp:
return resp.content
def sync_start(self, basedir: Path) -> Index:
"""Takes cares of constructing the local resources repository and initialising the RM."""
self.print_msg("Initialising ResourceManager", "sync")
self.ensure_dir(basedir)
try:
raw = self.sync_fetch("index.json")
new_index: Index = self.parse_index(raw)
with (basedir / "index.json").open("wb") as file:
file.write(raw)
except (requests.RequestException, OSError) as ex:
self.print_msg(f"There was an issue fetching the index: {ex.__class__.__name__}: {ex}", "sync")
if (basedir / "index.json").exists():
self.print_msg("Old file exist, using old resources", "fallback")
with (basedir / "index.json").open("r") as file:
old_index = self.parse_index(file.read())
for res, ver in self.versions.items():
for file in old_index[res][ver]:
if not (basedir / file.filename).exists():
self.print_msg(f"Error: {file.filename} is missing", "fallback")
raise SystemExit(1)
return old_index
raise SystemExit(1)
for res, ver in self.versions.items():
for file in new_index[res][ver]:
try:
with (basedir / file.filename).open("wb") as f:
f.write(self.sync_fetch(file.filename))
except (requests.RequestException, OSError) as ex:
ex_cls = ex.__class__.__name__
self.print_msg(f"There was an issue fetching {file.filename}: {ex_cls}: {ex}", "sync")
if not (basedir / file.filename).exists():
raise SystemExit(1)
self.print_msg("Old file exists, using it", "fallback")
return new_index
def ensure_dir(self, basedir: Path) -> bool:
"""Ensures that the resources/ directory is present. Creates as necessary."""
if basedir.is_file():
raise FileExistsError(f"'{basedir}' is not a directory!")
if not basedir.exists():
self.print_msg("Creating resources directory")
basedir.mkdir()
return True
return False
def print_msg(self, msg: str, mode: str = None):
"""Formats and prints messages for the resources manager."""
message = "RM: "
message += msg
if mode:
message += f" ({mode})"
print(message)

63
utils/resources_models.py Normal file
View File

@ -0,0 +1,63 @@
"""
Resource index models for qrm2.
---
Copyright (C) 2021 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
"""
from collections.abc import Mapping
from datetime import datetime
from pydantic import BaseModel
class File(BaseModel):
filename: str
hash: str
# For some reason those were not the same???
def __str__(self) -> str:
return repr(self)
class Resource(BaseModel, Mapping):
# 'A Beautiful Hack' https://github.com/samuelcolvin/pydantic/issues/1802
__root__: dict[str, list[File]]
def __getitem__(self, key: str) -> list[File]:
return self.__root__[key]
def __iter__(self):
return iter(self.__root__)
def __len__(self) -> int:
return len(self.__root__)
# For some reason those were not the same???
def __str__(self) -> str:
return repr(self)
# Make the repr more logical (despite the technical inaccuracy)
def __repr_args__(self):
return self.__root__.items()
class Index(BaseModel, Mapping):
last_updated: datetime
resources: dict[str, Resource]
def __getitem__(self, key: str) -> Resource:
return self.resources[key]
def __iter__(self):
return iter(self.resources)
def __len__(self) -> int:
return len(self.resources)
# For some reason those were not the same???
def __str__(self) -> str:
return repr(self)