152 Commits

Author SHA1 Message Date
classabbyamp 6074f5bc45 Merge pull request #315 from miaowware/release-2.5.1
Release 2.5.1
2020-12-10 17:46:24 -05:00
Abigail G 23ca74253d prep for release 2.5.1 2020-12-10 17:43:58 -05:00
Abigail G af68be2b2a add changelog for reaction intent fix 2020-12-10 17:41:41 -05:00
0x5c 2ae11058b2 Merge pull request #314 from miaowware/fixgl
Addded a "nonce" to the greyline URL to force discord to reload the c…
2020-12-10 17:40:06 -05:00
0x5c eba8eec5ac Add nonce to greyline URL to force cache bypass
Fixes #308
2020-12-10 17:38:10 -05:00
classabbyamp d6e381efec add reactions intent (#313)
fixes #312
2020-12-10 09:07:30 -05:00
0x5c 940f45f4d4 Merge pull request #305 from miaowware/changelog
Bump version 2.5.0 + changelog
2020-10-31 21:10:52 -04:00
0x5c be7e29b387 Bump version 2.5.0 + changelog 2020-10-31 21:08:44 -04:00
0x5c 518ead9ccd Merge pull request #304 from miaowware/maps-plans-ordering
Re-ordered the maps and plans
2020-10-31 21:05:03 -04:00
0x5c 6e5acba6e9 Re-ordered the maps and plans
Maps:
Followed order (all alphabetic) countrycode, ITU, other organisations.

Plans:
Followed countrycode (alphabetic).

Fixes #292
2020-10-31 20:56:39 -04:00
classabbyamp ad50a86f9d Merge pull request #291 from miaowware/moar-bandcharts
add australian and italian band charts
2020-10-31 20:34:38 -04:00
classabbyamp 0bfa0c6e41 Merge branch 'master' into moar-bandcharts 2020-10-31 20:28:18 -04:00
0x5c ce64d882b8 Merge pull request #303 from miaowware/pr221
[Compressed] Japan and Nederlands Bandplan Update (#221)
2020-10-31 20:26:14 -04:00
0x5c 0aac09f3bc [Compressed] Japan and Nederlands Bandplan Update (#221)
PR originally by MadIceTea

note: will take care of miaowware/qrm-resources#5 once applied there

Co-authored-by: Alexander Wiegman (Taniguchi) <7548448+MadIceTea@users.noreply.github.com>
Co-authored-by: MadIceTea <7548448+MadIceTea@users.noreply.github.com>
2020-10-31 20:08:01 -04:00
0x5c e3534d02d7 Merge pull request #302 from miaowware/cl-gl
Add missing changelog entry for greyline fix
2020-10-30 09:10:11 -04:00
0x5c cdcb0e17d2 Add missing changelog entry for greyline fix 2020-10-30 09:09:13 -04:00
0x5c cd2503c953 Merge pull request #300 from miaowware/paths
Moved paths to pathlib
2020-10-30 08:58:16 -04:00
0x5c b4c165851c Merge pull request #298 from miaowware/intents
Changed the intents and member cache
2020-10-30 08:57:57 -04:00
0x5c 77a5af73bc Merge pull request #297 from miaowware/no-dl
Switch to sending an URL instead of fetching images
2020-10-30 08:57:44 -04:00
0x5c 4b7064cad9 Merge pull request #301 from miaowware/ihaveocd
Yes, this is a PR to remove a newline
2020-10-30 08:49:55 -04:00
0x5c d8fe3cfa02 Yes, this is a PR to remove a newline
Yes, I have OCD

Yes, I made an issue just for that too
Fixes #299
2020-10-30 07:18:58 -04:00
0x5c ffc3be7e24 Moved paths to pathlib
Turns out most paths were already using pathlib, only remained
some in lookup.py and fun.py

Fixes #45
2020-10-30 07:07:56 -04:00
0x5c 5dab93b7d3 Changed the intents and member cache
- Now only intents GUILDS, GUILD_MESSAGES, DIRECT_MESSAGES.
- Member cache now from intents.

Fixes #296
2020-10-30 06:14:14 -04:00
0x5c e660b1a8f5 Switch to sending an URL instead of fetching images
This only applies to images that were downloaded.
Images that are hosted in the bot are not affected.

Fixes #230
Fixes #295
2020-10-30 05:22:16 -04:00
Abigail G 3d96a43c50 add australian and italian band charts
fixes #225
fixes #242
2020-10-29 00:52:44 -04:00
0x5c e8bb18ea8c Merge pull request #290 from miaowware/error
Fixed numerous small potential bugs
2020-10-28 23:33:58 -04:00
0x5c 19952396f2 Fixed numerous small potential bugs
- Most are typing related

Fixes #289
2020-10-28 23:22:28 -04:00
0x5c 1831c56f58 Merge pull request #286 from miaowware/unpin
Unpinned the versions of most dependencies
2020-10-28 21:06:47 -04:00
classabbyamp 77e14a109c convert Unit into a dataclass, move parse to converter (#257)
fixes #256
2020-10-28 21:06:30 -04:00
classabbyamp 2ac13346d4 Merge pull request #276 from miaowware/release-fixes
Release fixes
2020-10-28 21:05:58 -04:00
classabbyamp 2eea7dce23 move CallsignInfoData to resources/callsign_info (#258)
fixes #255
2020-10-28 21:04:14 -04:00
classabbyamp f26a7af928 fixed qsl/lotw status being incorrectly shown (#278)
fixes #277
2020-10-28 21:03:41 -04:00
classabbyamp 786440edcb Merge pull request #281 from miaowware/efix-docker-workflow 2020-10-28 21:01:32 -04:00
0x5c c47d211016 Unpinned the versions of most stuff, made the remaining version pinning less strict 2020-10-28 11:31:10 -04:00
Abigail G 855935a26e outputs can't be shared between jobs :oof: 2020-10-11 14:47:25 -04:00
classabbyamp ff9d46f379 add deploy workflow job (#280)
Fixes #279
2020-10-11 14:42:09 -04:00
classabbyamp 0f0c3bf723 fix variables not working correctly
Fixes #275
2020-10-06 23:44:58 -04:00
classabbyamp 7c818cfb34 fix tag bug in release workflow
progress on #275
2020-10-06 22:58:20 -04:00
0x5c 27863ae6bf Merge pull request #274 from miaowware/e-release
Bump version+changelog 2.4.1
2020-10-06 19:36:37 -04:00
classabbyamp de999bc39d fix error in workflow (#273) 2020-10-06 19:31:19 -04:00
0x5c 80d80ab718 Bump version+changelog 2.4.1 2020-10-06 19:26:57 -04:00
classabbyamp 8cb1a8df15 update docker documentation to remove docker hub mentions (#265)
Fixes #263
2020-10-06 19:17:02 -04:00
classabbyamp fa2dded81b Merge pull request #272 from miaowware/worflows-updates
add/update workflows
2020-10-06 19:16:13 -04:00
Abigail G bda0540fa8 add/update workflows
Fixes #270
Fixes #271
2020-10-06 19:13:00 -04:00
0x5c c9510ad9b9 Merge pull request #269 from miaowware/newcrap
Made bot work with new Intents system + only cache needed things
2020-10-06 19:01:46 -04:00
0x5c 00f9929deb Made bot work with new Intents system + only cache needed things
- all in one
- Bumped discord.py to 1.5.0

Fixes #267
Fixes #268
2020-10-06 18:56:45 -04:00
classabbyamp 3597367046 Create developer guide, remove issue/pr templates (#260)
* Create developer guide
* remove issue templates (they are in miaowware/.github now)
2020-10-04 22:29:00 -04:00
classabbyamp 7e35e8949a release v2.4.0 (#254) 2020-09-27 18:03:52 -04:00
classabbyamp 77b572eb3e add a decibel conversion command (#250)
fixes #231
2020-09-27 17:52:52 -04:00
classabbyamp be042a9641 add dev targets to makefile (#252)
fixes #251
2020-09-27 16:52:37 -04:00
classabbyamp 488ae6cc98 fix displaying multiple prefixes, add option to display ?help in status (#249)
* fix displaying multiple prefixes, add option to display ?help in status
Fixes #229

Co-authored-by: 0x5c <dev@0x5c.io>
2020-09-27 16:36:39 -04:00
classabbyamp a65fd04dbd add cq zone, itu zone and region, canadian maps (#248)
* add cq zone, itu zone and region, canadian maps
* update arrl/rac maps
* add attribution to all maps

Fixes #112
Progress on #130

Co-authored-by: 0x5c <dev@0x5c.io>
2020-09-27 16:30:59 -04:00
classabbyamp 6329718d29 Contribution and PR Guidelines (#219)
* Create pull_request_template.md
* add contribution guidelines

fixes #160
2020-09-27 16:18:09 -04:00
classabbyamp 756a15c4c5 added ?worksplit command (#247)
fixes #233
2020-09-27 16:07:21 -04:00
classabbyamp b462527211 add canadian callsign info, improve the prefix info data system
fixes #243
2020-09-24 19:02:12 -04:00
0x5c 93b42e64dc Merge pull request #240 from miaowware/dev-requirements.txt
Add dev-requirements.txt
2020-09-24 10:23:26 -04:00
classabbyamp f6103ef6f1 Merge pull request #245 from miaowware/dockerumentation-v2 2020-09-24 10:18:27 -04:00
Abigail G 090b96482d update docker documentation to mention github registry
also corrected a couple errors
fixes #212
2020-09-24 00:14:45 -04:00
0x5c 6d71974ea1 Add dev-requirements.txt
- Various dev tools like mypy, flake8, and discord.py typing stubs
2020-09-08 03:44:24 -04:00
Abigail Gold 0af82ac241 pin dependency versions (#239) 2020-07-23 00:05:32 -04:00
0x5c 2ba6249b90 Merge pull request #223 from miaowware/action-update
Update linting action
2020-04-19 21:25:08 -04:00
0x5c 2c11dad358 Update linting action
Should now run on PR
2020-04-19 21:10:34 -04:00
Abigail 5f796d479e bump version to 2.3.1 2020-04-02 23:04:29 -04:00
Abigail Gold 3ba55d4c35 update funetics words list (#218)
Fixes #217
2020-04-02 23:02:19 -04:00
Abigail f4ed93dc76 bump version to 2.3.0 2020-03-30 19:00:38 -04:00
Abigail Gold 2cb4b03532 add phonetic weight command (#215)
Fixes #170

Co-authored-by: 0x5c <dev@0x5c.io>
2020-03-30 18:56:29 -04:00
Abigail Gold bc93462c29 convert all OrderedDicts to dictionaries (#214)
Fixes #184

Co-authored-by: 0x5c <dev@0x5c.io>
2020-03-30 18:54:33 -04:00
Abigail Gold 6867c45c8c add ?standards command for xkcd 927 (#213)
Fixes #187
2020-03-30 18:24:50 -04:00
Abigail dcbb7acab8 bump release to 2.2.3 2020-03-29 12:34:58 -04:00
Abigail Gold 3803ce6045 add git commit hash to file "git_commit" for automatically-built docker images (#211) 2020-03-29 12:34:12 -04:00
Abigail Gold 8ca4911072 make commands case-insensitive (#210)
Fixes #209
2020-03-28 19:07:23 -04:00
Abigail Gold 6e2468f04f create github action for docker image creation and publication (#206) 2020-03-28 18:18:29 -04:00
0x5c b17a8a1749 Merge pull request #207 from miaowware/bumpversion
Bump version + changelog (2.2.2)
2020-02-25 21:44:35 -05:00
0x5c 8dfa7001ef Bump version + changelog (2.2.2)
- CL: fixed missing 2.2.1 link
2020-02-25 21:41:36 -05:00
0x5c f6ed8430b9 Merge pull request #205 from miaowware/fix-typing
Added/fixed/removed typing managers
2020-02-25 20:57:07 -05:00
0x5c d650cbd6c1 Removed lint 2020-02-25 20:44:53 -05:00
0x5c 4d9f9d1b19 Added/fixed/removed typing managers
Fixes #167
2020-02-25 20:36:21 -05:00
0x5c 1c649aacc2 Merge pull request #204 from miaowware/fix-studyimg
Fix HamStudy image error
2020-02-25 19:51:03 -05:00
0x5c 2049ca9fca Fix HamStudy image error
- Fixed the image link
- Removed unused import (pytz)
- Added test pool file to dev-notes

Fixes #203
2020-02-25 19:45:32 -05:00
Abigail 38416d9050 whoopsie 2020-02-20 20:02:45 -05:00
Abigail G 8dcdc22fe4 Merge pull request #202 from miaowware/hamstudy-extra-fix
fix offset-naive and offset-aware datetime conflict
2020-02-20 20:02:07 -05:00
Abigail c57056e586 fix offset-naive and offset-aware datetime conflict
Fixes #201
2020-02-20 01:32:17 -05:00
Abigail G b281122d41 bump version in info.py 2020-02-15 07:55:16 -05:00
Abigail fa1cc16c6f update changelog for v2.2.0 release 2020-02-15 06:35:07 -05:00
Abigail dfd9479e0d changelog for org migration 2020-02-15 06:30:34 -05:00
Abigail 4b122518f5 migrate classabbyamp/discord-qrm2 to miaowware/qrm2 2020-02-15 06:27:48 -05:00
Abigail Gold 0e28366265 Merge pull request #200 from classabbyamp/pfx-comma
remove extra comma in pfx invalid input handler
2020-02-15 06:02:13 -05:00
Abigail 9471eaa3cb remove extra comma in pfx invalid input handler 2020-02-15 05:58:57 -05:00
0x5c 27c290cff8 Merge pull request #199 from classabbyamp/5c-newyearlint
New year linting
2020-02-15 05:53:48 -05:00
0x5c 58878352aa New year lint removal
Fixes #142
2020-02-15 05:23:46 -05:00
0x5c af136c3d3e Cleaned up description of commands
- Formatting and wording

Element of #142
New year lint removal
2020-02-15 04:59:25 -05:00
0x5c 9ef4864d15 Removed unused f-strings
- f"" -> ""

Element of #142
New year lint removal
2020-02-05 07:30:14 -05:00
0x5c 6803b058d5 Reordered imports
- stdlib
- 3rd-party (pip)
- discord
- local (common, info, utils, & resources)
- data

Element of #142
New year lint removal
2020-02-05 07:09:08 -05:00
0x5c e37fdf40fb Block-style line continuations for data, part 2
- Forgot 'qcodes.py' in the first commit

Element of #142
New year lint removal
2020-01-31 07:04:20 -05:00
0x5c fdfc8cce06 Copyright headers cleanup
Element of #142
New year lint removal
2020-01-31 06:50:50 -05:00
0x5c 56b74108eb Block-style line continuations for data
Element of #142
New year lint removal
2020-01-30 06:55:11 -05:00
0x5c 29d0440d3d Normalised string quote type
- "" instead of '', except for dictionary lookups in f-strings

Element of #142
New year lint removal
2020-01-30 06:15:42 -05:00
Abigail Gold 29e75c38e1 Merge pull request #178 from classabbyamp/help-checks
Verify checks in help commands
2020-01-28 22:49:53 -05:00
Abigail 6c32dcbead fix can_run logic, re-hide xd, remove unnecessary checks 2020-01-28 22:45:10 -05:00
0x5c 74327378b9 Merge pull request #183 from classabbyamp/5c-errhandling
Improved error handling in commands
2020-01-28 05:51:12 -05:00
Abigail Gold c1d3c63503 Merge branch 'master' into help-checks 2020-01-28 01:23:51 -05:00
Abigail 6768a1e01d Merge branch 'help-checks' of github.com:classabbyamp/discord-qrm2 into help-checks 2020-01-28 01:21:40 -05:00
Abigail ea508d2a59 remove unnecessary categories 2020-01-28 01:19:21 -05:00
Abigail Gold f56efd3410 Merge pull request #180 from classabbyamp/restart-shut-aliases
add aliases to restart and shutdown commands
2020-01-27 00:46:59 -05:00
0x5c 976b3e8bf3 Improved error handling in commands
- Changed all "status != 200" to raise a custom exception
- Raise appropriate exceptions in 'grid'
- Removed command-specific error handling in 'extctl' commands

Fixes #146
2020-01-27 00:37:52 -05:00
Abigail Gold 0b4204dc13 add aliases to restart and shutdown commands
Fixes #179
2020-01-24 20:15:28 -05:00
Abigail Gold 8686b0ef96 Merge branch 'master' into help-checks 2020-01-21 22:34:59 -05:00
Abigail Gold 9113638b67 Merge pull request #177 from classabbyamp/hamstudy-refactor
Hamstudy refactor
2020-01-21 22:26:49 -05:00
Abigail 831667ec10 helpcommand now verifies checks when displaying help
Additionally:
- added admin category
- removed hidden flag from commands
- added checks to all extctl commands

Fixes #109
2020-01-21 22:21:30 -05:00
Abigail b64c7ee39a damn you flake8 2020-01-21 20:31:13 -05:00
Abigail 528307f22f updated changelog for hamstudy refactor 2020-01-21 20:25:37 -05:00
Abigail 09c58f9ba2 removed hamstudyanswer command and replaced it with using reactions to
answer questions.

Fixes #169
2020-01-21 19:48:19 -05:00
Abigail Gold 61f0c9423e WIP: help command checks 2020-01-20 20:52:22 -05:00
Abigail Gold b6f6d0408c WIP: answer hamstudy by reaction 2020-01-20 20:50:55 -05:00
0x5c 94f9865103 Merge pull request #175 from classabbyamp/5c-sendlogic
Fixed bad file/embed sending logic in multiple commands
2020-01-20 17:53:56 -05:00
0x5c 08ca455895 Merge pull request #176 from classabbyamp/5c-fixnotfound
Mini-fix: extraneous warning reaction on messages starting with "??"
2020-01-20 17:53:39 -05:00
0x5c 925a05aafb Mini-fix: extraneous warning emoji reaction on messages starting with "??"
- also taken care of: "?!"
2020-01-20 03:49:03 -05:00
0x5c 12886fad89 Fixed bad file/embed sending logic in multiple commands
-> image/*, weather/*
- Addressed #167 for those commands
- weather/greyline: moved gl_url to the class

Fixes #139
Touches #167
2020-01-20 03:17:50 -05:00
Abigail Gold ce107f5a82 Merge pull request #162 from classabbyamp/ae7q-refactor
refactor ae7q call, add other ae7q query types
2020-01-17 17:57:12 -05:00
0x5c 0aa5e6ebd6 Merge pull request #173 from bruceyang1998/patch-1
Fixed issue #172
2020-01-17 17:53:25 -05:00
Bruce Yang 671b0e9ee5 Fixed issue #172 2020-01-17 00:30:08 -05:00
Abigail Gold 776ff72581 add ability to use any pool for hamstudy command
Fixes #28
2020-01-13 14:06:26 -05:00
Abigail Gold 58c69f5aeb add typing context to ae7q commands 2020-01-08 17:47:34 -05:00
Abigail Gold 2c3535d99e update changelog for additional ae7q commands
Fixes #95
2020-01-08 17:18:53 -05:00
Abigail Gold 04cbc920ce add ae7q licensee command
Progress on #95
2020-01-08 17:07:02 -05:00
Abigail Gold f5a9b0b780 Merge branch 'master' into ae7q-refactor 2020-01-08 16:33:07 -05:00
Abigail Gold eb5e038624 add ae7q frn command
ae7q applications is WIP, and is commented out. There is also an
applications table on the FRN page, which could be used in the future

Progress on #95
2020-01-08 16:20:52 -05:00
Abigail Gold 1a1b4c9329 Merge pull request #166 from classabbyamp/5c-extctl-alias
Added aliases for extctl and subcommands
2020-01-08 03:55:51 -05:00
0x5c 8db13755bc Added aliases for extctl and subcommands
Fixes #164
2020-01-08 03:47:00 -05:00
0x5c ac740ee679 Merge pull request #165 from classabbyamp/5c-converter
echo: New converters for arguments
2020-01-08 02:27:01 -05:00
0x5c 0608a74e6c echo: New converters for arguemnts
- Created a GlobalChannelConverter
- Accepts Union[GlobalChannelConverter, UserConverter]

Fixes #145
2020-01-08 02:19:35 -05:00
Abigail Gold eaa47fc724 add ae7q trustee command, add short aliases for ae7q subcommands, bugfixes in ae7q call
Progress on #95
Fixes #153
2020-01-07 15:49:48 -05:00
0x5c 60764cd733 Merge pull request #163 from classabbyamp/async-session
[FIX] aiohttp DeprecationWarning
2020-01-07 15:39:36 -05:00
0x5c 8bfaaf4af6 [FIX] aiohttp DeprecationWarning
- Passing a connector to Bot()
- Using that connector for sessions in extensions

Fixes #141
2020-01-07 05:36:09 -05:00
Abigail Gold 30455153ba refactor ae7q call, add ae7q c alias
Process on #95
2020-01-07 04:28:51 -05:00
Abigail Gold d9bd3d354c Merge pull request #161 from classabbyamp/copyright-update
update copyright for the new year
2020-01-07 03:45:41 -05:00
Abigail Gold 8f15feab94 update copyright for nuevo ans
Fixes #150
2020-01-06 23:27:48 -05:00
Abigail Gold 4e73fa3734 Merge pull request #159 from classabbyamp/qrz-trustee
add trustee field to qrz
2020-01-04 17:17:09 -05:00
Abigail Gold 5e33a6aca6 add trustee field to qrz
Fixes #154
2020-01-04 17:14:41 -05:00
Abigail Gold 07fd9255e0 Merge pull request #158 from classabbyamp/ae7q-bugfixes
Ae7q bugfixes
2020-01-04 16:59:48 -05:00
Abigail Gold 238cdf1c72 Merge branch 'master' into ae7q-bugfixes 2020-01-04 16:59:05 -05:00
Abigail Gold 25eae1fc0f Merge pull request #157 from classabbyamp/clog-arg
changed changelog command to accept a version as argument
2020-01-04 16:57:29 -05:00
Abigail Gold f4f034abfe Merge branch 'master' into clog-arg 2020-01-04 16:56:57 -05:00
Abigail Gold ae673f7026 Merge pull request #155 from classabbyamp/qrz-link
add --link flag to only link the qrz page (rather than embed)
2020-01-04 16:56:02 -05:00
Abigail Gold 8a9c8cbd43 update changelog for qrz --link 2020-01-04 16:38:52 -05:00
Abigail Gold b94a8d42dd update docstring for changelog command 2020-01-04 16:37:37 -05:00
Abigail Gold 60f8e80b82 Fixed issue where incorrect table was parsed in ae7q call
Fixes #152
2020-01-04 16:33:49 -05:00
0x5c 6e516a12db Merge pull request #156 from classabbyamp/pfx-cat
add category to prefixes command
2020-01-04 15:58:46 -05:00
Abigail Gold 9552a7f6d4 Fixed ditto marks appearing in ae7q call
Fixes #151
2020-01-04 15:40:40 -05:00
Abigail Gold e7baca453c changed changelog command to accept a version as argument
Fixed version numbering and typo in CHANGELOG

Fixes #116
2020-01-04 15:24:33 -05:00
Abigail Gold 673d154b94 add category to prefixes command
Fixes #148
2020-01-04 14:46:40 -05:00
Abigail Gold 118d5e0b63 add --link flag to only link the qrz page (rather than embed) 2020-01-04 14:40:08 -05:00
56 changed files with 2715 additions and 45531 deletions
-29
View File
@@ -1,29 +0,0 @@
---
name: Bug report
about: Report a bug to help us improve qrm
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Run command '...' with input '...'
2. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**System (include if related to running the bot):**
- OS: [e.g. Linux, Docker]
- Version: [e.g. 22]
**Additional context**
Add any other context about the problem here.
-20
View File
@@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for qrm
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
+67
View File
@@ -0,0 +1,67 @@
# vim: ts=2 sw=2:
name: Docker Build and Deploy
on:
push:
# Publish `master` as Docker `dev` image.
branches:
- master
# Publish `v*` tags as x.x.x images and as `latest`.
tags:
- v*
env:
IMAGE_NAME: qrm2
jobs:
docker:
name: Build and push docker images
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Write ref to file
run: git rev-list -n 1 $GITHUB_REF > ./git_commit
- name: Build image
run: docker build . --file Dockerfile -t $IMAGE_NAME
- name: Log into Github Package Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Tag image
id: tag_image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
echo IMAGE_ID=$IMAGE_ID
echo ::set-output name=image_id::$IMAGE_ID
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# if version is master, set version to dev
[[ "$VERSION" == "master" ]] && VERSION=dev
echo VERSION=$VERSION
echo ::set-output name=version::$VERSION
# tag dev or x.x.x
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
# tag latest if not a dev release
[[ "$VERSION" != "dev" ]] && docker tag $IMAGE_NAME $IMAGE_ID:latest || true
- name: Push images to registry
run: docker push ${{ steps.tag_image.outputs.image_id }}
- name: Deploy official images
id: deploy_images
uses: satak/webrequest-action@v1
with:
url: ${{ secrets.DEPLOY_URL }}
method: POST
headers: '{"Authentication": "Token ${{ secrets.DEPLOY_TOKEN }}"}'
payload: '{"version": "${{ steps.tag_image.outputs.version }}"}'
+1 -1
View File
@@ -1,6 +1,6 @@
name: Linting name: Linting
on: [push] on: [push,pull_request]
jobs: jobs:
flake8_py3: flake8_py3:
+62
View File
@@ -0,0 +1,62 @@
# vim: ts=2 sw=2:
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
jobs:
release:
name: Create Release
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Get Version Info
id: get_tag
shell: bash
run: |
SUBJECT=$(/usr/bin/git tag -l ${GITHUB_REF#refs/tags/} --format='%(subject)')
BODY=$(/usr/bin/git tag -l ${GITHUB_REF#refs/tags/} --format='%(body)' | sed '/-----BEGIN PGP SIGNATURE-----/,$d')
echo "SUBJECT=$SUBJECT"
echo "BODY=$BODY"
echo 'tag_subject<<EOS' >> $GITHUB_ENV
echo "$SUBJECT" >> $GITHUB_ENV
echo 'EOS' >> $GITHUB_ENV
echo 'tag_body<<EOB' >> $GITHUB_ENV
echo "$BODY" >> $GITHUB_ENV
echo 'EOB' >> $GITHUB_ENV
echo "tag_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version_num=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Get Changelog Content
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ env.version_num }}
path: ./CHANGELOG.md
- name: Publish Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.tag_version }}
release_name: ${{ env.tag_subject }}
body: |
${{ env.tag_body }}
## Changelog
${{ steps.changelog_reader.outputs.changes }}
draft: false
prerelease: false
+2
View File
@@ -9,6 +9,8 @@ cty.zip
/docker-compose.yml /docker-compose.yml
.vscode/
######################################################### #########################################################
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
+107 -7
View File
@@ -7,7 +7,96 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
## [v2.1.0] - 2020-01-04 ## [2.5.1] - 2020-12-10
### Fixed
- The result of `?greyline` was cached by discord and would get out of date.
- Broken reaction functionality in `?hamstudy`.
## [2.5.0] - 2020-10-31
### Added
- Italian (`it_hf`, `it_vhf`, `it_shf`), Japanese (`jp`) and Australian (`au`) band charts.
### Fixed
- Details to the Netherlands bandplan command to accurately represent VERNON (Netherlands ARRL equivalent organisation).
- eQSL, paper QSL, and Logbook of the World status in `?qrz` sometimes being shown incorrectly.
- Fixed network error in `?greyline`.
## [2.4.1] - 2020-10-06
### Changed
- Bumped discord.py to 1.5.0
## [2.4.0] - 2020-09-27
### Added
- Canadian prefix info to the `?prefixes` command.
- `?worksplit` command.
- Maps for CQ Zones, ITU Zones, ITU Regions, and Canadian prefixes.
- Attribution for all maps.
- Option to append ` | ?help` to the playing status.
- `?dbconv` command to convert voltage, power, and antenna gain values.
### Changed
- ARRL/RAC section maps to include all current ARRL/RAC sections.
### Fixed
- Issue where multiple prefixes were not handled properly.
## [2.3.2] - 2020-07-22
### Fixed
- Dependency issues
## [2.3.1] - 2020-04-02
### Fixed
- Wordlist containing innappropriate words.
## [2.3.0] - 2020-03-30
### Added
- `?phoneticweight` command, which calculates a message's length in syllables.
- `?standards` command to display [xkcd 927](https://xkcd.com/927/).
### Changed
- Python>=3.7 now required.
## [2.2.3] - 2020-03-29
### Fixed
- Commands are no longer case-sensitive.
## [2.2.2] - 2020-02-25
### Fixed
- 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
### Fixed
- Fixed issue where some HamStudy pools will become unselectable.
## [2.2.0] - 2020-02-15
### Added
- Added Trustee field to qrz command for club callsigns.
- Added alias for `ae7q call` command (`ae7q c`).
- Added ae7q lookup by FRN and Licensee ID, and for trustee records (`ae7q frn, licensee, trustee`).
### Changed
- Changelog command to accept a version as argument.
- The qrz command can now link to a QRZ page instead of embedding the data with the `--link` flag.
- All currently-available pools can now be accessed by the `hamstudy` command.
- The `hamstudy` command now uses the syntax `?hamstudy <country> <pool>`.
- Replaced `hamstudyanswer` command with answering by reaction.
- Removed all generic error handling from commands.
- Cleaned up the description of multiple commands.
- Updated repository links from classabbyamp/discord-qrm2 to miaowware/qrm2.
### Fixed
- Fixed ditto marks (") appearing in the ae7q call command.
- Fixed issue where incorrect table was parsed in ae7q call command.
- Fixed warning emoji reaction on messages starting with "??".
- Fixed issue where `prefixes` would error when given an invalid argument.
## [2.1.0] - 2020-01-04
### Added ### Added
- New NATO "phonetics" command. - New NATO "phonetics" command.
- Flag emojis to commands with countries. - Flag emojis to commands with countries.
@@ -18,14 +107,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Command linking to the issue tracker. - Command linking to the issue tracker.
- New key in options.py: pika. - New key in options.py: pika.
### Changed ### Changed
- The "phonetics" command is not called "funetics". - The "phonetics" command is now called "funetics".
- All commands now respond in embeds. - All commands now respond in embeds.
- Playing status can now change on a schedule or randomly from a list. - Playing status can now change on a schedule or randomly from a list.
### Fixed ### Fixed
- Fixed incorrect information in the `prefixes` command. - Fixed incorrect information in the `prefixes` command.
## [v2.0.0] - 2019-12-16 ## [2.0.0] - 2019-12-16
### Added ### Added
- Rich lookup for AE7Q.com (callsigns only, more to come) - Rich lookup for AE7Q.com (callsigns only, more to come)
- Rich lookup for QRZ.com, if a QRZ subscription is present - Rich lookup for QRZ.com, if a QRZ subscription is present
@@ -52,9 +141,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Issue in morse and unmorse commands where spaces were not interpreted correctly - Issue in morse and unmorse commands where spaces were not interpreted correctly
## v1.0.0 - 2019-07-31 [YANKED] ## 1.0.0 - 2019-07-31 [YANKED]
[Unreleased]: https://github.com/classabbyamp/discord-qrm2/compare/v2.1.0...HEAD [Unreleased]: https://github.com/miaowware/qrm2/compare/v2.5.1...HEAD
[v2.1.0]: https://github.com/classabbyamp/discord-qrm2/releases/tag/v2.1.0 [2.5.1]: https://github.com/miaowware/qrm2/releases/tag/v2.5.1
[v2.0.0]: https://github.com/classabbyamp/discord-qrm2/releases/tag/v2.0.0 [2.5.0]: https://github.com/miaowware/qrm2/releases/tag/v2.5.0
[2.4.1]: https://github.com/miaowware/qrm2/releases/tag/v2.4.1
[2.4.0]: https://github.com/miaowware/qrm2/releases/tag/v2.4.0
[2.3.2]: https://github.com/miaowware/qrm2/releases/tag/v2.3.2
[2.3.1]: https://github.com/miaowware/qrm2/releases/tag/v2.3.1
[2.3.0]: https://github.com/miaowware/qrm2/releases/tag/v2.3.0
[2.2.3]: https://github.com/miaowware/qrm2/releases/tag/v2.2.3
[2.2.2]: https://github.com/miaowware/qrm2/releases/tag/v2.2.2
[2.2.1]: https://github.com/miaowware/qrm2/releases/tag/v2.2.1
[2.2.0]: https://github.com/miaowware/qrm2/releases/tag/v2.2.0
[2.1.0]: https://github.com/miaowware/qrm2/releases/tag/v2.1.0
[2.0.0]: https://github.com/miaowware/qrm2/releases/tag/v2.0.0
+54
View File
@@ -0,0 +1,54 @@
# Development Guide for qrm
**Make sure to also read [`CONTRIBUTING.md`][0], everything in there applies here.**
### Environment Setup
1. [Fork this repo][1] into your own GitHub namespace.
1. Make sure the `master` branch is up to date, then make yourself a new branch with a descriptive name.
1. Once the forked repo is cloned and on the proper branch, you can set up the development environment.
1. Install python 3.7 or higher.
1. Run `make dev-install`.
This should install everything you need to develop and run qrm.
1. [Create a bot and token][2], and add it to `data/keys.py`.
Also add your [QRZ credentials][3] if needed.
1. In `data/options.py`, change values as needed.
Some commands require adding your Discord user ID to `owner_uids`.
1. To activate the virtual env that was created by `make`, run `source botenv/bin/activate` (or the equivelent for your shell or operating system).
These instructions are fairly \*NIX-centric, so if you would like to develop on Windows, it is suggested that the Windows Subsystem for Linux be used.
## While You Develop
To run qrm, use the command `./run.sh`.
We recommend you use the `--pass-errors` flag to avoid perpetual restart loops if you break the bot.
It exists because repeatedly mashing [Ctrl+C] at high speed to break a fast loop is not fun.
Make sure to add [type hints][4] to your code.
This is what `mypy` validates in the code.
Using `dev-notes` for documentation is especially important if you introduce a new json file format (like for maps and bandplans) or to document some development process (like the command to crush the various images in the repository).
### Test your changes
In addition to testing functionality, make sure to run `flake8` to ensure your code uses the proper style, and `mypy [files...]` to ensure proper typing.
You can also enable them for this project in your IDE if supported.
This will give you automatic and continuous linting and type checking.
### A Note on Style
qrm tries to keep to PEP 8 style whenever possible.
Use the utility `flake8` to check that you follow this style.
When you start a PR or push commits, GitHub will automatically run this for you,
but we prefer that developers check this before committing and opening PRs.
Otherwise, try to follow the existing style:
- double-quotes except when required to be single,
- indentation of mult-line structures matching other examples in the code,
- etc.
[0]: https://github.com/miaowware/.github/blob/master/CONTRIBUTING.md
[1]: https://github.com/miaowware/qrm2/fork
[2]: https://discordpy.readthedocs.io/en/latest/discord.html
[3]: https://www.qrz.com/page/xml_data.html
[4]: https://docs.python.org/3/library/typing.html
+11
View File
@@ -71,6 +71,17 @@ clean:
### Dev targets ### ### Dev targets ###
.PHONY: dev-install
dev-install: $(BOTENV)/dev_req_done data/options.py data/keys.py
# Installing dev requirements
$(BOTENV)/dev_req_done: dev-requirements.txt $(BOTENV)/success
@echo "\033[34;1m--> Installing the dependencies...\033[0m"
@. $(BOTENV)/bin/activate; \
pip install ${PIP_OUTPUT} -U pip setuptools wheel; \
pip install ${PIP_OUTPUT} -U -r dev-requirements.txt
@touch $(BOTENV)/dev_req_done
### Special targets ### ### Special targets ###
+10 -9
View File
@@ -1,6 +1,6 @@
# Docker help for qrm2 # Docker help for qrm2
You have multiple ways to use docker to run an instance of qrm2 You have multiple ways to use docker to run an instance of qrm2.
- [Docker help for qrm2](#docker-help-for-qrm2) - [Docker help for qrm2](#docker-help-for-qrm2)
- [Using docker-compose and the prebuilt-image (recommended)](#using-docker-compose-and-the-prebuilt-image-recommended) - [Using docker-compose and the prebuilt-image (recommended)](#using-docker-compose-and-the-prebuilt-image-recommended)
@@ -23,13 +23,14 @@ This is the easiest method for running the bot without any modifications.
version: '3' version: '3'
services: services:
qrm2: qrm2:
image: "classabbyamp/discord-qrm2:latest" image: "docker.pkg.github.com/miaowware/qrm2/qrm2:latest"
restart: on-failure restart: on-failure
volumes: volumes:
- "./data:/app/data:rw" - "./data:/app/data:rw"
environment: environment:
- PYTHONUNBUFFERED=1 - PYTHONUNBUFFERED=1
``` ```
*Note that Github's registry requires [a few extra steps](https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages) during the initial setup.*
3. Create a subdirectory named `data`. 3. Create a subdirectory named `data`.
@@ -42,7 +43,7 @@ This is the easiest method for running the bot without any modifications.
$ docker-compose up -d $ docker-compose up -d
``` ```
> Run without "-d" to test the bot. (run in foreground) *Run without "-d" to test the bot (run in foreground).*
@@ -59,7 +60,7 @@ This is the easiest method to run the bot with modifications.
services: services:
qrm2: qrm2:
build: . build: .
image: "discord-qrm2:local-latest" image: "qrm2:local-latest"
restart: on-failure restart: on-failure
volumes: volumes:
- "./data:/app/data:rw" - "./data:/app/data:rw"
@@ -75,10 +76,10 @@ This is the easiest method to run the bot with modifications.
```none ```none
$ docker-compose build --pull $ docker-compose build --pull
$ docker-compose -d $ docker-compose up -d
``` ```
> Run without "-d" to test the bot. (run in foreground) *Run without "-d" to test the bot (run in foreground).*
@@ -95,7 +96,7 @@ This methods is not very nice to use.
2. Run docker build: 2. Run docker build:
```none ```none
$ docker build -t discord-qrm2:local-latest . $ docker build -t qrm2:local-latest .
``` ```
@@ -110,5 +111,5 @@ This methods is not very nice to use.
``` ```
Where `[image]` is either of: Where `[image]` is either of:
- `discord-qrm2:local-latest` if you are building your own. - `qrm2:local-latest` if you are building your own.
- `classabbyamp/discord-qrm2:latest` if you want to use the prebuilt image. - `docker.pkg.github.com/miaowware/qrm2/qrm2:latest` if you want to use the prebuilt image.
+7 -1
View File
@@ -14,6 +14,8 @@ See [README-DOCKER.md](./README-DOCKER.md)
### Without Docker ### Without Docker
Requires Python 3.7 or newer.
Prep the environment. For more information on extra options, see the [quick-bot-no-pain Makefile documentation](https://github.com/0x5c/quick-bot-no-pain/blob/master/docs/makefile.md). Prep the environment. For more information on extra options, see the [quick-bot-no-pain Makefile documentation](https://github.com/0x5c/quick-bot-no-pain/blob/master/docs/makefile.md).
``` ```
@@ -26,9 +28,13 @@ Run. For more information on options, see the [quick-bot-no-pain run.sh document
$ run.sh $ run.sh
``` ```
## Contributing
Check out the [contribution guidelines](/CONTRIBUTING.md) for more information about how to contribute to this project.
## Copyright ## Copyright
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This program is released under the terms of the GNU General Public License, This program is released under the terms of the GNU General Public License,
version 2. See `COPYING` for full license text. version 2. See `COPYING` for full license text.
+86 -33
View File
@@ -1,62 +1,79 @@
""" """
Common tools for the bot. Common tools for the bot.
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
---
`colours`: Colours used by embeds.
`cat`: Category names for the HelpCommand.
""" """
import collections import collections
import json import json
import re
import traceback import traceback
from pathlib import Path
from datetime import datetime from datetime import datetime
from pathlib import Path
from types import SimpleNamespace from types import SimpleNamespace
from typing import Union
import aiohttp
import discord import discord
import discord.ext.commands as commands import discord.ext.commands as commands
from discord import Emoji, Reaction, PartialEmoji
import data.options as opt import data.options as opt
__all__ = ["colours", "cat", "emojis", "embed_factory", "error_embed_factory", "add_react", "check_if_owner"] __all__ = ["colours", "cat", "emojis", "paths", "ImageMetadata", "ImagesGroup",
"embed_factory", "error_embed_factory", "add_react", "check_if_owner"]
# --- Common values --- # --- Common values ---
colours = SimpleNamespace(good=0x43B581, colours = SimpleNamespace(
neutral=0x7289DA, good=0x43B581,
bad=0xF04747) neutral=0x7289DA,
bad=0xF04747,
)
# meow # meow
cat = SimpleNamespace(lookup='Information Lookup', cat = SimpleNamespace(
fun='Fun', lookup="Information Lookup",
maps='Mapping', fun="Fun",
ref='Reference', maps="Mapping",
study='Exam Study', ref="Reference",
weather='Land and Space Weather') study="Exam Study",
weather="Land and Space Weather",
admin="Bot Control",
)
emojis = SimpleNamespace(check_mark='', emojis = SimpleNamespace(
x='', check_mark="",
warning='⚠️', x="",
question='', warning="⚠️",
no_entry='', question="",
bangbang='‼️') no_entry="",
bangbang="‼️",
a="🇦",
b="🇧",
c="🇨",
d="🇩",
)
paths = SimpleNamespace(data=Path("./data/"), paths = SimpleNamespace(
resources=Path("./resources/"), data=Path("./data/"),
bandcharts=Path("./resources/img/bandcharts/"), resources=Path("./resources/"),
maps=Path("./resources/img/maps/")) img=Path("./resources/img/"),
bandcharts=Path("./resources/img/bandcharts/"),
maps=Path("./resources/img/maps/"),
)
# --- Classes --- # --- Classes ---
class ImageMetadata: class ImageMetadata:
"""Represents the metadata of a single image.""" """Represents the metadata of a single image."""
def __init__(self, metadata: list): def __init__(self, metadata: list):
@@ -94,12 +111,47 @@ class ImagesGroup(collections.abc.Mapping):
return str(self._images) return str(self._images)
# --- Exceptions ---
class BotHTTPError(Exception):
"""Raised whan a requests fails (status != 200) in a command."""
def __init__(self, response: aiohttp.ClientResponse):
msg = f"Request failed: {response.status} {response.reason}"
super().__init__(msg)
self.response = response
self.status = response.status
self.reason = response.reason
# --- Converters ---
class GlobalChannelConverter(commands.IDConverter):
"""Converter to get any bot-acessible channel by ID/mention (global), or name (in current guild only)."""
async def convert(self, ctx: commands.Context, argument: str):
bot = ctx.bot
guild = ctx.guild
match = self._get_id_match(argument) or re.match(r"<#([0-9]+)>$", argument)
result = None
if match is None:
# not a mention/ID
if guild:
result = discord.utils.get(guild.text_channels, name=argument)
else:
raise commands.BadArgument(f"""Channel named "{argument}" not found in this guild.""")
else:
channel_id = int(match.group(1))
result = bot.get_channel(channel_id)
if not isinstance(result, (discord.TextChannel, discord.abc.PrivateChannel)):
raise commands.BadArgument(f"""Channel "{argument}" not found.""")
return result
# --- Helper functions --- # --- Helper functions ---
def embed_factory(ctx: commands.Context) -> discord.Embed: def embed_factory(ctx: commands.Context) -> discord.Embed:
"""Creates an embed with neutral colour and standard footer.""" """Creates an embed with neutral colour and standard footer."""
embed = discord.Embed(timestamp=datetime.utcnow(), colour=colours.neutral) embed = discord.Embed(timestamp=datetime.utcnow(), colour=colours.neutral)
embed.set_footer(text=ctx.author, icon_url=str(ctx.author.avatar_url)) embed.set_footer(text=str(ctx.author), icon_url=str(ctx.author.avatar_url))
return embed return embed
@@ -111,16 +163,17 @@ def error_embed_factory(ctx: commands.Context, exception: Exception, debug_mode:
fmtd_ex = traceback.format_exception_only(exception.__class__, exception) fmtd_ex = traceback.format_exception_only(exception.__class__, exception)
embed = embed_factory(ctx) embed = embed_factory(ctx)
embed.title = "⚠️ Error" embed.title = "⚠️ Error"
embed.description = "```\n" + '\n'.join(fmtd_ex) + "```" embed.description = "```\n" + "\n".join(fmtd_ex) + "```"
embed.colour = colours.bad embed.colour = colours.bad
return embed return embed
async def add_react(msg: discord.Message, react: str): async def add_react(msg: discord.Message, react: Union[Emoji, Reaction, PartialEmoji, str]):
try: try:
await msg.add_reaction(react) await msg.add_reaction(react)
except discord.Forbidden: except discord.Forbidden:
print(f"[!!] Missing permissions to add reaction in '{msg.guild.id}/{msg.channel.id}'!") idpath = (f"{msg.guild.id}/" if msg.guild else "") + str(msg.channel.id)
print(f"[!!] Missing permissions to add reaction in '{idpath}'!")
# --- Checks --- # --- Checks ---
+4
View File
@@ -0,0 +1,4 @@
# Image processing instructions
For images like bandplans and maps, first resize the image to a reasonable size, then run `pngquant --quality 30-40` on the images.
Do not apply that to non-flat images like actual pictures.
+1 -1
View File
@@ -20,5 +20,5 @@ Used for grouping info such as name, description, source, and such.
| `name` | The name of the file. | `Canada`, `ITU Zones` | | `name` | The name of the file. | `Canada`, `ITU Zones` |
| `long_name` | The long name (title) of the file. | `Worldwide map of ITU Zones` | | `long_name` | The long name (title) of the file. | `Worldwide map of ITU Zones` |
| `description` | The description accompanying the file. | `Full radio allocations chart for all services.` | | `description` | The description accompanying the file. | `Full radio allocations chart for all services.` |
| `source` | The source of the file. | `Instituto Federal de Telecomunicaciones (IFT)` | | `source` | The source of the file. | `Instituto Federal de Telecomunicaciones (IFT)` |
| `emoji` | A Unicode emoji associated with the file. | `📻`, `🇨🇦` | | `emoji` | A Unicode emoji associated with the file. | `📻`, `🇨🇦` |
+48
View File
@@ -0,0 +1,48 @@
{
"_id": "56956f51f65e5c590272e372",
"appears": "2016-04-01T06:00:00.000Z",
"class": "Amateur Extra",
"subtext": "Expires Jul 1, 2020",
"valid_from": "2016-07-01T06:00:00.000Z",
"expires": "2020-07-01T06:00:00.000Z",
"official_name": "Element 4",
"id": "E4_2016",
"slug": "extra2016",
"passing": 37,
"year": 2016,
"pool": [{
"_id": "5cd63f15910d9b003d545bd7",
"qcount": 4,
"id": "E5",
"name": "ELECTRICAL PRINCIPLES",
"sections": [{
"_id": "5cd63f15910d9b003d545beb",
"id": "E5C",
"questions": [{
"_id": "5cd63f15910d9b003d545bef",
"keywords": ["4"],
"answer": "B",
"answers": {
"A": "Point 2",
"B": "Point 4",
"C": "Point 5",
"D": "Point 6"
},
"fccpart": "",
"id": "E5C14",
"image": "E5-2.png",
"text": "Which point on Figure E5-2 best represents the impedance of a series circuit consisting of a 400 ohm resistor and a 38 picofarad capacitor at 14 MHz?"
}],
"summary": "Coordinate systems and phasors in electronics: Rectangular Coordinates; Polar Coordinates; Phasors"
}]
}],
"updated": "2019-05-11T03:18:46.121Z",
"category": "default",
"testIdEnd": 19999,
"testIdStart": 10000,
"__v": 12,
"mat_icon": "flash_on",
"tagline": "Serious General operators only! This is the most advanced US license class!",
"keywords": ["ham radio extra test prep", "amateur extra class radio study", "amateur extra class ham exam", "ham radio amateur extra test 2016", "2016 amateur extra class", "ham radio license exam", "extra class flash card"],
"replaces": "E4_2012"
}
+3
View File
@@ -0,0 +1,3 @@
-r requirements.txt
flake8
discord.py-stubs==1.5.0
+353 -93
View File
@@ -1,135 +1,395 @@
""" """
ae7q extension for qrm ae7q extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
---
Test callsigns:
KN8U: active, restricted
AB2EE: expired, restricted
KE8FGB: assigned once, no restrictions
NA2AAA: unassigned, no records
""" """
import discord.ext.commands as commands
# Test callsigns:
# KN8U: active, restricted
# AB2EE: expired, restricted
# KE8FGB: assigned once, no restrictions
# KV4AAA: unassigned, no records
# KC4USA: reserved, no call history, *but* has application history
import aiohttp
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import discord.ext.commands as commands
import common as cmn import common as cmn
class AE7QCog(commands.Cog): class AE7QCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
self.session = bot.qrm.session self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.group(name="ae7q", aliases=["ae"], category=cmn.cat.lookup) @commands.group(name="ae7q", aliases=["ae"], case_insensitive=True, category=cmn.cat.lookup)
async def _ae7q_lookup(self, ctx: commands.Context): async def _ae7q_lookup(self, ctx: commands.Context):
'''Look up a callsign, FRN, or Licensee ID on [ae7q.com](http://ae7q.com/).''' """Looks up a callsign, FRN, or Licensee ID on [ae7q.com](http://ae7q.com/)."""
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help(ctx.command) await ctx.send_help(ctx.command)
@_ae7q_lookup.command(name="call", category=cmn.cat.lookup) @_ae7q_lookup.command(name="call", aliases=["c"], category=cmn.cat.lookup)
async def _ae7q_call(self, ctx: commands.Context, callsign: str): async def _ae7q_call(self, ctx: commands.Context, callsign: str):
'''Look up the history for a callsign on [ae7q.com](http://ae7q.com/).''' """Looks up the history of a callsign on [ae7q.com](http://ae7q.com/)."""
callsign = callsign.upper() with ctx.typing():
desc = '' callsign = callsign.upper()
base_url = "http://ae7q.com/query/data/CallHistory.php?CALL=" desc = ""
embed = cmn.embed_factory(ctx) base_url = "http://ae7q.com/query/data/CallHistory.php?CALL="
embed = cmn.embed_factory(ctx)
async with self.session.get(base_url + callsign) as resp: async with self.session.get(base_url + callsign) as resp:
if resp.status != 200: if resp.status != 200:
embed.title = "Error in AE7Q call command" raise cmn.BotHTTPError(resp)
embed.description = 'Could not load AE7Q' page = await resp.text()
soup = BeautifulSoup(page, features="html.parser")
tables = [[row for row in table.find_all("tr")] for table in soup.select("table.Database")]
table = tables[0]
# find the first table in the page, and use it to make a description
if len(table[0]) == 1:
for row in table:
desc += " ".join(row.getText().split())
desc += "\n"
desc = desc.replace(callsign, f"`{callsign}`")
table = tables[1]
table_headers = table[0].find_all("th")
first_header = "".join(table_headers[0].strings) if len(table_headers) > 0 else None
# catch if the wrong table was selected
if first_header is None or first_header != "Entity Name":
embed.title = f"AE7Q History for {callsign}"
embed.colour = cmn.colours.bad embed.colour = cmn.colours.bad
embed.url = base_url + callsign
embed.description = desc
embed.description += f"\nNo records found for `{callsign}`"
await ctx.send(embed=embed) await ctx.send(embed=embed)
return return
page = await resp.text()
soup = BeautifulSoup(page, features="html.parser") table = await process_table(table[1:])
tables = soup.select("table.Database")
for table in tables: embed = cmn.embed_factory(ctx)
rows = table.find_all("tr")
if len(rows) > 1 and len(rows[0]) > 1:
break
if desc == '':
for row in rows:
desc += " ".join(row.getText().split())
desc += '\n'
desc = desc.replace(callsign, f'`{callsign}`')
rows = None
if rows is None:
embed.title = f"AE7Q History for {callsign}" embed.title = f"AE7Q History for {callsign}"
embed.colour = cmn.colours.bad embed.colour = cmn.colours.good
embed.url = f"{base_url}{callsign}" embed.url = base_url + callsign
# add the first three rows of the table to the embed
for row in table[0:3]:
header = f"**{row[0]}** ({row[1]})" # **Name** (Applicant Type)
body = (f"Class: *{row[2]}*\n"
f"Region: *{row[3]}*\n"
f"Status: *{row[4]}*\n"
f"Granted: *{row[5]}*\n"
f"Effective: *{row[6]}*\n"
f"Cancelled: *{row[7]}*\n"
f"Expires: *{row[8]}*")
embed.add_field(name=header, value=body, inline=False)
if len(table) > 3:
desc += f"\nRecords 1 to 3 of {len(table)}. See ae7q.com for more..."
embed.description = desc embed.description = desc
embed.description += f'\nNo records found for `{callsign}`'
await ctx.send(embed=embed) await ctx.send(embed=embed)
return
table_contents = [] # store your table here @_ae7q_lookup.command(name="trustee", aliases=["t"], category=cmn.cat.lookup)
for tr in rows: async def _ae7q_trustee(self, ctx: commands.Context, callsign: str):
if rows.index(tr) == 0: """Looks up the licenses for which a licensee is trustee on [ae7q.com](http://ae7q.com/)."""
continue with ctx.typing():
row_cells = [] callsign = callsign.upper()
for td in tr.find_all('td'): desc = ""
if td.getText().strip() != '': base_url = "http://ae7q.com/query/data/CallHistory.php?CALL="
row_cells.append(td.getText().strip()) embed = cmn.embed_factory(ctx)
else:
row_cells.append('-')
if 'colspan' in td.attrs and int(td.attrs['colspan']) > 1:
for i in range(int(td.attrs['colspan']) - 1):
row_cells.append(row_cells[-1])
for i, cell in enumerate(row_cells):
if cell == '"':
cell = table_contents[-1][i]
if len(row_cells) > 1:
table_contents += [row_cells]
embed = cmn.embed_factory(ctx) async with self.session.get(base_url + callsign) as resp:
embed.title = f"AE7Q Records for {callsign}" if resp.status != 200:
embed.colour = cmn.colours.good raise cmn.BotHTTPError(resp)
embed.url = f"{base_url}{callsign}" page = await resp.text()
for row in table_contents[0:3]: soup = BeautifulSoup(page, features="html.parser")
header = f'**{row[0]}** ({row[1]})' tables = [[row for row in table.find_all("tr")] for table in soup.select("table.Database")]
body = (f'Class: *{row[2]}*\n'
f'Region: *{row[3]}*\n'
f'Status: *{row[4]}*\n'
f'Granted: *{row[5]}*\n'
f'Effective: *{row[6]}*\n'
f'Cancelled: *{row[7]}*\n'
f'Expires: *{row[8]}*')
embed.add_field(name=header, value=body, inline=False)
embed.description = desc try:
if len(table_contents) > 3: table = tables[2] if len(tables[0][0]) == 1 else tables[1]
embed.description += f'\nRecords 1 to 3 of {len(table_contents)}. See ae7q.com for more...' except IndexError:
embed.title = f"AE7Q Trustee History for {callsign}"
embed.colour = cmn.colours.bad
embed.url = base_url + callsign
embed.description = desc
embed.description += f"\nNo records found for `{callsign}`"
await ctx.send(embed=embed)
return
await ctx.send(embed=embed) table_headers = table[0].find_all("th")
first_header = "".join(table_headers[0].strings) if len(table_headers) > 0 else None
# TODO: write commands for other AE7Q response types? # catch if the wrong table was selected
# @_ae7q_lookup.command(name="trustee") if first_header is None or not first_header.startswith("With"):
# async def _ae7q_trustee(self, ctx: commands.Context, callsign: str): embed.title = f"AE7Q Trustee History for {callsign}"
# pass embed.colour = cmn.colours.bad
embed.url = base_url + callsign
embed.description = desc
embed.description += f"\nNo records found for `{callsign}`"
await ctx.send(embed=embed)
return
# @_ae7q_lookup.command(name="applications", aliases=['apps']) table = await process_table(table[2:])
# async def _ae7q_applications(self, ctx: commands.Context, callsign: str):
# pass
# @_ae7q_lookup.command(name="frn") embed = cmn.embed_factory(ctx)
# async def _ae7q_frn(self, ctx: commands.Context, frn: str): embed.title = f"AE7Q Trustee History for {callsign}"
# base_url = "http://ae7q.com/query/data/FrnHistory.php?FRN=" embed.colour = cmn.colours.good
# pass embed.url = base_url + callsign
# @_ae7q_lookup.command(name="licensee", aliases=["lic"]) # add the first three rows of the table to the embed
# async def _ae7q_licensee(self, ctx: commands.Context, frn: str): for row in table[0:3]:
# base_url = "http://ae7q.com/query/data/LicenseeIdHistory.php?ID=" header = f"**{row[0]}** ({row[3]})" # **Name** (Applicant Type)
# pass body = (f"Name: *{row[2]}*\n"
f"Region: *{row[1]}*\n"
f"Status: *{row[4]}*\n"
f"Granted: *{row[5]}*\n"
f"Effective: *{row[6]}*\n"
f"Cancelled: *{row[7]}*\n"
f"Expires: *{row[8]}*")
embed.add_field(name=header, value=body, inline=False)
if len(table) > 3:
desc += f"\nRecords 1 to 3 of {len(table)}. See ae7q.com for more..."
embed.description = desc
await ctx.send(embed=embed)
@_ae7q_lookup.command(name="applications", aliases=["a"], category=cmn.cat.lookup)
async def _ae7q_applications(self, ctx: commands.Context, callsign: str):
"""Looks up the application history for a callsign on [ae7q.com](http://ae7q.com/)."""
"""
with ctx.typing():
callsign = callsign.upper()
desc = ""
base_url = "http://ae7q.com/query/data/CallHistory.php?CALL="
embed = cmn.embed_factory(ctx)
async with self.session.get(base_url + callsign) as resp:
if resp.status != 200:
raise cmn.BotHTTPError(resp)
page = await resp.text()
soup = BeautifulSoup(page, features="html.parser")
tables = [[row for row in table.find_all("tr")] for table in soup.select("table.Database")]
table = tables[0]
# find the first table in the page, and use it to make a description
if len(table[0]) == 1:
for row in table:
desc += " ".join(row.getText().split())
desc += "\n"
desc = desc.replace(callsign, f"`{callsign}`")
# select the last table to get applications
table = tables[-1]
table_headers = table[0].find_all("th")
first_header = "".join(table_headers[0].strings) if len(table_headers) > 0 else None
# catch if the wrong table was selected
if first_header is None or not first_header.startswith("Receipt"):
embed.title = f"AE7Q Application History for {callsign}"
embed.colour = cmn.colours.bad
embed.url = base_url + callsign
embed.description = desc
embed.description += f"\nNo records found for `{callsign}`"
await ctx.send(embed=embed)
return
table = await process_table(table[1:])
embed = cmn.embed_factory(ctx)
embed.title = f"AE7Q Application History for {callsign}"
embed.colour = cmn.colours.good
embed.url = base_url + callsign
# add the first three rows of the table to the embed
for row in table[0:3]:
header = f"**{row[1]}** ({row[3]})" # **Name** (Callsign)
body = (f"Received: *{row[0]}*\n"
f"Region: *{row[2]}*\n"
f"Purpose: *{row[5]}*\n"
f"Last Action: *{row[7]}*\n"
f"Application Status: *{row[8]}*\n")
embed.add_field(name=header, value=body, inline=False)
if len(table) > 3:
desc += f"\nRecords 1 to 3 of {len(table)}. See ae7q.com for more..."
embed.description = desc
await ctx.send(embed=embed)
"""
raise NotImplementedError("Application history lookup not yet supported. "
"Check back in a later version of the bot.")
@_ae7q_lookup.command(name="frn", aliases=["f"], category=cmn.cat.lookup)
async def _ae7q_frn(self, ctx: commands.Context, frn: str):
"""Looks up the history of an FRN on [ae7q.com](http://ae7q.com/)."""
"""
NOTES:
- 2 tables: callsign history and application history
- If not found: no tables
"""
with ctx.typing():
base_url = "http://ae7q.com/query/data/FrnHistory.php?FRN="
embed = cmn.embed_factory(ctx)
async with self.session.get(base_url + frn) as resp:
if resp.status != 200:
raise cmn.BotHTTPError(resp)
page = await resp.text()
soup = BeautifulSoup(page, features="html.parser")
tables = [[row for row in table.find_all("tr")] for table in soup.select("table.Database")]
if not len(tables):
embed.title = f"AE7Q History for FRN {frn}"
embed.colour = cmn.colours.bad
embed.url = base_url + frn
embed.description = f"No records found for FRN `{frn}`"
await ctx.send(embed=embed)
return
table = tables[0]
table_headers = table[0].find_all("th")
first_header = "".join(table_headers[0].strings) if len(table_headers) > 0 else None
# catch if the wrong table was selected
if first_header is None or not first_header.startswith("With Licensee"):
embed.title = f"AE7Q History for FRN {frn}"
embed.colour = cmn.colours.bad
embed.url = base_url + frn
embed.description = f"No records found for FRN `{frn}`"
await ctx.send(embed=embed)
return
table = await process_table(table[2:])
embed = cmn.embed_factory(ctx)
embed.title = f"AE7Q History for FRN {frn}"
embed.colour = cmn.colours.good
embed.url = base_url + frn
# add the first three rows of the table to the embed
for row in table[0:3]:
header = f"**{row[0]}** ({row[3]})" # **Callsign** (Applicant Type)
body = (f"Name: *{row[2]}*\n"
f"Class: *{row[4]}*\n"
f"Region: *{row[1]}*\n"
f"Status: *{row[5]}*\n"
f"Granted: *{row[6]}*\n"
f"Effective: *{row[7]}*\n"
f"Cancelled: *{row[8]}*\n"
f"Expires: *{row[9]}*")
embed.add_field(name=header, value=body, inline=False)
if len(table) > 3:
embed.description = f"Records 1 to 3 of {len(table)}. See ae7q.com for more..."
await ctx.send(embed=embed)
@_ae7q_lookup.command(name="licensee", aliases=["l"], category=cmn.cat.lookup)
async def _ae7q_licensee(self, ctx: commands.Context, licensee_id: str):
"""Looks up the history of a licensee ID on [ae7q.com](http://ae7q.com/)."""
with ctx.typing():
licensee_id = licensee_id.upper()
base_url = "http://ae7q.com/query/data/LicenseeIdHistory.php?ID="
embed = cmn.embed_factory(ctx)
async with self.session.get(base_url + licensee_id) as resp:
if resp.status != 200:
raise cmn.BotHTTPError(resp)
page = await resp.text()
soup = BeautifulSoup(page, features="html.parser")
tables = [[row for row in table.find_all("tr")] for table in soup.select("table.Database")]
if not len(tables):
embed.title = f"AE7Q History for Licensee {licensee_id}"
embed.colour = cmn.colours.bad
embed.url = base_url + licensee_id
embed.description = f"No records found for Licensee `{licensee_id}`"
await ctx.send(embed=embed)
return
table = tables[0]
table_headers = table[0].find_all("th")
first_header = "".join(table_headers[0].strings) if len(table_headers) > 0 else None
# catch if the wrong table was selected
if first_header is None or not first_header.startswith("With FCC"):
embed.title = f"AE7Q History for Licensee {licensee_id}"
embed.colour = cmn.colours.bad
embed.url = base_url + licensee_id
embed.description = f"No records found for Licensee `{licensee_id}`"
await ctx.send(embed=embed)
return
table = await process_table(table[2:])
embed = cmn.embed_factory(ctx)
embed.title = f"AE7Q History for Licensee {licensee_id}"
embed.colour = cmn.colours.good
embed.url = base_url + licensee_id
# add the first three rows of the table to the embed
for row in table[0:3]:
header = f"**{row[0]}** ({row[3]})" # **Callsign** (Applicant Type)
body = (f"Name: *{row[2]}*\n"
f"Class: *{row[4]}*\n"
f"Region: *{row[1]}*\n"
f"Status: *{row[5]}*\n"
f"Granted: *{row[6]}*\n"
f"Effective: *{row[7]}*\n"
f"Cancelled: *{row[8]}*\n"
f"Expires: *{row[9]}*")
embed.add_field(name=header, value=body, inline=False)
if len(table) > 3:
embed.description = f"Records 1 to 3 of {len(table)}. See ae7q.com for more..."
await ctx.send(embed=embed)
async def process_table(table: list):
"""Processes tables (*not* including headers) and returns the processed table"""
table_contents = []
for tr in table:
row = []
for td in tr.find_all("td"):
cell_val = td.getText().strip()
row.append(cell_val if cell_val else "-")
# take care of columns that span multiple rows by copying the contents rightward
if "colspan" in td.attrs and int(td.attrs["colspan"]) > 1:
for i in range(int(td.attrs["colspan"]) - 1):
row.append(row[-1])
# get rid of ditto marks by copying the contents from the previous row
for i, cell in enumerate(row):
if cell == "\"":
row[i] = table_contents[-1][i]
# add row to table
table_contents += [row]
return table_contents
def setup(bot: commands.Bot): def setup(bot: commands.Bot):
+98 -75
View File
@@ -1,88 +1,99 @@
""" """
Base extension for qrm Base extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import re
from collections import OrderedDict
import random import random
import re
from typing import Union
import discord import discord
import discord.ext.commands as commands import discord.ext.commands as commands
import info import info
import common as cmn
import data.options as opt import data.options as opt
import common as cmn
class QrmHelpCommand(commands.HelpCommand): class QrmHelpCommand(commands.HelpCommand):
def __init__(self): def __init__(self):
super().__init__(command_attrs={'help': 'Shows help about qrm or a command', 'aliases': ['h']}) super().__init__(command_attrs={"help": "Shows help about qrm or a command", "aliases": ["h"]})
self.verify_checks = True
def get_bot_mapping(self): async def get_bot_mapping(self):
bot = self.context.bot bot = self.context.bot
mapping = {} mapping = {}
for cmd in bot.commands:
cat = cmd.__original_kwargs__.get('category', None) for cmd in await self.filter_commands(bot.commands, sort=True):
cat = cmd.__original_kwargs__.get("category", None)
if cat in mapping: if cat in mapping:
mapping[cat].append(cmd) mapping[cat].append(cmd)
else: else:
mapping[cat] = [cmd] mapping[cat] = [cmd]
return mapping return mapping
def get_command_signature(self, command): async def get_command_signature(self, command):
parent = command.full_parent_name parent = command.full_parent_name
if command.aliases != []: if command.aliases != []:
aliases = ', '.join(command.aliases) aliases = ", ".join(command.aliases)
fmt = command.name fmt = command.name
if parent: if parent:
fmt = f'{parent} {fmt}' fmt = f"{parent} {fmt}"
alias = fmt alias = fmt
return f'{opt.prefix}{alias} {command.signature}\n *Aliases:* {aliases}' return f"{opt.display_prefix}{alias} {command.signature}\n *Aliases:* {aliases}"
alias = command.name if not parent else f'{parent} {command.name}' alias = command.name if not parent else f"{parent} {command.name}"
return f'{opt.prefix}{alias} {command.signature}' return f"{opt.display_prefix}{alias} {command.signature}"
async def send_error_message(self, error): async def send_error_message(self, error):
embed = cmn.embed_factory(self.context) embed = cmn.embed_factory(self.context)
embed.title = 'qrm Help Error' embed.title = "qrm Help Error"
embed.description = error embed.description = error
embed.colour = cmn.colours.bad embed.colour = cmn.colours.bad
await self.context.send(embed=embed) await self.context.send(embed=embed)
async def send_bot_help(self, mapping): async def send_bot_help(self, mapping):
embed = cmn.embed_factory(self.context) embed = cmn.embed_factory(self.context)
embed.title = 'qrm Help' embed.title = "qrm Help"
embed.description = (f'For command-specific help and usage, use `{opt.prefix}help [command name]`' embed.description = (f"For command-specific help and usage, use `{opt.display_prefix}help [command name]`."
'. Many commands have shorter aliases.') " Many commands have shorter aliases.")
mapping = await mapping
for cat, cmds in mapping.items(): for cat, cmds in mapping.items():
cmds = list(filter(lambda x: not x.hidden, cmds))
if cmds == []: if cmds == []:
continue continue
names = sorted([cmd.name for cmd in cmds]) names = sorted([cmd.name for cmd in cmds])
if cat is not None: if cat is not None:
embed.add_field(name=cat.title(), value=', '.join(names), inline=False) embed.add_field(name=cat.title(), value=", ".join(names), inline=False)
else: else:
embed.add_field(name='Other', value=', '.join(names), inline=False) embed.add_field(name="Other", value=", ".join(names), inline=False)
await self.context.send(embed=embed) await self.context.send(embed=embed)
async def send_command_help(self, command): async def send_command_help(self, command):
if self.verify_checks:
if not await command.can_run(self.context):
raise commands.CheckFailure
for p in command.parents:
if not await p.can_run(self.context):
raise commands.CheckFailure
embed = cmn.embed_factory(self.context) embed = cmn.embed_factory(self.context)
embed.title = self.get_command_signature(command) embed.title = await self.get_command_signature(command)
embed.description = command.help embed.description = command.help
await self.context.send(embed=embed) await self.context.send(embed=embed)
async def send_group_help(self, group): async def send_group_help(self, group):
if self.verify_checks and not await group.can_run(self.context):
raise commands.CheckFailure
embed = cmn.embed_factory(self.context) embed = cmn.embed_factory(self.context)
embed.title = self.get_command_signature(group) embed.title = await self.get_command_signature(group)
embed.description = group.help embed.description = group.help
for cmd in group.commands: for cmd in await self.filter_commands(group.commands, sort=True):
embed.add_field(name=self.get_command_signature(cmd), value=cmd.help, inline=False) embed.add_field(name=await self.get_command_signature(cmd), value=cmd.help, inline=False)
await self.context.send(embed=embed) await self.context.send(embed=embed)
@@ -97,104 +108,116 @@ class BaseCog(commands.Cog):
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = "About qrm" embed.title = "About qrm"
embed.description = info.description embed.description = info.description
embed.add_field(name="Authors", value=", ".join(info.authors)) embed.add_field(name="Authors", value=", ".join(info.authors))
embed.add_field(name="License", value=info.license) embed.add_field(name="License", value=info.license)
embed.add_field(name="Version", value=f'v{info.release}') embed.add_field(name="Version", value=f"v{info.release}")
embed.add_field(name="Contributing", value=info.contributing, inline=False) embed.add_field(name="Contributing", value=info.contributing, inline=False)
embed.add_field(name="Official Server", value=info.bot_server, inline=False) embed.add_field(name="Official Server", value=info.bot_server, inline=False)
embed.set_thumbnail(url=str(self.bot.user.avatar_url)) embed.set_thumbnail(url=str(self.bot.user.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="ping", aliases=['beep']) @commands.command(name="ping", aliases=["beep"])
async def _ping(self, ctx: commands.Context): async def _ping(self, ctx: commands.Context):
"""Show the current latency to the discord endpoint.""" """Shows the current latency to the discord endpoint."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
content = '' content = ""
if ctx.invoked_with == "beep": if ctx.invoked_with == "beep":
embed.title = "**Boop!**" embed.title = "**Boop!**"
else: else:
content = ctx.message.author.mention if random.random() < 0.05 else '' content = ctx.message.author.mention if random.random() < 0.05 else ""
embed.title = "🏓 **Pong!**" embed.title = "🏓 **Pong!**"
embed.description = f'Current ping is {self.bot.latency*1000:.1f} ms' embed.description = f"Current ping is {self.bot.latency*1000:.1f} ms"
await ctx.send(content, embed=embed) await ctx.send(content, embed=embed)
@commands.command(name="changelog", aliases=["clog"]) @commands.command(name="changelog", aliases=["clog"])
async def _changelog(self, ctx: commands.Context): async def _changelog(self, ctx: commands.Context, version: str = "latest"):
"""Show what has changed in the most recent bot version.""" """Shows what has changed in a bot version. Defaults to the latest version."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = "qrm Changelog" embed.title = "qrm Changelog"
embed.description = ("For a full listing, visit [Github](https://" embed.description = ("For a full listing, visit [Github](https://"
"github.com/classabbyamp/discord-qrm2/blob/master/CHANGELOG.md).") "github.com/miaowware/qrm2/blob/master/CHANGELOG.md).")
changelog = self.changelog changelog = self.changelog
vers = list(changelog.keys())
vers.remove("Unreleased")
vers = 0 version = version.lower()
for ver, log in changelog.items():
if ver.lower() != 'unreleased': if version == "latest":
if 'date' in log: version = info.release
embed.description += f'\n\n**{ver}** ({log["date"]})' if version == "unreleased":
else: version = "Unreleased"
embed.description += f'\n\n**{ver}**'
embed = await format_changelog(log, embed) try:
vers += 1 log = changelog[version]
if vers >= 1: except KeyError:
break embed.title += ": Version Not Found"
embed.description += "\n\n**Valid versions:** latest, "
embed.description += ", ".join(vers)
embed.colour = cmn.colours.bad
await ctx.send(embed=embed)
return
if "date" in log:
embed.description += f"\n\n**v{version}** ({log['date']})"
else:
embed.description += f"\n\n**v{version}**"
embed = await format_changelog(log, embed)
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="issue") @commands.command(name="issue")
async def _issue(self, ctx: commands.Context): async def _issue(self, ctx: commands.Context):
"""Shows how to create an issue for the bot.""" """Shows how to create a bug report or feature request about the bot."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = "Found a bug? Have a feature request?" embed.title = "Found a bug? Have a feature request?"
embed.description = ("Submit an issue on the [issue tracker]" embed.description = ("Submit an issue on the [issue tracker]"
"(https://github.com/classabbyamp/discord-qrm2/issues)!") "(https://github.com/miaowware/qrm2/issues)!")
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="bruce", hidden=True) @commands.command(name="echo", aliases=["e"], category=cmn.cat.admin)
async def _b_issue(self, ctx: commands.Context):
"""Shows how to create an issue for the bot."""
await ctx.invoke(self._issue)
@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,
"""Send a message in a channel as qrm. Only works within a server or DM to server, not between servers.""" channel: Union[cmn.GlobalChannelConverter, commands.UserConverter], *, msg: str):
"""Sends a message in a channel as qrm. Accepts channel/user IDs/mentions.
Channel names are current-guild only.
Does not work with the ID of the bot user."""
if isinstance(channel, discord.ClientUser):
raise commands.BadArgument("Can't send to the bot user!")
await channel.send(msg) await channel.send(msg)
def parse_changelog(): def parse_changelog():
changelog = OrderedDict() changelog = {}
ver = '' ver = ""
heading = '' heading = ""
with open('CHANGELOG.md') as changelog_file: with open("CHANGELOG.md") as changelog_file:
for line in changelog_file.readlines(): for line in changelog_file.readlines():
if line.strip() == '': if line.strip() == "":
continue continue
if re.match(r'##[^#]', line): if re.match(r"##[^#]", line):
ver_match = re.match(r'\[(.+)\](?: - )?(\d{4}-\d{2}-\d{2})?', line.lstrip('#').strip()) ver_match = re.match(r"\[(.+)\](?: - )?(\d{4}-\d{2}-\d{2})?", line.lstrip("#").strip())
if ver_match is not None: if ver_match is not None:
ver = ver_match.group(1) ver = ver_match.group(1)
changelog[ver] = dict() changelog[ver] = dict()
if ver_match.group(2): if ver_match.group(2):
changelog[ver]['date'] = ver_match.group(2) changelog[ver]["date"] = ver_match.group(2)
elif re.match(r'###[^#]', line): elif re.match(r"###[^#]", line):
heading = line.lstrip('#').strip() heading = line.lstrip("#").strip()
changelog[ver][heading] = [] changelog[ver][heading] = []
elif ver != '' and heading != '': elif ver != "" and heading != "":
if line.startswith('-'): if line.startswith("-"):
changelog[ver][heading].append(line.lstrip('-').strip()) changelog[ver][heading].append(line.lstrip("-").strip())
return changelog return changelog
async def format_changelog(log: dict, embed: discord.Embed): async def format_changelog(log: dict, embed: discord.Embed):
for header, lines in log.items(): for header, lines in log.items():
formatted = '' formatted = ""
if header != 'date': if header != "date":
for line in lines: for line in lines:
formatted += f'- {line}\n' formatted += f"- {line}\n"
embed.add_field(name=f'**{header}**', value=formatted, inline=False) embed.add_field(name=f"**{header}**", value=formatted, inline=False)
return embed return embed
+200
View File
@@ -0,0 +1,200 @@
"""
Conversion extension for qrm
---
Copyright (C) 2020 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
"""
import math
from enum import Enum
from typing import Optional
from dataclasses import dataclass
import discord.ext.commands as commands
import common as cmn
from data import options as opt
# not sure why but UnitConverter and Unit need to be defined before DbConvCog and convert()
class UnitConverter(commands.Converter):
async def convert(self, ctx: commands.Context, argument: str):
is_db = None
mult = None
unit = None
utype = None
try:
s = argument.lower()
if len(s) > 2 and s[:2] == "db":
is_db = True
if s[2:] in units:
u = units[s[2:]]
mult = u["mult"]
unit = u["log"]
utype = u["type"]
elif s in units:
is_db = False
u = units[s]
mult = u["mult"]
unit = u["scalar"]
utype = u["type"]
else:
raise ValueError(f"Invalid unit: {argument}")
return Unit(argument, unit, utype, is_db, mult)
except ValueError as e:
raise commands.BadArgument(message=str(e))
class UnitType(Enum):
voltage = 1
power = 2
antenna = 3
@dataclass
class Unit:
raw: str
unit: str
type: UnitType
is_db: bool
mult: int
class DbConvCog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command(name="dbconv", aliases=["dbc"], category=cmn.cat.ref)
async def _db_conv(self, ctx: commands.Context,
value: Optional[float] = None,
unit_from: Optional[UnitConverter] = None,
unit_to: Optional[UnitConverter] = None):
"""
Convert between decibels and scalar values for voltage, power, and antenna gain.
**Valid Units**
*Voltage:* V, mV, µV, uV, dBV, dBmV, dBµV, dBuV
*Power:* fW, mW, W, kW, dBf, dBm, dBW, dBk
*Antenna Gain:* dBi, dBd, dBq
"""
embed = cmn.embed_factory(ctx)
if value is not None and unit_from is not None and unit_to is not None:
converted = convert(value, unit_from, unit_to)
embed.title = f"{value:.3g} {unit_from.unit} = {converted:.3g} {unit_to.unit}"
embed.colour = cmn.colours.good
else:
embed.title = "Decibel Quick Reference"
embed.description = (
"Decibels are a great way to easily represent large quantities that are common in electronics. "
"There are a few main types that are used often in radio: voltage, power, and antenna gain. "
"Here are some commonly-used reference levels for each type:"
)
v_db_info = ("**dBV** = relative to 1 V\n"
"**dBmV** = relative to 1 mV (1e-3 V)\n"
"**dBµV** = relative to 1 µV (1e-6 V)")
embed.add_field(name="Voltage Decibels", value=v_db_info, inline=False)
p_db_info = ("**dBW** = relative to 1 W\n"
"**dBk** = relative to 1 kW (1e3 W)\n"
"**dBm** = relative to 1 mW (1e-3 W)\n"
"**dBf** = relative to 1 fW (1e-15 W)")
embed.add_field(name="Power Decibels", value=p_db_info, inline=False)
a_db_info = ("**dBi** = relative to a theoretical __i__sotropic radiator in free space "
"(equal radiation in all directions)\n"
"**dBd** = relative to a dipole in free space (0 dBd = 2.15 dBi)\n"
"**dBq** = relative to a quarter-wave antenna in free space (0 dBq = -0.85 dBi)")
embed.add_field(name="Antenna Gain Decibels", value=a_db_info, inline=False)
embed.add_field(name="Use the bot to do the conversions",
value=f"`{opt.display_prefix}dbconv [value] [unit_from] [unit_to]`",
inline=False)
await ctx.send(embed=embed)
def setup(bot: commands.Bot):
bot.add_cog(DbConvCog(bot))
def convert(initial: float, unit1: Unit, unit2: Unit):
if unit1.type == unit2.type:
# dB to dB
if unit1.is_db and unit2.is_db:
if unit1.mult == unit2.mult:
return initial
elif unit1.type == UnitType.voltage:
return _calc_volt_db(_calc_volt(initial, unit1.mult), unit2.mult)
elif unit1.type == UnitType.power:
return _calc_power_db(_calc_power(initial, unit1.mult), unit2.mult)
elif unit1.type == UnitType.antenna:
return initial + (unit1.mult - unit2.mult)
# V/W to V/W
elif not unit1.is_db and not unit2.is_db:
if unit1.mult == unit2.mult:
return initial
return initial * unit1.mult / unit2.mult
# dB to V/W
elif unit1.is_db and not unit2.is_db:
if unit1.type == UnitType.voltage:
return _calc_volt(initial, unit1.mult) / unit2.mult
elif unit1.type == UnitType.power:
return _calc_power(initial, unit1.mult) / unit2.mult
# V/W to dB
elif not unit1.is_db and unit2.is_db:
if unit1.type == UnitType.voltage:
return _calc_volt_db(initial * unit1.mult, unit2.mult)
elif unit1.type == UnitType.power:
return _calc_power_db(initial * unit1.mult, unit2.mult)
raise ValueError(f"Can't convert between {unit1} and {unit2}")
units = {
# voltage
"uv": {"mult": 1e-6, "scalar": "µV", "log": "dBµV", "type": UnitType.voltage},
"µv": {"mult": 1e-6, "scalar": "µV", "log": "dBµV", "type": UnitType.voltage},
"mv": {"mult": 1e-3, "scalar": "mV", "log": "dBmV", "type": UnitType.voltage},
"v": {"mult": 1, "scalar": "V", "log": "dBV", "type": UnitType.voltage},
# power
"fw": {"mult": 1e-15, "scalar": "fW", "log": "dBf", "type": UnitType.power},
"f": {"mult": 1e-15, "scalar": "fW", "log": "dBf", "type": UnitType.power},
"mw": {"mult": 1e-3, "scalar": "mW", "log": "dBm", "type": UnitType.power},
"m": {"mult": 1e-3, "scalar": "mW", "log": "dBm", "type": UnitType.power},
"w": {"mult": 1, "scalar": "W", "log": "dBW", "type": UnitType.power},
"kw": {"mult": 1e3, "scalar": "kW", "log": "dBk", "type": UnitType.power},
"k": {"mult": 1e3, "scalar": "kW", "log": "dBk", "type": UnitType.power},
# antenna
"q": {"mult": -0.85, "scalar": None, "log": "dBq", "type": UnitType.antenna},
"i": {"mult": 0, "scalar": None, "log": "dBi", "type": UnitType.antenna},
"d": {"mult": 2.15, "scalar": None, "log": "dBd", "type": UnitType.antenna},
}
def _calc_power_db(p: float, ref: float):
return 10 * math.log10(p / ref)
def _calc_power(db: float, ref: float):
return 10 ** (db / 10) * ref
def _calc_volt_db(v: float, ref: float):
return 20 * math.log10(v / ref)
def _calc_volt(db: float, ref: float):
return 10 ** (db / 20) * ref
# testing code
if __name__ == "__main__":
while(True):
try:
ip = input("> ").split()
initial = float(ip[0])
unit1 = Unit(ip[1])
unit2 = Unit(ip[2])
conv = convert(initial, unit1, unit2)
print(f"{initial:.2f} {unit1} = {conv:.2f} {unit2}")
except ValueError as e:
print(e)
+41 -25
View File
@@ -1,14 +1,16 @@
""" """
Fun extension for qrm Fun extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import random import random
import discord
import discord.ext.commands as commands import discord.ext.commands as commands
import common as cmn import common as cmn
@@ -17,39 +19,53 @@ import common as cmn
class FunCog(commands.Cog): class FunCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
with open('resources/words') as words_file: with open(cmn.paths.resources / "words") as words_file:
self.words = words_file.read().lower().splitlines() self.words = words_file.read().lower().splitlines()
@commands.command(name="xkcd", aliases=['x'], category=cmn.cat.fun) @commands.command(name="xkcd", aliases=["x"], category=cmn.cat.fun)
async def _xkcd(self, ctx: commands.Context, number: str): async def _xkcd(self, ctx: commands.Context, number: str):
'''Look up an xkcd by number.''' """Looks up an xkcd comic by number."""
await ctx.send('http://xkcd.com/' + number) await ctx.send("http://xkcd.com/" + number)
@commands.command(name="tar", category=cmn.cat.fun) @commands.command(name="tar", category=cmn.cat.fun)
async def _tar(self, ctx: commands.Context): async def _tar(self, ctx: commands.Context):
'''Returns an xkcd about tar.''' """Returns xkcd: tar."""
await ctx.send('http://xkcd.com/1168') await ctx.send("http://xkcd.com/1168")
@commands.command(name="standards", category=cmn.cat.fun)
async def _standards(self, ctx: commands.Context):
"""Returns xkcd: Standards."""
await ctx.send("http://xkcd.com/927")
@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)
@commands.command(name="xd", hidden=True, category=cmn.cat.fun) @commands.command(name="xd", hidden=True, category=cmn.cat.fun)
async def _xd(self, ctx: commands.Context): async def _xd(self, ctx: commands.Context):
'''ecks dee''' """ecks dee"""
await ctx.send('ECKS DEE :smirk:') await ctx.send("ECKS DEE :smirk:")
@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):
'''Get fun 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(): result += random.choice([word for word in self.words if word[0] == char])
result += random.choice([word for word in self.words if word[0] == char]) else:
else: result += char
result += char result += " "
result += ' ' embed = cmn.embed_factory(ctx)
embed = cmn.embed_factory(ctx) embed.title = f"Funetics for {msg}"
embed.title = f'Funetics for {msg}' embed.description = result.title()
embed.description = result.title() embed.colour = cmn.colours.good
embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
+93 -94
View File
@@ -1,12 +1,13 @@
""" """
Grid extension for qrm Grid extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import math import math
import discord.ext.commands as commands import discord.ext.commands as commands
@@ -20,117 +21,115 @@ class GridCog(commands.Cog):
@commands.command(name="grid", category=cmn.cat.maps) @commands.command(name="grid", category=cmn.cat.maps)
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
try: lonf = float(lon) + 180
latf = float(lat) + 90 if 0 <= latf <= 180 and 0 <= lonf <= 360:
lonf = float(lon) + 180 grid += chr(ord("A") + int(lonf / 20))
if 0 <= latf <= 180 and 0 <= lonf <= 360: grid += chr(ord("A") + int(latf / 10))
grid += chr(ord('A') + int(lonf / 20)) grid += chr(ord("0") + int((lonf % 20)/2))
grid += chr(ord('A') + int(latf / 10)) grid += chr(ord("0") + int((latf % 10)/1))
grid += chr(ord('0') + int((lonf % 20)/2)) grid += chr(ord("a") + int((lonf - (int(lonf/2)*2)) / (5/60)))
grid += chr(ord('0') + int((latf % 10)/1)) grid += chr(ord("a") + int((latf - (int(latf/1)*1)) / (2.5/60)))
grid += chr(ord('a') + int((lonf - (int(lonf/2)*2)) / (5/60))) grid += "**"
grid += chr(ord('a') + int((latf - (int(latf/1)*1)) / (2.5/60))) embed = cmn.embed_factory(ctx)
grid += "**" embed.title = f"Maidenhead Grid Locator for {float(lat):.6f}, {float(lon):.6f}"
embed = cmn.embed_factory(ctx) embed.description = grid
embed.title = f'Maidenhead Grid Locator for {float(lat):.6f}, {float(lon):.6f}' embed.colour = cmn.colours.good
embed.description = grid else:
embed.colour = cmn.colours.good embed = cmn.embed_factory(ctx)
else: embed.title = f"Error generating grid square for {lat}, {lon}."
raise ValueError('Out of range.') embed.description = """Coordinates out of range.
except ValueError as err: The valid ranges are:
embed = cmn.embed_factory(ctx) - Latitude: `-90` to `+90`
embed.title = f'Error generating grid square for {lat}, {lon}.' - Longitude: `-180` to `+180`"""
embed.description = str(err) embed.colour = cmn.colours.bad
embed.colour = cmn.colours.bad
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="ungrid", aliases=['loc'], category=cmn.cat.maps) @commands.command(name="ungrid", aliases=["loc"], category=cmn.cat.maps)
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() loc = get_coords(grid)
loc = get_coords(grid)
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = f'Latitude and Longitude for {grid}' embed.title = f"Latitude and Longitude for {grid}"
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
if len(grid) >= 6: if len(grid) >= 6:
embed.description = f'**{loc[0]:.5f}, {loc[1]:.5f}**' embed.description = f"**{loc[0]:.5f}, {loc[1]:.5f}**"
embed.url = f'https://www.openstreetmap.org/#map=13/{loc[0]:.5f}/{loc[1]:.5f}' embed.url = f"https://www.openstreetmap.org/#map=13/{loc[0]:.5f}/{loc[1]:.5f}"
else: else:
embed.description = f'**{loc[0]:.1f}, {loc[1]:.1f}**' embed.description = f"**{loc[0]:.1f}, {loc[1]:.1f}**"
embed.url = f'https://www.openstreetmap.org/#map=10/{loc[0]:.1f}/{loc[1]:.1f}' embed.url = f"https://www.openstreetmap.org/#map=10/{loc[0]:.1f}/{loc[1]:.1f}"
except Exception as e: except Exception as e:
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = f'Error generating latitude and longitude for grid {grid}.' embed.title = f"Error generating latitude and longitude for grid {grid}."
embed.description = str(e) embed.description = str(e)
embed.colour = cmn.colours.bad embed.colour = cmn.colours.bad
else: else:
radius = 6371 radius = 6371
try: try:
grid = grid.upper() grid = grid.upper()
grid2 = grid2.upper() grid2 = grid2.upper()
loc = get_coords(grid) loc = get_coords(grid)
loc2 = get_coords(grid2) loc2 = get_coords(grid2)
# Haversine formula # Haversine formula
d_lat = math.radians(loc2[0] - loc[0]) d_lat = math.radians(loc2[0] - loc[0])
d_lon = math.radians(loc2[1] - loc[1]) d_lon = math.radians(loc2[1] - loc[1])
a = (math.sin(d_lat/2) ** 2 a = (math.sin(d_lat/2) ** 2
+ math.cos(math.radians(loc[0])) + math.cos(math.radians(loc[0]))
* math.cos(math.radians(loc2[0])) * math.cos(math.radians(loc2[0]))
* math.sin(d_lon/2) ** 2) * math.sin(d_lon/2) ** 2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)) c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
d = radius * c d = radius * c
d_mi = 0.6213712 * d d_mi = 0.6213712 * d
# Bearing # Bearing
y_dist = math.sin(math.radians(loc2[1]-loc[1])) * math.cos(math.radians(loc2[0])) y_dist = math.sin(math.radians(loc2[1]-loc[1])) * math.cos(math.radians(loc2[0]))
x_dist = (math.cos(math.radians(loc[0])) x_dist = (math.cos(math.radians(loc[0]))
* math.sin(math.radians(loc2[0])) * math.sin(math.radians(loc2[0]))
- math.sin(math.radians(loc[0])) - math.sin(math.radians(loc[0]))
* math.cos(math.radians(loc2[0])) * math.cos(math.radians(loc2[0]))
* math.cos(math.radians(loc2[1] - loc[1]))) * math.cos(math.radians(loc2[1] - loc[1])))
bearing = (math.degrees(math.atan2(y_dist, x_dist)) + 360) % 360 bearing = (math.degrees(math.atan2(y_dist, x_dist)) + 360) % 360
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = f'Great Circle Distance and Bearing from {grid} to {grid2}' embed.title = f"Great Circle Distance and Bearing from {grid} to {grid2}"
embed.description = f'**Distance:** {d:.1f} km ({d_mi:.1f} mi)\n**Bearing:** {bearing:.1f}°' embed.description = f"**Distance:** {d:.1f} km ({d_mi:.1f} mi)\n**Bearing:** {bearing:.1f}°"
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
except Exception as e: except Exception as e:
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = f'Error generating great circle distance and bearing from {grid} and {grid2}.' embed.title = f"Error generating great circle distance and bearing from {grid} and {grid2}."
embed.description = str(e) embed.description = str(e)
embed.colour = cmn.colours.bad embed.colour = cmn.colours.bad
await ctx.send(embed=embed) await ctx.send(embed=embed)
def get_coords(grid: str): def get_coords(grid: str):
if len(grid) < 3: if len(grid) < 3:
raise ValueError('The grid locator must be at least 4 characters long.') raise ValueError("The grid locator must be at least 4 characters long.")
if not grid[0:2].isalpha() or not grid[2:4].isdigit(): if not grid[0:2].isalpha() or not grid[2:4].isdigit():
if len(grid) <= 4: if len(grid) <= 4:
raise ValueError('The grid locator must be of the form AA##.') raise ValueError("The grid locator must be of the form AA##.")
if len(grid) >= 6 and not grid[5:7].isalpha(): if len(grid) >= 6 and not grid[5:7].isalpha():
raise ValueError('The grid locator must be of the form AA##AA.') raise ValueError("The grid locator must be of the form AA##AA.")
lon = ((ord(grid[0]) - ord('A')) * 20) - 180 lon = ((ord(grid[0]) - ord("A")) * 20) - 180
lat = ((ord(grid[1]) - ord('A')) * 10) - 90 lat = ((ord(grid[1]) - ord("A")) * 10) - 90
lon += ((ord(grid[2]) - ord('0')) * 2) lon += ((ord(grid[2]) - ord("0")) * 2)
lat += ((ord(grid[3]) - ord('0')) * 1) lat += ((ord(grid[3]) - ord("0")) * 1)
if len(grid) >= 6: if len(grid) >= 6:
# have subsquares # have subsquares
lon += ((ord(grid[4])) - ord('A')) * (5/60) lon += ((ord(grid[4])) - ord("A")) * (5/60)
lat += ((ord(grid[5])) - ord('A')) * (2.5/60) lat += ((ord(grid[5])) - ord("A")) * (2.5/60)
# move to center of subsquare # move to center of subsquare
lon += (2.5/60) lon += (2.5/60)
lat += (1.25/60) lat += (1.25/60)
+82 -59
View File
@@ -1,12 +1,13 @@
""" """
Ham extension for qrm Ham extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
from datetime import datetime from datetime import datetime
import discord.ext.commands as commands import discord.ext.commands as commands
@@ -20,68 +21,70 @@ from resources import qcodes
class HamCog(commands.Cog): class HamCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
self.pfxs = callsign_info.options
@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):
'''Look up 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)
if qcode in qcodes.qcodes:
embed.title = qcode
embed.description = qcodes.qcodes[qcode]
embed.colour = cmn.colours.good
else:
embed.title = f'Q Code {qcode} not found'
embed.colour = cmn.colours.bad
await ctx.send(embed=embed)
@commands.command(name="phonetics", aliases=['ph', 'phoneticize', 'phoneticise', 'phone'], category=cmn.cat.ref)
async def _phonetics_lookup(self, ctx: commands.Context, *, msg: str):
'''Get phonetics for a word or phrase.'''
with ctx.typing():
result = ''
for char in msg.lower():
if char.isalpha():
result += phonetics.phonetics[char]
else:
result += char
result += ' '
embed = cmn.embed_factory(ctx)
embed.title = f'Phonetics for {msg}'
embed.description = result.title()
embed.colour = cmn.colours.good
await ctx.send(embed=embed)
@commands.command(name="utc", aliases=['z'], category=cmn.cat.ref)
async def _utc_lookup(self, ctx: commands.Context):
'''Gets the current time in UTC.'''
with ctx.typing():
now = datetime.utcnow()
result = '**' + now.strftime('%Y-%m-%d %H:%M') + 'Z**'
embed = cmn.embed_factory(ctx)
embed.title = 'The current time is:'
embed.description = result
embed.colour = cmn.colours.good
await ctx.send(embed=embed)
@commands.command(name="prefixes", aliases=["vanity", "pfx", "vanities", "prefix"])
async def _vanity_prefixes(self, ctx: commands.Context, country: str = None):
'''Lists valid prefixes for countries.'''
if country is None:
await ctx.send_help(ctx.command)
return
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
if country.lower() not in callsign_info.options: if qcode in qcodes.qcodes:
embed.title = f'{country} not found!', embed.title = qcode
embed.description = f'Valid countries: {", ".join(callsign_info.options.keys())}', embed.description = qcodes.qcodes[qcode]
embed.colour = cmn.colours.bad embed.colour = cmn.colours.good
else: else:
embed.title = callsign_info.options[country.lower()][0] embed.title = f"Q Code {qcode} not found"
embed.description = callsign_info.options[country.lower()][1] embed.colour = cmn.colours.bad
await ctx.send(embed=embed)
@commands.command(name="phonetics", aliases=["ph", "phoneticize", "phoneticise", "phone"], category=cmn.cat.ref)
async def _phonetics_lookup(self, ctx: commands.Context, *, msg: str):
"""Returns NATO phonetics for a word or phrase."""
result = ""
for char in msg.lower():
if char.isalpha():
result += phonetics.phonetics[char]
else:
result += char
result += " "
embed = cmn.embed_factory(ctx)
embed.title = f"Phonetics for {msg}"
embed.description = result.title()
embed.colour = cmn.colours.good
await ctx.send(embed=embed)
@commands.command(name="utc", aliases=["z"], category=cmn.cat.ref)
async def _utc_lookup(self, ctx: commands.Context):
"""Returns the current time in UTC."""
now = datetime.utcnow()
result = "**" + now.strftime("%Y-%m-%d %H:%M") + "Z**"
embed = cmn.embed_factory(ctx)
embed.title = "The current time is:"
embed.description = result
embed.colour = cmn.colours.good
await ctx.send(embed=embed)
@commands.command(name="prefixes", aliases=["vanity", "pfx", "vanities", "prefix"], category=cmn.cat.ref)
async def _vanity_prefixes(self, ctx: commands.Context, country: str = ""):
"""Lists valid callsign prefixes for different countries."""
country = country.lower()
embed = cmn.embed_factory(ctx)
if country not in self.pfxs:
desc = "Possible arguments are:\n"
for key, val in self.pfxs.items():
desc += f"`{key}`: {val.title}{(' ' + val.emoji if val.emoji else '')}\n"
embed.title = f"{country} Not Found!"
embed.description = desc
embed.colour = cmn.colours.bad
await ctx.send(embed=embed)
return
else:
data = self.pfxs[country]
embed.title = data.title + (" " + data.emoji if data.emoji else "")
embed.description = data.desc
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
for name, val in callsign_info.options[country.lower()][2].items(): for name, val in data.calls.items():
embed.add_field(name=name, value=val, inline=False) embed.add_field(name=name, value=val, inline=False)
await ctx.send(embed=embed) await ctx.send(embed=embed)
@@ -94,6 +97,26 @@ class HamCog(commands.Cog):
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="phoneticweight", aliases=["pw"], category=cmn.cat.ref)
async def _weight(self, ctx: commands.Context, *, msg: str):
"""Calculates the phonetic weight of a callsign or message."""
embed = cmn.embed_factory(ctx)
msg = msg.upper()
weight = 0
for char in msg:
try:
weight += phonetics.pweights[char]
except KeyError:
embed.title = "Error in calculation of phonetic weight"
embed.description = f"Unknown character `{char}` in message"
embed.colour = cmn.colours.bad
await ctx.send(embed=embed)
return
embed.title = f"Phonetic Weight of {msg}"
embed.description = f"The phonetic weight is **{weight}**"
embed.colour = cmn.colours.good
await ctx.send(embed=embed)
def setup(bot: commands.Bot): def setup(bot: commands.Bot):
bot.add_cog(HamCog(bot)) bot.add_cog(HamCog(bot))
+58 -63
View File
@@ -1,13 +1,14 @@
""" """
Image extension for qrm Image extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import io
import aiohttp
import discord import discord
import discord.ext.commands as commands import discord.ext.commands as commands
@@ -16,85 +17,79 @@ import common as cmn
class ImageCog(commands.Cog): class ImageCog(commands.Cog):
gl_url = ("http://www.fourmilab.ch/cgi-bin/uncgi/Earth?img=NOAAtopo.evif"
"&imgsize=320&dynimg=y&opt=-p&lat=&lon=&alt=&tle=&date=0&utc=&jd=")
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
self.bandcharts = cmn.ImagesGroup(cmn.paths.bandcharts / "meta.json") self.bandcharts = cmn.ImagesGroup(cmn.paths.bandcharts / "meta.json")
self.maps = cmn.ImagesGroup(cmn.paths.maps / "meta.json") self.maps = cmn.ImagesGroup(cmn.paths.maps / "meta.json")
self.session = bot.qrm.session self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.command(name="bandplan", aliases=['plan', 'bands'], category=cmn.cat.ref) @commands.command(name="bandplan", aliases=["plan", "bands"], category=cmn.cat.ref)
async def _bandplan(self, ctx: commands.Context, region: str = ''): async def _bandplan(self, ctx: commands.Context, region: str = ""):
'''Posts an image of Frequency Allocations.''' """Gets the frequency allocations chart for a given country."""
arg = region.lower() async with ctx.typing():
arg = region.lower()
with ctx.typing():
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
if arg not in self.bandcharts: if arg not in self.bandcharts:
desc = 'Possible arguments are:\n' desc = "Possible arguments are:\n"
for key, img in self.bandcharts.items(): for key, img in self.bandcharts.items():
desc += f'`{key}`: {img.name}{(" " + img.emoji if img.emoji else "")}\n' desc += f"`{key}`: {img.name}{(' ' + img.emoji if img.emoji else '')}\n"
embed.title = f'Bandplan Not Found!' embed.title = "Bandplan Not Found!"
embed.description = desc embed.description = desc
embed.colour = cmn.colours.bad embed.colour = cmn.colours.bad
await ctx.send(embed=embed) await ctx.send(embed=embed)
else: return
metadata: cmn.ImageMetadata = self.bandcharts[arg] metadata: cmn.ImageMetadata = self.bandcharts[arg]
img = discord.File(cmn.paths.bandcharts / metadata.filename, img = discord.File(cmn.paths.bandcharts / metadata.filename,
filename=metadata.filename) filename=metadata.filename)
if metadata.description: if metadata.description:
embed.description = metadata.description embed.description = metadata.description
if metadata.source: if metadata.source:
embed.add_field(name="Source", value=metadata.source) embed.add_field(name="Source", value=metadata.source)
embed.title = metadata.long_name + (" " + metadata.emoji if metadata.emoji else "") embed.title = metadata.long_name + (" " + metadata.emoji if metadata.emoji else "")
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
embed.set_image(url='attachment://' + metadata.filename) embed.set_image(url="attachment://" + metadata.filename)
await ctx.send(embed=embed, file=img) await ctx.send(embed=embed, file=img)
@commands.command(name="map", category=cmn.cat.maps) @commands.command(name="map", category=cmn.cat.maps)
async def _map(self, ctx: commands.Context, map_id: str = ''): async def _map(self, ctx: commands.Context, map_id: str = ""):
'''Posts an image of a ham-relevant map.''' """Posts a ham-relevant map."""
arg = map_id.lower() async with ctx.typing():
arg = map_id.lower()
with ctx.typing():
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
if arg not in self.maps: if arg not in self.maps:
desc = 'Possible arguments are:\n' desc = "Possible arguments are:\n"
for key, img in self.maps.items(): for key, img in self.maps.items():
desc += f'`{key}`: {img.name}{(" " + img.emoji if img.emoji else "")}\n' desc += f"`{key}`: {img.name}{(' ' + img.emoji if img.emoji else '')}\n"
embed.title = 'Map Not Found!' embed.title = "Map Not Found!"
embed.description = desc embed.description = desc
embed.colour = cmn.colours.bad embed.colour = cmn.colours.bad
await ctx.send(embed=embed) await ctx.send(embed=embed)
else: return
metadata: cmn.ImageMetadata = self.maps[arg] metadata: cmn.ImageMetadata = self.maps[arg]
img = discord.File(cmn.paths.maps / metadata.filename, img = discord.File(cmn.paths.maps / metadata.filename,
filename=metadata.filename) filename=metadata.filename)
if metadata.description: if metadata.description:
embed.description = metadata.description embed.description = metadata.description
if metadata.source: if metadata.source:
embed.add_field(name="Source", value=metadata.source) embed.add_field(name="Source", value=metadata.source)
embed.title = metadata.long_name + (" " + metadata.emoji if metadata.emoji else "") 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)
@commands.command(name="grayline", aliases=['greyline', 'grey', 'gray', 'gl'], category=cmn.cat.maps)
async def _grayline(self, ctx: commands.Context):
'''Posts a map of the current greyline, where HF propagation is the best.'''
gl_url = ('http://www.fourmilab.ch/cgi-bin/uncgi/Earth?img=NOAAtopo.evif'
'&imgsize=320&dynimg=y&opt=-p&lat=&lon=&alt=&tle=&date=0&utc=&jd=')
with ctx.typing():
embed = cmn.embed_factory(ctx)
embed.title = 'Current Greyline Conditions'
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
async with self.session.get(gl_url) as resp: embed.set_image(url="attachment://" + metadata.filename)
if resp.status != 200: await ctx.send(embed=embed, file=img)
embed.description = 'Could not download file...'
embed.colour = cmn.colours.bad @commands.command(name="grayline", aliases=["greyline", "grey", "gray", "gl"], category=cmn.cat.maps)
else: async def _grayline(self, ctx: commands.Context):
data = io.BytesIO(await resp.read()) """Gets a map of the current greyline, where HF propagation is the best."""
embed.set_image(url=f'attachment://greyline.jpg') embed = cmn.embed_factory(ctx)
await ctx.send(embed=embed, file=discord.File(data, 'greyline.jpg')) embed.title = "Current Greyline Conditions"
embed.colour = cmn.colours.good
# Generate a nonce to force discord to recache this
cachenonce = (ctx.message.id >> 22) // 1000 // 600 # nonce will stay the same for ~10min
embed.set_image(url=self.gl_url + f"&cachenonce={cachenonce}")
await ctx.send(embed=embed)
def setup(bot: commands.Bot): def setup(bot: commands.Bot):
+44 -39
View File
@@ -1,72 +1,77 @@
""" """
Lookup extension for qrm Lookup extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import threading
from discord.ext import commands, tasks import threading
from pathlib import Path
from ctyparser import BigCty from ctyparser import BigCty
from discord.ext import commands, tasks
import common as cmn import common as cmn
cty_path = Path("./data/cty.json")
class LookupCog(commands.Cog): class LookupCog(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
try: try:
self.cty = BigCty('./data/cty.json') self.cty = BigCty(cty_path)
except OSError: except OSError:
self.cty = BigCty() self.cty = BigCty()
# TODO: See #107 # TODO: See #107
# @commands.command(name="sat", category=cmn.cat.lookup) # @commands.command(name="sat", category=cmn.cat.lookup)
# async def _sat_lookup(self, ctx: commands.Context, sat_name: str, grid1: str, grid2: str = None): # async def _sat_lookup(self, ctx: commands.Context, sat_name: str, grid1: str, grid2: str = None):
# '''Links to info about satellite passes on satmatch.com.''' # """Links to info about satellite passes on satmatch.com."""
# now = datetime.utcnow().strftime('%Y-%m-%d%%20%H:%M') # now = datetime.utcnow().strftime("%Y-%m-%d%%20%H:%M")
# if grid2 is None or grid2 == '': # if grid2 is None or grid2 == "":
# await ctx.send(f'http://www.satmatch.com/satellite/{sat_name}/obs1/{grid1}' # await ctx.send(f"http://www.satmatch.com/satellite/{sat_name}/obs1/{grid1}"
# f'?search_start_time={now}&duration_hrs=24') # f"?search_start_time={now}&duration_hrs=24")
# else: # else:
# await ctx.send(f'http://www.satmatch.com/satellite/{sat_name}/obs1/{grid1}' # await ctx.send(f"http://www.satmatch.com/satellite/{sat_name}/obs1/{grid1}"
# f'/obs2/{grid2}?search_start_time={now}&duration_hrs=24') # f"/obs2/{grid2}?search_start_time={now}&duration_hrs=24")
@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 info about a DXCC 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) embed.title = "DXCC Info for "
embed.title = f'DXCC Info for ' embed.description = f"*Last Updated: {self.cty.formatted_version}*"
embed.description = f'*Last Updated: {self.cty.formatted_version}*' embed.colour = cmn.colours.bad
embed.colour = cmn.colours.bad 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", value=data["entity"])
embed.add_field(name="Entity", value=data['entity']) embed.add_field(name="CQ Zone", value=data["cq"])
embed.add_field(name="CQ Zone", value=data['cq']) embed.add_field(name="ITU Zone", value=data["itu"])
embed.add_field(name="ITU Zone", value=data['itu']) embed.add_field(name="Continent", value=data["continent"])
embed.add_field(name="Continent", value=data['continent']) embed.add_field(name="Time Zone",
embed.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 embed.colour = cmn.colours.good
embed.colour = cmn.colours.good break
break
else:
query = query[:-1]
else: else:
embed.title += full_query + ' not found' query = query[:-1]
embed.colour = cmn.colours.bad else:
embed.title += full_query + " not found"
embed.colour = cmn.colours.bad
await ctx.send(embed=embed) await ctx.send(embed=embed)
@tasks.loop(hours=24) @tasks.loop(hours=24)
async def _update_cty(self): async def _update_cty(self):
update = threading.Thread(target=run_update, args=(self.cty, "./data/cty.json")) update = threading.Thread(target=run_update, args=(self.cty, cty_path))
update.start() update.start()
+54 -56
View File
@@ -1,12 +1,13 @@
""" """
Morse Code extension for qrm Morse Code extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import discord.ext.commands as commands import discord.ext.commands as commands
import common as cmn import common as cmn
@@ -17,64 +18,61 @@ class MorseCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
@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: result += morse.morse[char]
result += morse.morse[char] except KeyError:
except KeyError: result += "<?>"
result += '<?>' result += " "
result += ' '
embed = cmn.embed_factory(ctx)
embed.title = f'Morse Code for {msg}'
embed.description = '**' + result + '**'
embed.colour = cmn.colours.good
await ctx.send(embed=embed)
@commands.command(name="unmorse", aliases=['demorse', 'uncw', 'decw'], category=cmn.cat.ref)
async def _unmorse(self, ctx: commands.Context, *, msg: str):
'''Converts international morse code to ASCII.'''
with ctx.typing():
result = ''
msg0 = msg
msg = msg.split('/')
msg = [m.split() for m in msg]
for word in msg:
for char in word:
try:
result += morse.ascii[char]
except KeyError:
result += '<?>'
result += ' '
embed = cmn.embed_factory(ctx)
embed.title = f'ASCII for {msg0}'
embed.description = result
embed.colour = cmn.colours.good
await ctx.send(embed=embed)
@commands.command(name="cwweight", aliases=["weight", 'cww'], category=cmn.cat.ref)
async def _weight(self, ctx: commands.Context, *, msg: str):
'''Calculates the CW Weight of a callsign or message.'''
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
with ctx.typing(): embed.title = f"Morse Code for {msg}"
msg = msg.upper() embed.description = "**" + result + "**"
weight = 0 embed.colour = cmn.colours.good
for char in msg: await ctx.send(embed=embed)
@commands.command(name="unmorse", aliases=["demorse", "uncw", "decw"], category=cmn.cat.ref)
async def _unmorse(self, ctx: commands.Context, *, msg: str):
"""Converts international morse code to ASCII."""
result = ""
msg0 = msg
msg = msg.split("/")
msg = [m.split() for m in msg]
for word in msg:
for char in word:
try: try:
cw_char = morse.morse[char].replace('-', '==') result += morse.ascii[char]
weight += len(cw_char) * 2 + 2
except KeyError: except KeyError:
embed.title = 'Error in calculation of CW weight' result += "<?>"
embed.description = f'Unknown character {char} in callsign' result += " "
embed.colour = cmn.colours.bad embed = cmn.embed_factory(ctx)
await ctx.send(embed=embed) embed.title = f"ASCII for {msg0}"
return embed.description = result
embed.title = f'CW Weight of {msg}' embed.colour = cmn.colours.good
embed.description = f'The CW weight is **{weight}**' await ctx.send(embed=embed)
embed.colour = cmn.colours.good
@commands.command(name="cwweight", aliases=["weight", "cww"], category=cmn.cat.ref)
async def _weight(self, ctx: commands.Context, *, msg: str):
"""Calculates the CW weight of a callsign or message."""
embed = cmn.embed_factory(ctx)
msg = msg.upper()
weight = 0
for char in msg:
try:
cw_char = morse.morse[char].replace("-", "==")
weight += len(cw_char) * 2 + 2
except KeyError:
embed.title = "Error in calculation of CW weight"
embed.description = f"Unknown character `{char}` in message"
embed.colour = cmn.colours.bad
await ctx.send(embed=embed)
return
embed.title = f"CW Weight of {msg}"
embed.description = f"The CW weight is **{weight}**"
embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
+108 -105
View File
@@ -1,92 +1,97 @@
""" """
QRZ extension for qrm QRZ extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
from collections import OrderedDict
from io import BytesIO
from discord.ext import commands, tasks
from io import BytesIO
import aiohttp import aiohttp
from lxml import etree from lxml import etree
from discord.ext import commands, tasks
import common as cmn import common as cmn
import data.keys as keys import data.keys as keys
class QRZCog(commands.Cog): class QRZCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
self.session = bot.qrm.session self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
self._qrz_session_init.start() self._qrz_session_init.start()
@commands.command(name="call", aliases=["qrz"], category=cmn.cat.lookup) @commands.command(name="call", aliases=["qrz"], category=cmn.cat.lookup)
async def _qrz_lookup(self, ctx: commands.Context, callsign: str): async def _qrz_lookup(self, ctx: commands.Context, callsign: str, *flags):
'''Look up a callsign on [QRZ.com](https://www.qrz.com/).''' """Looks up a callsign on [QRZ.com](https://www.qrz.com/). Add `--link` to only link the QRZ page."""
if keys.qrz_user == '' or keys.qrz_pass == '': flags = [f.lower() for f in flags]
await ctx.send(f'http://qrz.com/db/{callsign}')
if keys.qrz_user == "" or keys.qrz_pass == "" or "--link" in flags:
await ctx.send(f"http://qrz.com/db/{callsign}")
return return
try: async with ctx.typing():
await qrz_test_session(self.key, self.session) try:
except ConnectionError: await qrz_test_session(self.key, self.session)
await self.get_session() except ConnectionError:
url = f'http://xmldata.qrz.com/xml/current/?s={self.key};callsign={callsign}'
async with self.session.get(url) as resp:
if resp.status != 200:
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
with BytesIO(await resp.read()) as resp_file:
resp_xml = etree.parse(resp_file).getroot()
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
if 'Error' in resp_session:
if 'Session Timeout' in resp_session['Error']:
await self.get_session() await self.get_session()
await self._qrz_lookup(ctx, callsign)
return
if 'Not found' in resp_session['Error']:
embed = cmn.embed_factory(ctx)
embed.title = f"QRZ Data for {callsign.upper()}"
embed.colour = cmn.colours.bad
embed.description = 'No data found!'
await ctx.send(embed=embed)
return
raise ValueError(resp_session['Error'])
resp_xml_data = resp_xml.xpath('/x:QRZDatabase/x:Callsign', namespaces={'x': 'http://xmldata.qrz.com'}) url = f"http://xmldata.qrz.com/xml/current/?s={self.key};callsign={callsign}"
resp_data = {el.tag.split('}')[1]: el.text for el in resp_xml_data[0].getiterator()} async with self.session.get(url) as resp:
if resp.status != 200:
raise ConnectionError(f"Unable to connect to QRZ (HTTP Error {resp.status})")
with BytesIO(await resp.read()) as resp_file:
resp_xml = etree.parse(resp_file).getroot()
embed = cmn.embed_factory(ctx) resp_xml_session = resp_xml.xpath("/x:QRZDatabase/x:Session", namespaces={"x": "http://xmldata.qrz.com"})
embed.title = f"QRZ Data for {resp_data['call']}" resp_session = {el.tag.split("}")[1]: el.text for el in resp_xml_session[0].getiterator()}
embed.colour = cmn.colours.good if "Error" in resp_session:
embed.url = f'http://www.qrz.com/db/{resp_data["call"]}' if "Session Timeout" in resp_session["Error"]:
if 'image' in resp_data: await self.get_session()
embed.set_thumbnail(url=resp_data['image']) await self._qrz_lookup(ctx, callsign)
return
if "Not found" in resp_session["Error"]:
embed = cmn.embed_factory(ctx)
embed.title = f"QRZ Data for {callsign.upper()}"
embed.colour = cmn.colours.bad
embed.description = "No data found!"
await ctx.send(embed=embed)
return
raise ValueError(resp_session["Error"])
data = qrz_process_info(resp_data) resp_xml_data = resp_xml.xpath("/x:QRZDatabase/x:Callsign", namespaces={"x": "http://xmldata.qrz.com"})
resp_data = {el.tag.split("}")[1]: el.text for el in resp_xml_data[0].getiterator()}
for title, val in data.items(): embed = cmn.embed_factory(ctx)
if val is not None: embed.title = f"QRZ Data for {resp_data['call']}"
embed.add_field(name=title, value=val, inline=True) embed.colour = cmn.colours.good
await ctx.send(embed=embed) embed.url = f"http://www.qrz.com/db/{resp_data['call']}"
if "image" in resp_data:
embed.set_thumbnail(url=resp_data["image"])
data = qrz_process_info(resp_data)
for title, val in data.items():
if val is not None:
embed.add_field(name=title, value=val, inline=True)
await ctx.send(embed=embed)
async def get_session(self): async def get_session(self):
"""Session creation and caching.""" """Session creation and caching."""
self.key = await qrz_login(keys.qrz_user, keys.qrz_pass, self.session) self.key = await qrz_login(keys.qrz_user, keys.qrz_pass, self.session)
with open('data/qrz_session', 'w') as qrz_file: with open("data/qrz_session", "w") as qrz_file:
qrz_file.write(self.key) qrz_file.write(self.key)
@tasks.loop(count=1) @tasks.loop(count=1)
async def _qrz_session_init(self): async def _qrz_session_init(self):
"""Helper task to allow obtaining a session at cog instantiation.""" """Helper task to allow obtaining a session at cog instantiation."""
try: try:
with open('data/qrz_session') as qrz_file: with open("data/qrz_session") as qrz_file:
self.key = qrz_file.readline().strip() self.key = qrz_file.readline().strip()
await qrz_test_session(self.key, self.session) await qrz_test_session(self.key, self.session)
except (FileNotFoundError, ConnectionError): except (FileNotFoundError, ConnectionError):
@@ -94,85 +99,83 @@ class QRZCog(commands.Cog):
async def qrz_login(user: str, passwd: str, session: aiohttp.ClientSession): async def qrz_login(user: str, passwd: str, session: aiohttp.ClientSession):
url = f'http://xmldata.qrz.com/xml/current/?username={user};password={passwd};agent=discord-qrm2' url = f"http://xmldata.qrz.com/xml/current/?username={user};password={passwd};agent=discord-qrm2"
async with session.get(url) as resp: async with session.get(url) as resp:
if resp.status != 200: if resp.status != 200:
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})') raise ConnectionError(f"Unable to connect to QRZ (HTTP Error {resp.status})")
with BytesIO(await resp.read()) as resp_file: with BytesIO(await resp.read()) as resp_file:
resp_xml = etree.parse(resp_file).getroot() resp_xml = etree.parse(resp_file).getroot()
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'}) resp_xml_session = resp_xml.xpath("/x:QRZDatabase/x:Session", 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"])
if resp_session['SubExp'] == 'non-subscriber': if resp_session["SubExp"] == "non-subscriber":
raise ConnectionError('Invalid QRZ Subscription') raise ConnectionError("Invalid QRZ Subscription")
return resp_session['Key'] return resp_session["Key"]
async def qrz_test_session(key: str, session: aiohttp.ClientSession): async def qrz_test_session(key: str, session: aiohttp.ClientSession):
url = f'http://xmldata.qrz.com/xml/current/?s={key}' url = f"http://xmldata.qrz.com/xml/current/?s={key}"
async with session.get(url) as resp: async with session.get(url) as resp:
if resp.status != 200: if resp.status != 200:
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})') raise ConnectionError(f"Unable to connect to QRZ (HTTP Error {resp.status})")
with BytesIO(await resp.read()) as resp_file: with BytesIO(await resp.read()) as resp_file:
resp_xml = etree.parse(resp_file).getroot() resp_xml = etree.parse(resp_file).getroot()
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'}) resp_xml_session = resp_xml.xpath("/x:QRZDatabase/x:Session", 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"])
def qrz_process_info(data: dict): def qrz_process_info(data: dict):
if 'name' in data: if "name" in data:
if 'fname' in data: if "fname" in data:
name = data['fname'] + ' ' + data['name'] name = data["fname"] + " " + data["name"]
else: else:
name = data['name'] name = data["name"]
else: else:
name = None name = None
if 'state' in data: if "state" in data:
state = f', {data["state"]}' state = f", {data['state']}"
else: else:
state = '' state = ""
address = data.get('addr1', '') + '\n' + data.get('addr2', '') + state + ' ' + data.get('zip', '') address = data.get("addr1", "") + "\n" + data.get("addr2", "") + state + " " + data.get("zip", "")
address = address.strip() address = address.strip()
if address == '': if address == "":
address = None address = None
if 'eqsl' in data: if "eqsl" in data:
eqsl = 'Yes' if data['eqsl'] == 1 else 'No' eqsl = "Yes" if data["eqsl"] == "1" else "No"
else: else:
eqsl = 'Unknown' eqsl = "Unknown"
if 'mqsl' in data: if "mqsl" in data:
mqsl = 'Yes' if data['mqsl'] == 1 else 'No' mqsl = "Yes" if data["mqsl"] == "1" else "No"
else: else:
mqsl = 'Unknown' mqsl = "Unknown"
if 'lotw' in data: if "lotw" in data:
lotw = 'Yes' if data['lotw'] == 1 else 'No' lotw = "Yes" if data["lotw"] == "1" else "No"
else: else:
lotw = 'Unknown' lotw = "Unknown"
return OrderedDict([('Name', name), return {"Name": name,
('Country', data.get('country', None)), "Country": data.get("country", None),
('Address', address), "Address": address,
('Grid Square', data.get('grid', None)), "Grid Square": data.get("grid", None),
('County', data.get('county', None)), "County": data.get("county", None),
('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),
('Expires', data.get('expdate', None)), "Expires": data.get("expdate", None),
('Aliases', data.get('aliases', None)), "Aliases": data.get("aliases", None),
('Previous Callsign', data.get('p_call', None)), "Previous Callsign": data.get("p_call", None),
('License Class', data.get('class', None)), "License Class": data.get("class", None),
('eQSL?', eqsl), "Trustee": data.get("trustee", None),
('Paper QSL?', mqsl), "eQSL?": eqsl,
('LotW?', lotw), "Paper QSL?": mqsl,
('QSL Info', data.get('qslmgr', None)), "LotW?": lotw,
('CQ Zone', data.get('cqzone', None)), "QSL Info": data.get("qslmgr", None),
('ITU Zone', data.get('ituzone', None)), "Born": data.get("born", None)}
('IOTA Designator', data.get('iota', None)),
('Born', data.get('born', None))])
def setup(bot): def setup(bot):
+144 -77
View File
@@ -1,117 +1,184 @@
""" """
Study extension for qrm Study extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import random import random
import json import json
from datetime import datetime
import asyncio
import aiohttp
import discord.ext.commands as commands import discord.ext.commands as commands
import common as cmn import common as cmn
from resources import study
class StudyCog(commands.Cog): class StudyCog(commands.Cog):
choices = {cmn.emojis.a: "A", cmn.emojis.b: "B", cmn.emojis.c: "C", cmn.emojis.d: "D"}
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
self.lastq = dict() self.lastq = dict()
self.source = 'Data courtesy of [HamStudy.org](https://hamstudy.org/)' self.source = "Data courtesy of [HamStudy.org](https://hamstudy.org/)"
self.session = bot.qrm.session self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.command(name="hamstudy", aliases=['rq', 'randomquestion', 'randomq'], category=cmn.cat.study) @commands.command(name="hamstudy", aliases=["rq", "randomquestion", "randomq"], category=cmn.cat.study)
async def _random_question(self, ctx: commands.Context, level: str = None): async def _random_question(self, ctx: commands.Context, country: str = "", level: str = ""):
'''Gets a random question from the Technician, General, and/or Extra question pools.''' """Gets a random question from [HamStudy's](https://hamstudy.org) question pools."""
tech_pool = 'E2_2018'
gen_pool = 'E3_2019'
extra_pool = 'E4_2016'
embed = cmn.embed_factory(ctx)
with ctx.typing(): with ctx.typing():
selected_pool = None embed = cmn.embed_factory(ctx)
try:
level = level.lower()
except AttributeError: # no level given (it's None)
pass
if level in ['t', 'technician', 'tech']: country = country.lower()
selected_pool = tech_pool level = level.lower()
if level in ['g', 'gen', 'general']: if country in study.pool_names.keys():
selected_pool = gen_pool if level in study.pool_names[country].keys():
pool_name = study.pool_names[country][level]
if level in ['e', 'ae', 'extra']: elif level in ("random", "r"):
selected_pool = extra_pool # select a random level in that country
pool_name = random.choice(list(study.pool_names[country].values()))
if (level is None) or (level == 'all'): # no pool given or user wants all, so pick a random pool else:
selected_pool = random.choice([tech_pool, gen_pool, extra_pool]) # show list of possible pools
if (level is not None) and (selected_pool is None): # unrecognized pool given by user embed.title = "Pool Not Found!"
embed.title = 'Error in HamStudy command' embed.description = "Possible arguments are:"
embed.description = ('The question pool you gave was unrecognized. ' embed.colour = cmn.colours.bad
'There are many ways to call up certain question pools - try ?rq t, g, or e. ' for cty in study.pool_names:
'\n\nNote that currently only the US question pools are available.') levels = "`, `".join(study.pool_names[cty].keys())
embed.add_field(name=f"**Country: `{cty}` {study.pool_emojis[cty]}**",
value=f"Levels: `{levels}`", inline=False)
embed.add_field(name="**Random**", value="To select a random pool or country, use `random` or `r`")
await ctx.send(embed=embed)
return
elif country in ("random", "r"):
# select a random country and level
country = random.choice(list(study.pool_names.keys()))
pool_name = random.choice(list(study.pool_names[country].values()))
else:
# show list of possible pools
embed.title = "Pool Not Found!"
embed.description = "Possible arguments are:"
embed.colour = cmn.colours.bad embed.colour = cmn.colours.bad
for cty in study.pool_names:
levels = "`, `".join(study.pool_names[cty].keys())
embed.add_field(name=f"**Country: `{cty}` {study.pool_emojis[cty]}**",
value=f"Levels: `{levels}`", inline=False)
embed.add_field(name="**Random**", value="To select a random pool or country, use `random` or `r`")
await ctx.send(embed=embed) await ctx.send(embed=embed)
return return
async with self.session.get(f'https://hamstudy.org/pools/{selected_pool}') as resp: pools = await self.hamstudy_get_pools()
pool_matches = [p for p in pools.keys() if "_".join(p.split("_")[:-1]) == pool_name]
if len(pool_matches) > 0:
if len(pool_matches) == 1:
pool = pool_matches[0]
else:
# look at valid_from and expires dates to find the correct one
for p in pool_matches:
valid_from = datetime.fromisoformat(pools[p]["valid_from"][:-1])
expires = datetime.fromisoformat(pools[p]["expires"][:-1])
if valid_from < datetime.utcnow() < expires:
pool = p
break
else:
# show list of possible pools
embed.title = "Pool Not Found!"
embed.description = "Possible arguments are:"
embed.colour = cmn.colours.bad
for cty in study.pool_names:
levels = "`, `".join(study.pool_names[cty].keys())
embed.add_field(name=f"**Country: `{cty}` {study.pool_emojis[cty]}**",
value=f"Levels: `{levels}`", inline=False)
embed.add_field(name="**Random**", value="To select a random pool or country, use `random` or `r`")
await ctx.send(embed=embed)
return
pool_meta = pools[pool]
async with self.session.get(f"https://hamstudy.org/pools/{pool}") as resp:
if resp.status != 200: if resp.status != 200:
embed.title = 'Error in HamStudy command' raise cmn.BotHTTPError(resp)
embed.description = 'Could not load questions' pool = json.loads(await resp.read())["pool"]
embed.colour = cmn.colours.bad
await ctx.send(embed=embed)
return
pool = json.loads(await resp.read())['pool']
# Select a question # Select a question
pool_section = random.choice(pool)['sections'] pool_section = random.choice(pool)["sections"]
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.title = question['id'] embed.title = f"{study.pool_emojis[country]} {pool_meta['class']} {question['id']}"
embed.description = self.source embed.description = self.source
embed.colour = cmn.colours.good embed.add_field(name="Question:", value=question["text"], inline=False)
embed.add_field(name='Question:', value=question['text'], inline=False) embed.add_field(name="Answers:",
embed.add_field(name='Answers:', value='**A:** ' + question['answers']['A'] value=(f"**{cmn.emojis.a}** {question['answers']['A']}"
+ '\n**B:** ' + question['answers']['B'] f"\n**{cmn.emojis.b}** {question['answers']['B']}"
+ '\n**C:** ' + question['answers']['C'] f"\n**{cmn.emojis.c}** {question['answers']['C']}"
+ '\n**D:** ' + question['answers']['D'], inline=False) f"\n**{cmn.emojis.d}** {question['answers']['D']}"),
embed.add_field(name='Answer:', value='Type _?rqa_ for answer', inline=False) inline=False)
if 'image' in question: embed.add_field(name="To Answer:",
image_url = f'https://hamstudy.org/_1330011/images/{selected_pool.split("_",1)[1]}/{question["image"]}' value=("Answer with reactions below. If not answered within 10 minutes,"
" the answer will be revealed."),
inline=False)
if "image" in question:
image_url = f"https://hamstudy.org/images/{pool_meta['year']}/{question['image']}"
embed.set_image(url=image_url) embed.set_image(url=image_url)
self.lastq[ctx.message.channel.id] = (question['id'], question['answer'])
await ctx.send(embed=embed)
@commands.command(name="hamstudyanswer", aliases=['rqa', 'randomquestionanswer', 'randomqa', 'hamstudya'], q_msg = await ctx.send(embed=embed)
category=cmn.cat.study)
async def _q_answer(self, ctx: commands.Context, answer: str = None): await cmn.add_react(q_msg, cmn.emojis.a)
'''Returns the answer to question last asked (Optional argument: your answer).''' await cmn.add_react(q_msg, cmn.emojis.b)
with ctx.typing(): await cmn.add_react(q_msg, cmn.emojis.c)
correct_ans = self.lastq[ctx.message.channel.id][1] await cmn.add_react(q_msg, cmn.emojis.d)
q_num = self.lastq[ctx.message.channel.id][0]
embed = cmn.embed_factory(ctx) def check(reaction, user):
if answer is not None: return (user.id != self.bot.user.id
answer = answer.upper() and reaction.message.id == q_msg.id
if answer == correct_ans: and str(reaction.emoji) in self.choices.keys())
result = f'Correct! The answer to {q_num} was **{correct_ans}**.'
embed.title = f'{q_num} Answer' try:
embed.description = f'{self.source}\n\n{result}' reaction, user = await self.bot.wait_for("reaction_add", timeout=600.0, check=check)
embed.colour = cmn.colours.good except asyncio.TimeoutError:
else: embed.remove_field(2)
result = f'Incorrect. The answer to {q_num} was **{correct_ans}**, not **{answer}**.' embed.add_field(name="Answer:", value=f"Timed out! The correct answer was **{question['answer']}**.")
embed.title = f'{q_num} Answer' await q_msg.edit(embed=embed)
embed.description = f'{self.source}\n\n{result}' else:
embed.colour = cmn.colours.bad if self.choices[str(reaction.emoji)] == question["answer"]:
embed.remove_field(2)
embed.add_field(name="Answer:", value=f"Correct! The answer was **{question['answer']}**.")
embed.colour = cmn.colours.good
await q_msg.edit(embed=embed)
else: else:
result = f'The correct answer to {q_num} was **{correct_ans}**.' embed.remove_field(2)
embed.title = f'{q_num} Answer' embed.add_field(name="Answer:", value=f"Incorrect! The correct answer was **{question['answer']}**.")
embed.description = f'{self.source}\n\n{result}' embed.colour = cmn.colours.bad
embed.colour = cmn.colours.neutral await q_msg.edit(embed=embed)
await ctx.send(embed=embed)
async def hamstudy_get_pools(self):
async with self.session.get("https://hamstudy.org/pools/") as resp:
if resp.status != 200:
raise cmn.BotHTTPError(resp)
else:
pools_dict = json.loads(await resp.read())
pools = dict()
for ls in pools_dict.values():
for pool in ls:
pools[pool["id"]] = pool
return pools
def setup(bot: commands.Bot): def setup(bot: commands.Bot):
+68 -87
View File
@@ -1,16 +1,17 @@
""" """
Weather extension for qrm Weather extension for qrm
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import io
import re import re
import discord import aiohttp
import discord.ext.commands as commands import discord.ext.commands as commands
import common as cmn import common as cmn
@@ -21,105 +22,85 @@ class WeatherCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
self.session = bot.qrm.session self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.command(name="bandconditions", aliases=['cond', 'condx', 'conditions'], category=cmn.cat.weather) @commands.command(name="bandconditions", aliases=["cond", "condx", "conditions"], category=cmn.cat.weather)
async def _band_conditions(self, ctx: commands.Context): async def _band_conditions(self, ctx: commands.Context):
'''Posts an image of HF Band Conditions.''' """Gets a solar conditions report."""
with ctx.typing(): embed = cmn.embed_factory(ctx)
embed = cmn.embed_factory(ctx) embed.title = "Current Solar Conditions"
embed.title = 'Current Solar Conditions' embed.colour = cmn.colours.good
embed.colour = cmn.colours.good embed.set_image(url="http://www.hamqsl.com/solarsun.php")
async with self.session.get('http://www.hamqsl.com/solarsun.php') as resp: await ctx.send(embed=embed)
if resp.status != 200:
embed.description = 'Could not download file...'
embed.colour = cmn.colours.bad
else:
data = io.BytesIO(await resp.read())
embed.set_image(url=f'attachment://condx.png')
await ctx.send(embed=embed, file=discord.File(data, 'condx.png'))
@commands.group(name="weather", aliases=['wttr'], category=cmn.cat.weather) @commands.group(name="weather", aliases=["wttr"], case_insensitive=True, category=cmn.cat.weather)
async def _weather_conditions(self, ctx: commands.Context): async def _weather_conditions(self, ctx: commands.Context):
'''Posts an image of Local Weather Conditions from [wttr.in](http://wttr.in/). """Gets local weather conditions from [wttr.in](http://wttr.in/).
*Supported location types:* *Supported location types:*
city name: `paris` city name: `paris`
any location: `~Eiffel Tower` any location: `~Eiffel Tower`
Unicode name of any location in any language: `Москва` Unicode name of any location in any language: `Москва`
airport code (3 letters): `muc` airport code (3 letters): `muc`
domain name `@stackoverflow.com` domain name `@stackoverflow.com`
area codes: `12345` area codes: `12345`
GPS coordinates: `-78.46,106.79` GPS coordinates: `-78.46,106.79`
'''
Add a `-c` or `-f` to use Celcius or Fahrenheit: `-c YSC`"""
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help(ctx.command) await ctx.send_help(ctx.command)
@_weather_conditions.command(name='forecast', aliases=['fc', 'future'], category=cmn.cat.weather) @_weather_conditions.command(name="forecast", aliases=["fc", "future"], category=cmn.cat.weather)
async def _weather_conditions_forecast(self, ctx: commands.Context, *, location: str): async def _weather_conditions_forecast(self, ctx: commands.Context, *, location: str):
'''Posts an image of Local Weather Conditions for the next three days from [wttr.in](http://wttr.in/). """Gets local weather forecast for the next three days from [wttr.in](http://wttr.in/).
See help for weather command for possible location types. Add a `-c` or `-f` to use Celcius or Fahrenheit.''' See help of the `weather` command for possible location types and options."""
with ctx.typing(): try:
try: units_arg = re.search(self.wttr_units_regex, location).group(1)
units_arg = re.search(self.wttr_units_regex, location).group(1) except AttributeError:
except AttributeError: units_arg = ""
units_arg = '' if units_arg.lower() == "f":
if units_arg.lower() == 'f': units = "u"
units = 'u' elif units_arg.lower() == "c":
elif units_arg.lower() == 'c': units = "m"
units = 'm' else:
else: units = ""
units = ''
loc = self.wttr_units_regex.sub('', location).strip() loc = self.wttr_units_regex.sub("", location).strip()
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = f'Weather Forecast for {loc}' embed.title = f"Weather Forecast for {loc}"
embed.description = 'Data from [wttr.in](http://wttr.in/).' embed.description = "Data from [wttr.in](http://wttr.in/)."
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
loc = loc.replace(' ', '+') loc = loc.replace(" ", "+")
async with self.session.get(f'http://wttr.in/{loc}_{units}pnFQ.png') as resp: embed.set_image(url=f"http://wttr.in/{loc}_{units}pnFQ.png")
if resp.status != 200: await ctx.send(embed=embed)
embed.description = 'Could not download file...'
embed.colour = cmn.colours.bad
else:
data = io.BytesIO(await resp.read())
embed.set_image(url=f'attachment://wttr_forecast.png')
await ctx.send(embed=embed, file=discord.File(data, 'wttr_forecast.png'))
@_weather_conditions.command(name='now', aliases=['n'], category=cmn.cat.weather) @_weather_conditions.command(name="now", aliases=["n"], category=cmn.cat.weather)
async def _weather_conditions_now(self, ctx: commands.Context, *, location: str): async def _weather_conditions_now(self, ctx: commands.Context, *, location: str):
'''Posts an image of current Local Weather Conditions from [wttr.in](http://wttr.in/). """Gets current local weather conditions from [wttr.in](http://wttr.in/).
See help for weather command for possible location types. Add a `-c` or `-f` to use Celcius or Fahrenheit.''' See help of the `weather` command for possible location types and options."""
with ctx.typing(): try:
try: units_arg = re.search(self.wttr_units_regex, location).group(1)
units_arg = re.search(self.wttr_units_regex, location).group(1) except AttributeError:
except AttributeError: units_arg = ""
units_arg = '' if units_arg.lower() == "f":
if units_arg.lower() == 'f': units = "u"
units = 'u' elif units_arg.lower() == "c":
elif units_arg.lower() == 'c': units = "m"
units = 'm' else:
else: units = ""
units = ''
loc = self.wttr_units_regex.sub('', location).strip() loc = self.wttr_units_regex.sub("", location).strip()
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = f'Current Weather for {loc}' embed.title = f"Current Weather for {loc}"
embed.description = 'Data from [wttr.in](http://wttr.in/).' embed.description = "Data from [wttr.in](http://wttr.in/)."
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
loc = loc.replace(' ', '+') loc = loc.replace(" ", "+")
async with self.session.get(f'http://wttr.in/{loc}_0{units}pnFQ.png') as resp: embed.set_image(url=f"http://wttr.in/{loc}_0{units}pnFQ.png")
if resp.status != 200: await ctx.send(embed=embed)
embed.description = 'Could not download file...'
embed.colour = cmn.colours.bad
else:
data = io.BytesIO(await resp.read())
embed.set_image(url=f'attachment://wttr_now.png')
await ctx.send(embed=embed, file=discord.File(data, 'wttr_now.png'))
def setup(bot: commands.Bot): def setup(bot: commands.Bot):
+7 -19
View File
@@ -1,28 +1,16 @@
""" """
Static info about the bot. Static info about the bot.
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
---
`authors`: The authors of the bot.
`description`: A description of the bot.
`license`: The license the bot is released under.
`contrubuting`: Info on how to contribute to the bot.
`release`: Current bot version.
`release_timestamp`: When the bot was last released.
""" """
authors = ("@ClassAbbyAmplifier#2229", "@0x5c#0639") authors = ("@ClassAbbyAmplifier#2229", "@0x5c#0639")
description = """A bot with various useful ham radio-related functions, written in Python.""" description = """A bot with various useful ham radio-related functions, written in Python."""
license = "Released under the GNU General Public License v2" license = "Released under the GNU General Public License v2"
contributing = "Check out the source on GitHub, contributions welcome: https://github.com/classabbyamp/discord-qrm2" contributing = "Check out the source on GitHub, contributions welcome: https://github.com/miaowware/qrm2"
release = '2.1.0' release = "2.5.1"
bot_server = 'https://discord.gg/Ntbg3J4' bot_server = "https://discord.gg/Ntbg3J4"
+69 -46
View File
@@ -2,29 +2,31 @@
""" """
qrm, a bot for Discord qrm, a bot for Discord
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrm2 and is released under the terms of the GNU This file is part of qrm2 and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
import asyncio
import random
import sys import sys
import traceback import traceback
from datetime import time, datetime from datetime import datetime, time
import random
from types import SimpleNamespace from types import SimpleNamespace
import pytz import pytz
import aiohttp
import discord import discord
from discord.ext import commands, tasks from discord.ext import commands, tasks
import common as cmn
import info import info
import data.options as opt import common as cmn
import utils.connector as conn
import data.keys as keys import data.keys as keys
import data.options as opt
# --- Settings --- # --- Settings ---
@@ -38,23 +40,41 @@ debug_mode = opt.debug # Separate assignement in-case we define an override (te
# --- Bot setup --- # --- Bot setup ---
# Loop/aiohttp stuff
loop = asyncio.get_event_loop()
connector = loop.run_until_complete(conn.new_connector())
# Defining the intents
intents = discord.Intents.none()
intents.guilds = True
intents.guild_messages = True
intents.dm_messages = True
intents.reactions = True
member_cache = discord.MemberCacheFlags.from_intents(intents)
bot = commands.Bot(command_prefix=opt.prefix, bot = commands.Bot(command_prefix=opt.prefix,
description=info.description, case_insensitive=True,
help_command=commands.MinimalHelpCommand()) description=info.description, help_command=commands.MinimalHelpCommand(),
intents=intents,
member_cache=member_cache,
loop=loop,
connector=connector)
# Simple way to access bot-wide stuff in extensions.
bot.qrm = SimpleNamespace() bot.qrm = SimpleNamespace()
bot.qrm.session = aiohttp.ClientSession(headers={'User-Agent': f'discord-qrm2/{info.release}'})
# Let's store stuff here.
bot.qrm.connector = connector
bot.qrm.debug_mode = debug_mode bot.qrm.debug_mode = debug_mode
# --- Commands --- # --- Commands ---
@bot.command(name="restart", hidden=True) @bot.command(name="restart", aliases=["rs"], category=cmn.cat.admin)
@commands.check(cmn.check_if_owner) @commands.check(cmn.check_if_owner)
async def _restart_bot(ctx: commands.Context): async def _restart_bot(ctx: commands.Context):
"""Restarts the bot.""" """Restarts the bot."""
await bot.qrm.session.close()
global exit_code global exit_code
await cmn.add_react(ctx.message, cmn.emojis.check_mark) await cmn.add_react(ctx.message, cmn.emojis.check_mark)
print(f"[**] Restarting! Requested by {ctx.author}.") print(f"[**] Restarting! Requested by {ctx.author}.")
@@ -62,11 +82,10 @@ async def _restart_bot(ctx: commands.Context):
await bot.logout() await bot.logout()
@bot.command(name="shutdown", hidden=True) @bot.command(name="shutdown", aliases=["shut"], category=cmn.cat.admin)
@commands.check(cmn.check_if_owner) @commands.check(cmn.check_if_owner)
async def _shutdown_bot(ctx: commands.Context): async def _shutdown_bot(ctx: commands.Context):
"""Shuts down the bot.""" """Shuts down the bot."""
await bot.qrm.session.close()
global exit_code global exit_code
await cmn.add_react(ctx.message, cmn.emojis.check_mark) await cmn.add_react(ctx.message, cmn.emojis.check_mark)
print(f"[**] Shutting down! Requested by {ctx.author}.") print(f"[**] Shutting down! Requested by {ctx.author}.")
@@ -74,57 +93,48 @@ async def _shutdown_bot(ctx: commands.Context):
await bot.logout() await bot.logout()
@bot.group(name="extctl", hidden=True) @bot.group(name="extctl", aliases=["ex"], case_insensitive=True, category=cmn.cat.admin)
@commands.check(cmn.check_if_owner) @commands.check(cmn.check_if_owner)
async def _extctl(ctx: commands.Context): async def _extctl(ctx: commands.Context):
"""Extension control commands. """Extension control commands.
Defaults to `list` if no subcommand specified""" Defaults to `list` if no subcommand specified"""
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
cmd = bot.get_command("extctl list") cmd = _extctl_list
await ctx.invoke(cmd) await ctx.invoke(cmd)
@_extctl.command(name="list") @_extctl.command(name="list", aliases=["ls"])
async def _extctl_list(ctx: commands.Context): async def _extctl_list(ctx: commands.Context):
"""Lists Extensions.""" """Lists loaded extensions."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = "Loaded Extensions" embed.title = "Loaded Extensions"
embed.description = "\n".join(["" + x.split(".")[1] for x in bot.extensions.keys()]) embed.description = "\n".join(["" + x.split(".")[1] for x in bot.extensions.keys()])
await ctx.send(embed=embed) await ctx.send(embed=embed)
@_extctl.command(name="load") @_extctl.command(name="load", aliases=["ld"])
async def _extctl_load(ctx: commands.Context, extension: str): async def _extctl_load(ctx: commands.Context, extension: str):
try: """Loads an extension."""
bot.load_extension(ext_dir + "." + extension) bot.load_extension(ext_dir + "." + extension)
await cmn.add_react(ctx.message, cmn.emojis.check_mark) await cmn.add_react(ctx.message, cmn.emojis.check_mark)
except commands.ExtensionError as ex:
embed = cmn.error_embed_factory(ctx, ex, bot.qrm.debug_mode)
await ctx.send(embed=embed)
@_extctl.command(name="reload", aliases=["relaod"]) @_extctl.command(name="reload", aliases=["rl", "r", "relaod"])
async def _extctl_reload(ctx: commands.Context, extension: str): async def _extctl_reload(ctx: commands.Context, extension: str):
"""Reloads an extension."""
if ctx.invoked_with == "relaod": if ctx.invoked_with == "relaod":
pika = bot.get_emoji(opt.pika) pika = bot.get_emoji(opt.pika)
if pika: if pika:
await cmn.add_react(ctx.message, pika) await cmn.add_react(ctx.message, pika)
try: bot.reload_extension(ext_dir + "." + extension)
bot.reload_extension(ext_dir + "." + extension) await cmn.add_react(ctx.message, cmn.emojis.check_mark)
await cmn.add_react(ctx.message, cmn.emojis.check_mark)
except commands.ExtensionError as ex:
embed = cmn.error_embed_factory(ctx, ex, bot.qrm.debug_mode)
await ctx.send(embed=embed)
@_extctl.command(name="unload") @_extctl.command(name="unload", aliases=["ul"])
async def _extctl_unload(ctx: commands.Context, extension: str): async def _extctl_unload(ctx: commands.Context, extension: str):
try: """Unloads an extension."""
bot.unload_extension(ext_dir + "." + extension) bot.unload_extension(ext_dir + "." + extension)
await cmn.add_react(ctx.message, cmn.emojis.check_mark) await cmn.add_react(ctx.message, cmn.emojis.check_mark)
except commands.ExtensionError as ex:
embed = cmn.error_embed_factory(ctx, ex, bot.qrm.debug_mode)
await ctx.send(embed=embed)
# --- Events --- # --- Events ---
@@ -156,8 +166,11 @@ async def on_command_error(ctx: commands.Context, err: commands.CommandError):
if isinstance(err, commands.UserInputError): if isinstance(err, commands.UserInputError):
await cmn.add_react(ctx.message, cmn.emojis.warning) await cmn.add_react(ctx.message, cmn.emojis.warning)
await ctx.send_help(ctx.command) await ctx.send_help(ctx.command)
elif isinstance(err, commands.CommandNotFound) and not ctx.invoked_with.startswith("?"): elif isinstance(err, commands.CommandNotFound):
await cmn.add_react(ctx.message, cmn.emojis.question) if ctx.invoked_with and ctx.invoked_with.startswith(("?", "!")):
return
else:
await cmn.add_react(ctx.message, cmn.emojis.question)
elif isinstance(err, commands.CheckFailure): elif isinstance(err, commands.CheckFailure):
# Add handling of other subclasses of CheckFailure as needed. # Add handling of other subclasses of CheckFailure as needed.
if isinstance(err, commands.NotOwner): if isinstance(err, commands.NotOwner):
@@ -168,7 +181,7 @@ async def on_command_error(ctx: commands.Context, err: commands.CommandError):
await cmn.add_react(ctx.message, cmn.emojis.bangbang) await cmn.add_react(ctx.message, cmn.emojis.bangbang)
elif isinstance(err, (commands.CommandInvokeError, commands.ConversionError)): elif isinstance(err, (commands.CommandInvokeError, commands.ConversionError)):
# Emulating discord.py's default beaviour. # Emulating discord.py's default beaviour.
print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr) print("Ignoring exception in command {}:".format(ctx.command), file=sys.stderr)
traceback.print_exception(type(err), err, err.__traceback__, file=sys.stderr) traceback.print_exception(type(err), err, err.__traceback__, file=sys.stderr)
embed = cmn.error_embed_factory(ctx, err.original, bot.qrm.debug_mode) embed = cmn.error_embed_factory(ctx, err.original, bot.qrm.debug_mode)
@@ -177,7 +190,7 @@ async def on_command_error(ctx: commands.Context, err: commands.CommandError):
await ctx.send(embed=embed) await ctx.send(embed=embed)
else: else:
# Emulating discord.py's default beaviour. (safest bet) # Emulating discord.py's default beaviour. (safest bet)
print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr) print("Ignoring exception in command {}:".format(ctx.command), file=sys.stderr)
traceback.print_exception(type(err), err, err.__traceback__, file=sys.stderr) traceback.print_exception(type(err), err, err.__traceback__, file=sys.stderr)
await cmn.add_react(ctx.message, cmn.emojis.warning) await cmn.add_react(ctx.message, cmn.emojis.warning)
@@ -191,7 +204,10 @@ async def _ensure_activity_time():
try: try:
tz = pytz.timezone(opt.status_tz) tz = pytz.timezone(opt.status_tz)
except pytz.exceptions.UnknownTimeZoneError: except pytz.exceptions.UnknownTimeZoneError:
await bot.change_presence(activity=discord.Game(name="with invalid timezones.")) status = "with invalid timezones"
if opt.show_help:
status += f" | {opt.display_prefix}help"
await bot.change_presence(activity=discord.Game(name=status))
return return
now = datetime.now(tz=tz).time() now = datetime.now(tz=tz).time()
@@ -201,6 +217,8 @@ async def _ensure_activity_time():
end_time = time(hour=sts[2][0], minute=sts[2][1], tzinfo=tz) end_time = time(hour=sts[2][0], minute=sts[2][1], tzinfo=tz)
if start_time < now <= end_time: if start_time < now <= end_time:
status = sts[0] status = sts[0]
if opt.show_help:
status += f" | {opt.display_prefix}help"
await bot.change_presence(activity=discord.Game(name=status)) await bot.change_presence(activity=discord.Game(name=status))
@@ -208,6 +226,8 @@ async def _ensure_activity_time():
@tasks.loop(minutes=5) @tasks.loop(minutes=5)
async def _ensure_activity_random(): async def _ensure_activity_random():
status = random.choice(opt.statuses) status = random.choice(opt.statuses)
if opt.show_help:
status += f" | {opt.display_prefix}help"
await bot.change_presence(activity=discord.Game(name=status)) await bot.change_presence(activity=discord.Game(name=status))
@@ -215,6 +235,8 @@ async def _ensure_activity_random():
@tasks.loop(minutes=5) @tasks.loop(minutes=5)
async def _ensure_activity_fixed(): async def _ensure_activity_fixed():
status = opt.statuses[0] status = opt.statuses[0]
if opt.show_help:
status += f" | {opt.display_prefix}help"
await bot.change_presence(activity=discord.Game(name=status)) await bot.change_presence(activity=discord.Game(name=status))
@@ -222,7 +244,7 @@ async def _ensure_activity_fixed():
# --- Run --- # --- Run ---
for ext in opt.exts: for ext in opt.exts:
bot.load_extension(ext_dir + '.' + ext) bot.load_extension(ext_dir + "." + ext)
try: try:
@@ -246,6 +268,7 @@ except ConnectionResetError as ex:
raise raise
raise SystemExit("ConnectionResetError: {}".format(ex)) raise SystemExit("ConnectionResetError: {}".format(ex))
# --- Exit --- # --- Exit ---
# Codes for the wrapper shell script: # Codes for the wrapper shell script:
# 0 - Clean exit, don't restart # 0 - Clean exit, don't restart
+2 -2
View File
@@ -1,5 +1,5 @@
discord.py discord.py~=1.5.0
ctyparser ctyparser~=2.0
beautifulsoup4 beautifulsoup4
lxml lxml
pytz pytz
+20 -47
View File
@@ -1,55 +1,28 @@
""" """
Information about callsigns for the vanity prefixes command in hamcog. Information about callsigns for the prefixes command in hamcog.
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrmbot and is released under the terms of the GNU This file is part of discord-qrmbot and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
from collections import OrderedDict
from dataclasses import dataclass
from .callsigninfos import (us, ca)
us_calls_title = "Valid US Vanity Callsigns" @dataclass
us_calls_desc = ('#x# is the number of letters in the prefix and suffix of a callsign. ' class CallsignInfoData:
'E.g., WY4RC would be a 2x2 callsign, with prefix WY and suffix RC.') """Represents a country's callsign info"""
us_calls = OrderedDict([('**Group A** (Extra Only)', ('**Any:** K, N, W (1x2)\n' title: str = ""
' AA-AL, KA-KZ, NA-NZ, WA-WZ (2x1)\n' desc: str = ""
' AA-AL (2x2)\n' calls: str = ""
'*Except*\n' emoji: str = ""
'**Alaska:** AL, KL, NL, WL (2x1)\n'
'**Caribbean:** KP, NP, WP (2x1)\n'
'**Pacific:** AH, KH, NH, WH (2x1)')),
('**Group B** (Advanced and Extra Only)', ('**Any:** KA-KZ, NA-NZ, WA-WZ (2x2)\n'
'*Except*\n'
'**Alaska:** AL (2x2)\n'
'**Caribbean:** KP (2x2)\n'
'**Pacific:** AH (2x2)')),
('**Group C** (Technician, General, Advanced, Extra Only)', ('**Any Region:** K, N, W (1x3)\n'
'*Except*\n'
'**Alaska:** KL, NL, WL (2x2)\n'
'**Caribbean:** NP, WP (2x2)\n'
'**Pacific:** KH, NH, WH (2x2)')),
('**Group D** (Any License Class)', ('**Any Region:** KA-KZ, WA-WZ (2x3)\n'
'*Except*\n'
'**Alaska:** KL, WL (2x3)\n'
'**Caribbean:** KP, WP (2x3)\n'
'**Pacific:** KH, WH (2x3)')),
('**Unavailable**', ('- KA2AA-KA9ZZ: US Army in Japan\n'
'- KC4AAA-KC4AAF: NSF in Antartica\n'
'- KC4USA-KC4USZ: US Navy in Antartica\n'
'- KG4AA-KG4ZZ: US Navy in Guantanamo Bay\n'
'- KL9KAA-KL9KHZ: US military in Korea\n'
'- KC6AA-KC6ZZ: Former US (Eastern and Western Caroline Islands), '
'now Federated States of Micronesia (V6) and Republic of Palau (T8)\n'
'- KX6AA-KX6ZZ: Former US (Marshall Islands), '
'now Republic of the Marshall Islands (V73)\n'
'- Any suffix SOS or QRA-QUZ\n'
'- Any 2x3 with X as the first suffix letter\n'
'- Any 2x3 with AF, KF, NF, or WF prefix and suffix EMA: FEMA\n'
'- Any 2x3 with AA-AL, NA-NZ, WC, WK, WM, WR, or WT prefix: "Group X"\n'
'- Any 2x1, 2x2, or 2x3 with KP, NP, WP prefix and 0, 6, 7, 8, 9 number\n'
'- Any 1x1 callsign: Special Event'))])
# format: country: (title, description, text)
options = {'us': (us_calls_title, us_calls_desc, us_calls)} options = {
"us": CallsignInfoData(us.title, us.desc, us.calls, us.emoji),
"ca": CallsignInfoData(ca.title, ca.desc, ca.calls, ca.emoji),
}
+3
View File
@@ -0,0 +1,3 @@
"""
Callsign info for various countries
"""
+47
View File
@@ -0,0 +1,47 @@
"""
Information about callsigns for the CA prefixes command in hamcog.
---
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.
"""
title = "Canadian Callsign Rules"
emoji = "🇨🇦"
desc = ("Canadian operators are limited to callsigns with the prefixes of their address' province/territory. "
"Initially, operators can choose a callsign with a 3-letter suffix. "
"Later on, they can apply to change or for additional callsigns. "
"Operators can only hold one 2-letter suffix callsign, but many 3-letter suffix callsigns. "
"If the number of 2-letter suffix callsigns exceeds 80% of the total available, "
"operators can only choose a 2-letter suffix after holding a license for 5 years. "
"If the operator is a family member of a deceased operator, they are not bound by this restriction. "
"Data from [ISED Canada (RIC-9)](https://www.ic.gc.ca/eic/site/smt-gst.nsf/eng/sf02102.html).")
calls = {
"Provinces": (
"**Nova Scotia:** VE1 and VA1\n"
"**Québec:** VE2 and VA2\n"
"**Ontario:** VE3 and VA3\n"
"**Manitoba:** VE4 and VA4\n"
"**Saskatchewan:** VE5 and VA5\n"
"**Alberta:** VE6 and VA6\n"
"**British Columbia:** VE7 and VA7\n"
"**New Brunswick:** VE9\n"
"**Newfoundland:** VO1\n"
"**Labrador:** VO2\n"
"**Prince Edward Island:** VY2\n"
),
"Territories": (
"**Northwest Territories:** VE8\n"
"**Nunavut:** VY0\n"
"**Yukon:** VY1\n"
),
"Other": (
"**International Waters:** VE0\n"
"**Government of Canada:** VY9\n"
"**Sable Island:** CY0\n"
"**St-Paul Island:** CY9\n"
),
"Special Event": "Various prefixes in the ranges: CF-CK, CY-CZ, VA-VG, VO, VX-VY, XJ-XO"
}
+53
View File
@@ -0,0 +1,53 @@
"""
Information about callsigns for the US prefixes command in hamcog.
---
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.
"""
title = "US Callsign Rules"
emoji = "🇺🇸"
desc = ("#x# is the number of letters in the prefix and suffix of a callsign. "
"E.g., WY4RC would be a 2x2 callsign, with prefix WY and suffix RC.")
calls = {
"**Group A** (Extra Only)": ("**Any:** K, N, W (1x2)\n"
" AA-AL, KA-KZ, NA-NZ, WA-WZ (2x1)\n"
" AA-AL (2x2)\n"
"*Except*\n"
"**Alaska:** AL, KL, NL, WL (2x1)\n"
"**Caribbean:** KP, NP, WP (2x1)\n"
"**Pacific:** AH, KH, NH, WH (2x1)"),
"**Group B** (Advanced and Extra Only)": ("**Any:** KA-KZ, NA-NZ, WA-WZ (2x2)\n"
"*Except*\n"
"**Alaska:** AL (2x2)\n"
"**Caribbean:** KP (2x2)\n"
"**Pacific:** AH (2x2)"),
"**Group C** (Technician, General, Advanced, Extra Only)": ("**Any Region:** K, N, W (1x3)\n"
"*Except*\n"
"**Alaska:** KL, NL, WL (2x2)\n"
"**Caribbean:** NP, WP (2x2)\n"
"**Pacific:** KH, NH, WH (2x2)"),
"**Group D** (Any License Class)": ("**Any Region:** KA-KZ, WA-WZ (2x3)\n"
"*Except*\n"
"**Alaska:** KL, WL (2x3)\n"
"**Caribbean:** KP, WP (2x3)\n"
"**Pacific:** KH, WH (2x3)"),
"**Unavailable**": ("- KA2AA-KA9ZZ: US Army in Japan\n"
"- KC4AAA-KC4AAF: NSF in Antartica\n"
"- KC4USA-KC4USZ: US Navy in Antartica\n"
"- KG4AA-KG4ZZ: US Navy in Guantanamo Bay\n"
"- KL9KAA-KL9KHZ: US military in Korea\n"
"- KC6AA-KC6ZZ: Former US (Eastern and Western Caroline Islands), "
"now Federated States of Micronesia (V6) and Republic of Palau (T8)\n"
"- KX6AA-KX6ZZ: Former US (Marshall Islands), "
"now Republic of the Marshall Islands (V73)\n"
"- Any suffix SOS or QRA-QUZ\n"
"- Any 2x3 with X as the first suffix letter\n"
"- Any 2x3 with AF, KF, NF, or WF prefix and suffix EMA: FEMA\n"
"- Any 2x3 with AA-AL, NA-NZ, WC, WK, WM, WR, or WT prefix: \"Group X\"\n"
"- Any 2x1, 2x2, or 2x3 with KP, NP, WP prefix and 0, 6, 7, 8, 9 number\n"
"- Any 1x1 callsign: Special Event")
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

+6 -1
View File
@@ -1,7 +1,12 @@
{ {
"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)", "🇨🇦"], "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", "🇨🇳"], "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)", "🇲🇽"], "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", "", "", "🇳🇱"], "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)", "🇺🇸"] "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: 92 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

+7 -3
View File
@@ -1,6 +1,10 @@
{ {
"arrl": ["arrl-rac.png", "ARRL Sections", "ARRL Sections", "", "", "🇺🇸"], "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)", "🇨🇦"],
"rac": ["arrl-rac.png", "RAC Sections", "RAC Sections", "", "", "🇨🇦"],
"cn": ["cn.png", "China's Prefixes", "Map of prefix regions in China", "", "CRAC", "🇨🇳"], "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)", "🇺🇸"] "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.

After

Width:  |  Height:  |  Size: 304 KiB

+130 -23
View File
@@ -1,29 +1,136 @@
""" """
A listing of morse code symbols A listing of morse code symbols
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrmbot and is released under the terms of the GNU This file is part of discord-qrmbot and is released under the terms of
General Public License, version 2. 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", morse = {
"---": "O", ".--.": "P", "--.-": "Q", ".-.": "R", "...": "S", "-": "T", "..-": "U", "A": ".-",
"...-": "V", ".--": "W", "-..-": "X", "-.--": "Y", "--..": "Z", ".----": "1", "B": "-...",
"..---": "2", "...--": "3", "....-": "4", ".....": "5", "-....": "6", "--...": "7", "C": "-.-.",
"---..": "8", "----.": "9", "-----": "0", ".-.-.-": ".", "--..--": ",", "..--..": "?", "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",
".-.-.-": ".",
"--..--": ",",
"..--..": "?",
".----.": "'",
"-.-.--": "!",
"-..-.": "/",
"-.--.": "(",
"-.--.-": ")",
".-...": "&",
"---...": ":",
"-.-.-.": ";",
"-...-": "=",
".-.-.": "+",
"-....-": "-",
".-..-.": "\"",
".--.-.": "@",
".-.-": "Ä",
"..-..": "É",
"--.--": "Ñ",
"---.": "Ö",
"..--": "Ü",
"----": "Š",
"/": " "
}
+72 -8
View File
@@ -1,14 +1,78 @@
""" """
A listing of NATO Phonetics A listing of NATO Phonetics
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrmbot and is released under the terms of the GNU This file is part of discord-qrmbot and is released under the terms of
General Public License, version 2. 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', phonetics = {
'm': 'mike', 'n': 'november', 'o': 'oscar', 'p': 'papa', 'q': 'quebec', 'r': 'romeo', "a": "alfa",
's': 'sierra', 't': 'tango', 'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'x-ray', "b": "bravo",
'y': 'yankee', 'z': 'zulu'} "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,
}
+280 -274
View File
@@ -1,280 +1,286 @@
""" """
A listing of Q Codes A listing of Q Codes
--- ---
Copyright (C) 2019 Abigail Gold, 0x5c Copyright (C) 2019-2020 Abigail Gold, 0x5c
This file is part of discord-qrmbot and is released under the terms of the GNU This file is part of discord-qrmbot and is released under the terms of
General Public License, version 2. the GNU General Public License, version 2.
""" """
# flake8: noqa # 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.", qcodes = {
"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).", "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 ...",
"QAI": "What is the essential traffic respecting my aircraft? / The essential traffic respecting your aircraft is ...", "QAF": "Will you advise me when you are (were) at (over) ... (place)? / I am (was) at (over) ... (place) (at ... hours) at flight level/altitude ...",
"QAK": "Is there any risk of collision? / There is risk of collision.", "QAG": "Arrange your flight in order to arrive over ... (place) at ... hours.",
"QAL": "Are you going to land at ... (place)? I am going to land at ... (place).", "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).",
"QAM": "What is the latest available meteorological observation for ... (place)? / Meteorological observation made at ... (place) at ... hours was as follows ...", "QAI": "What is the essential traffic respecting my aircraft? / The essential traffic respecting your aircraft is ...",
"QAN": "What is the surface wind direction and speed at ... (place)? / The surface wind direction and speed at ... (place) at ... hours is ... (direction) ... (speed).", "QAK": "Is there any risk of collision? / There is risk of collision.",
"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).", "QAL": "Are you going to land at ... (place)? I am going to land at ... (place).",
"QAP": "Shall I listen for you (or for ...) on ... kHz (... MHz)? / Listen for me (or for ...) on ... kHz (... MHz).", "QAM": "What is the latest available meteorological observation for ... (place)? / Meteorological observation made at ... (place) at ... hours was as follows ...",
"QAQ": "Am I near a prohibited, restricted or danger area?", "QAN": "What is the surface wind direction and speed at ... (place)? / The surface wind direction and speed at ... (place) at ... hours is ... (direction) ... (speed).",
"QAR": "May I stop listening on the watch frequency for ... minutes? / You may stop listening on the watch frequency for ... minutes.", "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).",
"QAU": "Where may I jettison fuel? / I am about to jettison fuel.", "QAP": "Shall I listen for you (or for ...) on ... kHz (... MHz)? / Listen for me (or for ...) on ... kHz (... MHz).",
"QAW": "I am about to carry out overshoot procedure.", "QAQ": "Am I near a prohibited, restricted or danger area?",
"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.", "QAR": "May I stop listening on the watch frequency for ... minutes? / You may stop listening on the watch frequency for ... minutes.",
"QAZ": "Are you experiencing communication difficulties through flying in a storm? / I am experiencing communication difficulties through flying in a storm.", "QAU": "Where may I jettison fuel? / I am about to jettison fuel.",
"QBA": "What is the horizontal visibility at ... (place)? / The horizontal visibility at ... (place) at ... hours is ... (distance figures and units).", "QAW": "I am about to carry out overshoot procedure.",
"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.", "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.",
"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 ...", "QAZ": "Are you experiencing communication difficulties through flying in a storm? / I am experiencing communication difficulties through flying in a storm.",
"QBD": "How much fuel have you remaining (expressed as hours and/or minutes of consumption)? / My fuel endurance is ... (hours and/or minutes).", "QBA": "What is the horizontal visibility at ... (place)? / The horizontal visibility at ... (place) at ... hours is ... (distance figures and units).",
"QBE": "I am about to wind in my aerial.", "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.",
"QBF": "Are you flying in cloud? / I am flying in cloud at ... flight level/altitude ... [and I am ascending (descending) to flight level/altitude ...].", "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 ...",
"QBG": "Are you flying above cloud? / I am flying above cloud and at flight level/altitude ...", "QBD": "How much fuel have you remaining (expressed as hours and/or minutes of consumption)? / My fuel endurance is ... (hours and/or minutes).",
"QBH": "Are you flying below cloud? / I am flying below cloud and at flight level/altitude ...", "QBE": "I am about to wind in my aerial.",
"QBI": "Is flight under IFR compulsory at ... (place) [or from ... to ... (place)]? / Flight under IFR is compulsory at ... (place) [or from ... to ... (place)].", "QBF": "Are you flying in cloud? / I am flying in cloud at ... flight level/altitude ... [and I am ascending (descending) to flight level/altitude ...].",
"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).", "QBG": "Are you flying above cloud? / I am flying above cloud and at flight level/altitude ...",
"QBK": "Are you flying with no cloud in your vicinity? / I am flying with no cloud in my vicinity and at flight level/altitude ...", "QBH": "Are you flying below cloud? / I am flying below cloud and at flight level/altitude ...",
"QBM": "Has ... sent any messages for me? / Here is the message sent by ... at ... hours.", "QBI": "Is flight under IFR compulsory at ... (place) [or from ... to ... (place)]? / Flight under IFR is compulsory at ... (place) [or from ... to ... (place)].",
"QBN": "Are you flying between two layers of cloud? / I am flying between two layers of cloud and at flight level/altitude ...", "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).",
"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.", "QBK": "Are you flying with no cloud in your vicinity? / I am flying with no cloud in my vicinity and at flight level/altitude ...",
"QBP": "Are you flying in and out of cloud? / I am flying in and out of cloud and at flight level/altitude ...", "QBM": "Has ... sent any messages for me? / Here is the message sent by ... at ... hours.",
"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.", "QBN": "Are you flying between two layers of cloud? / I am flying between two layers of cloud and at flight level/altitude ...",
"QBT": "What is the runway visual range at ... (place)? / The runway visual range at ... (place) at ... hours is ... (distance figures and units).", "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.",
"QBV": "Have you reached flight level/altitude ... [or ... (area or place)]? / I have reached ... flight level/altitude ... [or ... (area or place)].", "QBP": "Are you flying in and out of cloud? / I am flying in and out of cloud and at flight level/altitude ...",
"QBX": "Have you left ... flight level/altitude ... [or ... (area or place)]? / I have left ... flight level/altitude ... [or ... (area or place)].", "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.",
"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.", "QBT": "What is the runway visual range at ... (place)? / The runway visual range at ... (place) at ... hours is ... (distance figures and units).",
"QCA": "May I change my flight level/altitude from ... to ... ? / You may change your flight level/altitude from ... to ...", "QBV": "Have you reached flight level/altitude ... [or ... (area or place)]? / I have reached ... flight level/altitude ... [or ... (area or place)].",
"QCB": "Delay is being caused by ...", "QBX": "Have you left ... flight level/altitude ... [or ... (area or place)]? / I have left ... flight level/altitude ... [or ... (area or place)].",
"QCE": "When may I expect approach clearance? / Expect approach clearance at ... hours.", "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.",
"QCF": "Delay indefinite. Expect approach clearance not later than ... hours.", "QCA": "May I change my flight level/altitude from ... to ... ? / You may change your flight level/altitude from ... to ...",
"QCH": "May I taxi to ... (place)? / Cleared to taxi to ... (place).", "QCB": "Delay is being caused by ...",
"QCI": "Make a 360-degree turn immediately (turning to the ...).", "QCE": "When may I expect approach clearance? / Expect approach clearance at ... hours.",
"QCS": "My reception on ... frequency has broken down.", "QCF": "Delay indefinite. Expect approach clearance not later than ... hours.",
"QCX": "What is your full call sign? / My full call sign is ...", "QCH": "May I taxi to ... (place)? / Cleared to taxi to ... (place).",
"QCY": "I am working on a trailing aerial.", "QCI": "Make a 360-degree turn immediately (turning to the ...).",
"QDB": "Have you sent message ... to ... ? / I have sent message ... to ...", "QCS": "My reception on ... frequency has broken down.",
"QDF": "What is your D-Value at ... (position)?", "QCX": "What is your full call sign? / My full call sign is ...",
"QDL": "Do you intend to ask me for a series of bearings? / I intend to ask you for a series of bearings.", "QCY": "I am working on a trailing aerial.",
"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).", "QDB": "Have you sent message ... to ... ? / I have sent message ... to ...",
"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).", "QDF": "What is your D-Value at ... (position)?",
"QDR": "What is my MAGNETIC bearing from you (or from ...)? / Your MAGNETIC bearing from me (or from ...) was ... degrees (at ... hours).", "QDL": "Do you intend to ask me for a series of bearings? / I intend to ask you for a series of bearings.",
"QDT": "Are you flying in visual meteorological condition? / I am flying in visual meteorological condition.", "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).",
"QDU": "Cancelling my IFR flight.", "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).",
"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 ...", "QDR": "What is my MAGNETIC bearing from you (or from ...)? / Your MAGNETIC bearing from me (or from ...) was ... degrees (at ... hours).",
"QEA": "May I cross the runway ahead of me? / You may cross the runway ahead of you.", "QDT": "Are you flying in visual meteorological condition? / I am flying in visual meteorological condition.",
"QEB": "May I turn at the intersection? / Taxi as follows at the intersection ...", "QDU": "Cancelling my IFR flight.",
"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.", "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 ...",
"QED": "Shall I follow the pilot vehicle? / Follow the pilot vehicle.", "QEA": "May I cross the runway ahead of me? / You may cross the runway ahead of you.",
"QEF": "Have I reached my parking area? / You have reached your parking area.", "QEB": "May I turn at the intersection? / Taxi as follows at the intersection ...",
"QEG": "May I leave the parking area? / You may leave the parking area.", "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.",
"QEH": "May I move to the holding position for runway number ... ? / Cleared to the holding position for runway number ...", "QED": "Shall I follow the pilot vehicle? / Follow the pilot vehicle.",
"QEJ": "May I assume position for take-off? / Cleared to hold at take-off position for runway number ...", "QEF": "Have I reached my parking area? / You have reached your parking area.",
"QEK": "Are you ready for immediate take-off? / I am ready for immediate take-off.", "QEG": "May I leave the parking area? / You may leave the parking area.",
"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 ...).", "QEH": "May I move to the holding position for runway number ... ? / Cleared to the holding position for runway number ...",
"QEM": "What is the condition of the landing surface at ... (place)? / The condition of the landing surface at ... (place) is ...", "QEJ": "May I assume position for take-off? / Cleared to hold at take-off position for runway number ...",
"QEN": "Shall I hold my position? / Hold your position", "QEK": "Are you ready for immediate take-off? / I am ready for immediate take-off.",
"QEO": "Shall I clear the runway (or landing area)? / Clear the runway (or landing area).", "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 ...).",
"QES": "Is a right-hand circuit in force at ... (place)? / A right-hand circuit is in force at ... (place).", "QEM": "What is the condition of the landing surface at ... (place)? / The condition of the landing surface at ... (place) is ...",
"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 ...", "QEN": "Shall I hold my position? / Hold your position",
"QFB": "The approach/runway lights are out of order.", "QEO": "Shall I clear the runway (or landing area)? / Clear the runway (or landing area).",
"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).", "QES": "Is a right-hand circuit in force at ... (place)? / A right-hand circuit is in force at ... (place).",
"QFD": "Is the ... visual beacon [at ... (place)] in operation?", "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 ...",
"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 ...).", "QFB": "The approach/runway lights are out of order.",
"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.", "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).",
"QFG": "Am I overhead? / You are overhead.", "QFD": "Is the ... visual beacon [at ... (place)] in operation?",
"QFH": "May I descend below the clouds? / You may descend below the clouds.", "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 ...).",
"QFI": "Are the aerodrome lights lit? / The aerodrome lights are lit.", "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.",
"QFL": "Will you send up pyrotechnical lights? / I will send up pyrotechnical lights.", "QFG": "Am I overhead? / You are overhead.",
"QFM": "What flight level/altitude should I maintain?", "QFH": "May I descend below the clouds? / You may descend below the clouds.",
"QFO": "May I land immediately? / You may land immediately.", "QFI": "Are the aerodrome lights lit? / The aerodrome lights are lit.",
"QFP": "Will you give me the latest information concerning ... facility [at ... (place)]? / The latest information concerning ... facility [at ... (place)] is as follows ...", "QFL": "Will you send up pyrotechnical lights? / I will send up pyrotechnical lights.",
"QFQ": "Are the approach and runway lights lit? / The approach and runway lights are lit.", "QFM": "What flight level/altitude should I maintain?",
"QFR": "Does my landing gear appear damaged? / Your landing gear appears damaged.", "QFO": "May I land immediately? / You may land immediately.",
"QFS": "Is the radio facility at ... (place) in operation? / The radio facility at ... (place) is in operation (or will be in operation in ... hours).", "QFP": "Will you give me the latest information concerning ... facility [at ... (place)]? / The latest information concerning ... facility [at ... (place)] is as follows ...",
"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).", "QFQ": "Are the approach and runway lights lit? / The approach and runway lights are lit.",
"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 ...", "QFR": "Does my landing gear appear damaged? / Your landing gear appears damaged.",
"QFV": "Are the floodlights switched on? / The floodlights are switched on.", "QFS": "Is the radio facility at ... (place) in operation? / The radio facility at ... (place) is in operation (or will be in operation in ... hours).",
"QFW": "What is the length of the runway in use in ... (units)? / The length of runway ... now in use is ... (figures and units).", "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).",
"QFX": "I am working (or am going to work) on a fixed aerial.", "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 ...",
"QFY": "Please report the present meteorological landing conditions [at ... (place)]. / The present meteorological landing conditions at ... (place) are ...", "QFV": "Are the floodlights switched on? / The floodlights are switched on.",
"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 ...", "QFW": "What is the length of the runway in use in ... (units)? / The length of runway ... now in use is ... (figures and units).",
"QGC": "There are obstructions to the ... of ... runway ...", "QFX": "I am working (or am going to work) on a fixed aerial.",
"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).", "QFY": "Please report the present meteorological landing conditions [at ... (place)]. / The present meteorological landing conditions at ... (place) are ...",
"QGE": "What is my distance to your station (or to ...)? / Your distance to my station (or to ...) is ... (distance figures and units).", "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 ...",
"QGH": "May I land using ... (procedure or facility)? / You may land using ... (procedure or facility).", "QGC": "There are obstructions to the ... of ... runway ...",
"QGK": "What track should I make good? / Make good a track from ... (place) on ... degrees ... (true or magnetic).", "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).",
"QGL": "May I enter the ... (control area or zone) at ... (place)? / You may enter the ... (control area or zone) at ... (place).", "QGE": "What is my distance to your station (or to ...)? / Your distance to my station (or to ...) is ... (distance figures and units).",
"QGM": "Leave the ... (control area or zone).", "QGH": "May I land using ... (procedure or facility)? / You may land using ... (procedure or facility).",
"QGN": "May I be cleared to land [at ... (place)]? / You are cleared to land [at ... (place)].", "QGK": "What track should I make good? / Make good a track from ... (place) on ... degrees ... (true or magnetic).",
"QGO": "Landing is prohibited at ... (place).", "QGL": "May I enter the ... (control area or zone) at ... (place)? / You may enter the ... (control area or zone) at ... (place).",
"QGP": "What is my number for landing? / You are number ... to land.", "QGM": "Leave the ... (control area or zone).",
"QGQ": "May I hold at ... (place)? / Hold at ... (place) at flight level/altitude ... (datum) and await further clearance.", "QGN": "May I be cleared to land [at ... (place)]? / You are cleared to land [at ... (place)].",
"QGT": "Fly for ... minutes on a heading what will enable you to maintain a track reciprocal to your present one.", "QGO": "Landing is prohibited at ... (place).",
"QGU": "Fly for ... minutes on a magnetic heading of ... degrees.", "QGP": "What is my number for landing? / You are number ... to land.",
"QGV": "Do you see me? / Can you see the aerodrome? / Can you see ... (aircraft)? / I see you at ... (cardinal or quadrantal point of direction).", "QGQ": "May I hold at ... (place)? / Hold at ... (place) at flight level/altitude ... (datum) and await further clearance.",
"QGW": "Does my landing gear appear to be down and in place? / Your landing gear appears to be down and in place.", "QGT": "Fly for ... minutes on a heading what will enable you to maintain a track reciprocal to your present one.",
"QGZ": "Hold on ... direction of ... facility.", "QGU": "Fly for ... minutes on a magnetic heading of ... degrees.",
"QHE": "Will you inform me when you are on ... leg of approach? / I am on ...(leg).. of approach.", "QGV": "Do you see me? / Can you see the aerodrome? / Can you see ... (aircraft)? / I see you at ... (cardinal or quadrantal point of direction).",
"QHG": "May I enter traffic circuit at flight level/altitude ...? / Cleared to enter traffic circuit at flight level/altitude ...", "QGW": "Does my landing gear appear to be down and in place? / Your landing gear appears to be down and in place.",
"QHH": "Are you making an emergency landing? / I am making an emergency landing.", "QGZ": "Hold on ... direction of ... facility.",
"QHI": "Are you (or is ...) ... waterborne / on land? ", "QHE": "Will you inform me when you are on ... leg of approach? / I am on ...(leg).. of approach.",
"QHQ": "May I make a ... approach [at ... (place)]? / You may make a ... approach [at ... (place)].", "QHG": "May I enter traffic circuit at flight level/altitude ...? / Cleared to enter traffic circuit at flight level/altitude ...",
"QHZ": "Shall I circle the aerodrome (or go around)? / Circle the aerodrome (or go around).", "QHH": "Are you making an emergency landing? / I am making an emergency landing.",
"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).", "QHI": "Are you (or is ...) ... waterborne / on land? ",
"QIF": "What frequency is ... using? / ... is using ... kHz (or ... MHz.).", "QHQ": "May I make a ... approach [at ... (place)]? / You may make a ... approach [at ... (place)].",
"QJA": "Is my tape / mark and space reversed? / Your tape / mark and space is reversed.", "QHZ": "Shall I circle the aerodrome (or go around)? / Circle the aerodrome (or go around).",
"QJB": "Will you use radio/cable/telegraph/teletype/telephone/receiver/transmitter/reperforator? / I will use ...", "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).",
"QJC": "Will you check your transmitter/autohead/perforator/reperfordator/printer/keyboard/antenna? / I will check my ...", "QIF": "What frequency is ... using? / ... is using ... kHz (or ... MHz.).",
"QJD": "Am I transmitting letters/figures? / You are transmitting ...", "QJA": "Is my tape / mark and space reversed? / Your tape / mark and space is reversed.",
"QJE": "Is my frequency shift wide/narrow/correct? / Your frequency shift is ... (by ... cycles)", "QJB": "Will you use radio/cable/telegraph/teletype/telephone/receiver/transmitter/reperforator? / I will use ...",
"QJF": "My signal as checked by monitor locally/as radiated is satisfactory.", "QJC": "Will you check your transmitter/autohead/perforator/reperfordator/printer/keyboard/antenna? / I will check my ...",
"QJG": "Shall I revert to automatic relay? / Revert to automatic relay.", "QJD": "Am I transmitting letters/figures? / You are transmitting ...",
"QJH": "Shall I run test tape/sentence? / Run test tape/sentence.", "QJE": "Is my frequency shift wide/narrow/correct? / Your frequency shift is ... (by ... cycles)",
"QJI": "Will you transmit a continuous mark/space? / I am transmitting a continuous mark/space.", "QJF": "My signal as checked by monitor locally/as radiated is satisfactory.",
"QJK": "Are you receiving continuous mark/space / mark/space bias? / I am receiving a continuous mark/space / mark/space bias.", "QJG": "Shall I revert to automatic relay? / Revert to automatic relay.",
"QKC": "The sea conditions (at ... position) ... permit alighting but not takeoff / render alihting extremely hazardous.", "QJH": "Shall I run test tape/sentence? / Run test tape/sentence.",
"QKF": "May I be relieved (at ... hours)? / You may expect to be relieved at ... hours [by aircraft/vessel/callsign/name].", "QJI": "Will you transmit a continuous mark/space? / I am transmitting a continuous mark/space.",
"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.", "QJK": "Are you receiving continuous mark/space / mark/space bias? / I am receiving a continuous mark/space / mark/space bias.",
"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].", "QKC": "The sea conditions (at ... position) ... permit alighting but not takeoff / render alihting extremely hazardous.",
"QKN": "Aircraft plotted (believed to be you) in position ... on track ... degrees at ... hours.", "QKF": "May I be relieved (at ... hours)? / You may expect to be relieved at ... hours [by aircraft/vessel/callsign/name].",
"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).", "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.",
"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].", "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].",
"QLB": "Will you monitor ... station and report regarding range, quality, etc.? / I have monitored ... station and report (briefly) as follows ...", "QKN": "Aircraft plotted (believed to be you) in position ... on track ... degrees at ... hours.",
"QLE": "What is your expected signal? / The expected signal is low...", "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).",
"QLF": "Are you sending with your left foot? Try sending with your left foot!", "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].",
"QLH": "Will you use simultaneous keying on ... frequency and ... frequency? / I will now key simultaneously on ... frequency and ... frequency.", "QLB": "Will you monitor ... station and report regarding range, quality, etc.? / I have monitored ... station and report (briefly) as follows ...",
"QLV": "Is the ... radio facility still required? / The ... radio facility is still required.", "QLE": "What is your expected signal? / The expected signal is low...",
"QMH": "Shift to transmit and receive on ... kHz (or ... MHz.); if communication is not established within 5 minutes, revert to present frequency.", "QLF": "Are you sending with your left foot? Try sending with your left foot!",
"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).", "QLH": "Will you use simultaneous keying on ... frequency and ... frequency? / I will now key simultaneously on ... frequency and ... frequency.",
"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.", "QLV": "Is the ... radio facility still required? / The ... radio facility is still required.",
"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) ...", "QMH": "Shift to transmit and receive on ... kHz (or ... MHz.); if communication is not established within 5 minutes, revert to present frequency.",
"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.", "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).",
"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]", "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.",
"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).", "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) ...",
"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.", "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.",
"QNI": "May I join the net? / You may check in...", "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]",
"QNO": "I am not equipped to give the information (or provide the facility) requested.", "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).",
"QNR": "I am approaching my point of no return.", "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.",
"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).", "QNI": "May I join the net? / You may check in...",
"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 ...", "QNO": "I am not equipped to give the information (or provide the facility) requested.",
"QOA": "Can you communicate by radiotelegraphy (500 kHz)? / I can communicate by radiotelegraphy (500 kHz).", "QNR": "I am approaching my point of no return.",
"QOB": "Can you communicate by radiotelephony (2182 kHz)? / I can communicate by radiotelephony (2182 kHz).", "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).",
"QOC": "Can you communicate by radiotelephony (channel 16 - frequency 156.80 MHz)? / I can communicate by radiotelephony (channel 16 - frequency 156.80 MHz).", "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 ...",
"QOD": "Can you communicate with me in Dutch/English/French/German/Greek/Italian/Japanese/Norwegian/Russian/Spanish? / I can communicate with you in ...", "QOA": "Can you communicate by radiotelegraphy (500 kHz)? / I can communicate by radiotelegraphy (500 kHz).",
"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).", "QOB": "Can you communicate by radiotelephony (2182 kHz)? / I can communicate by radiotelephony (2182 kHz).",
"QOF": "What is the commercial quality of my signals? / The quality of your signals is not commercial/marginally commercial/commercial.", "QOC": "Can you communicate by radiotelephony (channel 16 - frequency 156.80 MHz)? / I can communicate by radiotelephony (channel 16 - frequency 156.80 MHz).",
"QOG": "How many tapes have you to send? / I have ... tapes to send.", "QOD": "Can you communicate with me in Dutch/English/French/German/Greek/Italian/Japanese/Norwegian/Russian/Spanish? / I can communicate with you in ...",
"QOH": "Shall I send a phasing signal for ... seconds? / Send a phasing signal for ... seconds.", "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).",
"QOI": "Shall I send my tape? / Send your tape.", "QOF": "What is the commercial quality of my signals? / The quality of your signals is not commercial/marginally commercial/commercial.",
"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.", "QOG": "How many tapes have you to send? / I have ... tapes to send.",
"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).", "QOH": "Shall I send a phasing signal for ... seconds? / Send a phasing signal for ... seconds.",
"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 ...", "QOI": "Shall I send my tape? / Send your tape.",
"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).", "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.",
"QOO": "Can you send on any working frequency? / I can send on any working frequency.", "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).",
"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.", "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 ...",
"QRA": "What is the name of your vessel (or station)? / The name of my vessel (or station) 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).",
"QRB": "How far approximately are you from my station? / The approximate distance between our stations is ... nautical miles (or km).", "QOO": "Can you send on any working frequency? / I can send on any working frequency.",
"QRC": "What is your true bearing? / My true bearing is ____ degrees.", "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.",
"QRD": "Where are you bound for? / I am bound for ____.", "QRA": "What is the name of your vessel (or station)? / The name of my vessel (or station) is ...",
"QRE": "What is your estimated time of arrival at ... (or over ...) (place)? / My estimated time of arrival at ... (or over ...) (place) is ... hours.", "QRB": "How far approximately are you from my station? / The approximate distance between our stations is ... nautical miles (or km).",
"QRF": "Where are you bound from? / I am bound from ____.", "QRC": "What is your true bearing? / My true bearing is ____ degrees.",
"QRG": "Will you tell me my exact frequency (or that of ...)? / Your exact frequency (or that of ...) is ... kHz (or MHz).", "QRD": "Where are you bound for? / I am bound for ____.",
"QRH": "Does my frequency vary? / Your frequency varies.", "QRE": "What is your estimated time of arrival at ... (or over ...) (place)? / My estimated time of arrival at ... (or over ...) (place) is ... hours.",
"QRI": "How is the tone of my transmission? / The tone of your transmission is ...", "QRF": "Where are you bound from? / I am bound from ____.",
"QRJ": "How many voice contacts do you want to make? / I want to make ... voice contacts.", "QRG": "Will you tell me my exact frequency (or that of ...)? / Your exact frequency (or that of ...) is ... kHz (or MHz).",
"QRK": "How do you receive me? / I am receiving (1-5).", "QRH": "Does my frequency vary? / Your frequency varies.",
"QRL": "Are you busy? / I am busy (or I am busy with ...). Please do not interfere.", "QRI": "How is the tone of my transmission? / The tone of your transmission is ...",
"QRM": "Are you being interfered with? / I am being interfered with.", "QRJ": "How many voice contacts do you want to make? / I want to make ... voice contacts.",
"QRN": "Are the atmospherics strong? / Atmospherics (noise) are very strong.", "QRK": "How do you receive me? / I am receiving (1-5).",
"QRO": "Shall I increase transmitter power? / Increase transmitter power.", "QRL": "Are you busy? / I am busy (or I am busy with ...). Please do not interfere.",
"QRP": "Shall I decrease transmitter power? / Decrease transmitter power.", "QRM": "Are you being interfered with? / I am being interfered with.",
"QRQ": "Shall I send faster? / Send faster (... wpm)", "QRN": "Are the atmospherics strong? / Atmospherics (noise) are very strong.",
"QRR": "Are you ready for automatic operation? / I am ready for automatic operation. Send at ... words per minute.", "QRO": "Shall I increase transmitter power? / Increase transmitter power.",
"QRS": "Shall I send more slowly? / Send more slowly (... words per minute).", "QRP": "Shall I decrease transmitter power? / Decrease transmitter power.",
"QRT": "Shall I stop sending? / Stop sending.", "QRQ": "Shall I send faster? / Send faster (... wpm)",
"QRU": "Have you anything for me? / I have nothing for you.", "QRR": "Are you ready for automatic operation? / I am ready for automatic operation. Send at ... words per minute.",
"QRV": "Are you ready? / I am ready.", "QRS": "Shall I send more slowly? / Send more slowly (... words per minute).",
"QRW": "Shall I inform ... that you are calling him on ... kHz (or MHz)? / Please inform ... that I am calling him on ... kHz (or MHz).", "QRT": "Shall I stop sending? / Stop sending.",
"QRX": "When will you call me again? / I will call you again at ... hours (on ... kHz (or MHz)).", "QRU": "Have you anything for me? / I have nothing for you.",
"QRY": "What is my turn? / Your turn is Number ... (or according to any other indication).", "QRV": "Are you ready? / I am ready.",
"QRZ": "Who is calling me? / You are being called by ... (on ... kHz (or MHz)).", "QRW": "Shall I inform ... that you are calling him on ... kHz (or MHz)? / Please inform ... that I am calling him on ... kHz (or MHz).",
"QSA": "What is the strength of my signals (or those of ...)? / The strength of your signals (or those of ...) is ...", "QRX": "When will you call me again? / I will call you again at ... hours (on ... kHz (or MHz)).",
"QSB": "Are my signals fading? / Your signals are fading.", "QRY": "What is my turn? / Your turn is Number ... (or according to any other indication).",
"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.", "QRZ": "Who is calling me? / You are being called by ... (on ... kHz (or MHz)).",
"QSD": "Is my keying defective? --or-- Are my signals mutilated? / Your keying is defective. --or-- Your signals are mutilated.", "QSA": "What is the strength of my signals (or those of ...)? / The strength of your signals (or those of ...) is ...",
"QSE": "What is the estimated drift of the survival craft? / The estimated drift of the survival craft is ... (figures and units).", "QSB": "Are my signals fading? / Your signals are fading.",
"QSF": "Have you effected rescue? / I have effected rescue and am proceeding to ... base (with ... persons injured requiring ambulance).", "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.",
"QSG": "Shall I send ... telegrams at a time? / Send ... telegrams at a time.", "QSD": "Is my keying defective? --or-- Are my signals mutilated? / Your keying is defective. --or-- Your signals are mutilated.",
"QSH": "Are you able to home on your direction-finding equipment? / I am able to home on my D/F equipment (on station ...).", "QSE": "What is the estimated drift of the survival craft? / The estimated drift of the survival craft is ... (figures and units).",
"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)).", "QSF": "Have you effected rescue? / I have effected rescue and am proceeding to ... base (with ... persons injured requiring ambulance).",
"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.", "QSG": "Shall I send ... telegrams at a time? / Send ... telegrams at a time.",
"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.", "QSH": "Are you able to home on your direction-finding equipment? / I am able to home on my D/F equipment (on station ...).",
"QSL": "Can you acknowledge receipt? / I am acknowledging receipt.", "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)).",
"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) ...).", "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.",
"QSN": "Did you hear me (or ... (call sign)) on ... kHz (or MHz)? / I did hear you (or ... (call sign)) on ... kHz (or MHz).", "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.",
"QSO": "Can you communicate with ... direct (or by relay)? / I can communicate with ... direct (or by relay through ...).", "QSL": "Can you acknowledge receipt? / I am acknowledging receipt.",
"QSP": "Will you relay to ... free of charge? / I will relay to ... free of charge.", "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) ...).",
"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).", "QSN": "Did you hear me (or ... (call sign)) on ... kHz (or MHz)? / I did hear you (or ... (call sign)) on ... kHz (or MHz).",
"QSR": "Shall I repeat the call on the calling frequency? / Repeat your call on the calling frequency; did not hear you (or have interference).", "QSO": "Can you communicate with ... direct (or by relay)? / I can communicate with ... direct (or by relay through ...).",
"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).", "QSP": "Will you relay to ... free of charge? / I will relay to ... free of charge.",
"QST": "Here is a broadcast message to all amateurs.", "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).",
"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 ...).", "QSR": "Shall I repeat the call on the calling frequency? / Repeat your call on the calling frequency; did not hear you (or have interference).",
"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)).", "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).",
"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 ...).", "QST": "Here is a broadcast message to all amateurs.",
"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 ...", "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 ...).",
"QSY": "Shall I change to transmission on another frequency? / Change to transmission on another frequency (or on ... kHz (or MHz)).", "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)).",
"QSZ": "Shall I send each word or group more than once? / Send each word or group twice (or ... times).", "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 ...).",
"QTA": "Shall I cancel telegram (or message) number ... ? / Cancel telegram (or message) number ...", "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 ...",
"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.", "QSY": "Shall I change to transmission on another frequency? / Change to transmission on another frequency (or on ... kHz (or MHz)).",
"QTC": "How many telegrams have you to send? / I have ... telegrams for you (or for ...).", "QSZ": "Shall I send each word or group more than once? / Send each word or group twice (or ... times).",
"QTD": "What has the rescue vessel or rescue aircraft recovered? / ... (identification) has recovered ... survivors/wreckage/bodies.", "QTA": "Shall I cancel telegram (or message) number ... ? / Cancel telegram (or message) number ...",
"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.", "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.",
"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.", "QTC": "How many telegrams have you to send? / I have ... telegrams for you (or for ...).",
"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).", "QTD": "What has the rescue vessel or rescue aircraft recovered? / ... (identification) has recovered ... survivors/wreckage/bodies.",
"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", "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.",
"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).", "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.",
"QTI": "What is your TRUE course? / My TRUE course is ... degrees.", "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).",
"QTJ": "What is your speed? / My speed is ... knots (or ... kilometres per hour or ... statute miles per hour).", "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",
"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).", "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).",
"QTL": "What is your TRUE heading? / My TRUE heading is ... degrees.", "QTI": "What is your TRUE course? / My TRUE course is ... degrees.",
"QTM": "What is your MAGNETIC heading? / My MAGNETIC heading is ... degrees.", "QTJ": "What is your speed? / My speed is ... knots (or ... kilometres per hour or ... statute miles per hour).",
"QTN": "At what time did you depart from ... (place)? / I departed from ... (place) at ... hours.", "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).",
"QTO": "Have you left dock (or port)? --or-- Are you airborne? / I have left dock (or port). --or-- I am airborne.", "QTL": "What is your TRUE heading? / My TRUE heading is ... degrees.",
"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).", "QTM": "What is your MAGNETIC heading? / My MAGNETIC heading is ... degrees.",
"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).", "QTN": "At what time did you depart from ... (place)? / I departed from ... (place) at ... hours.",
"QTR": "What is the correct time? / The correct time is ... hours.", "QTO": "Have you left dock (or port)? --or-- Are you airborne? / I have left dock (or port). --or-- I am airborne.",
"QTS": "Will you send your call sign (and/or name) for ... seconds? / I will send my call sign (and/or name) for ... seconds.", "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).",
"QTT": "The identification signal which follows is superimposed on another transmission.", "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).",
"QTU": "What are the hours during which your station is open? / My station is open from ... to ... hours.", "QTR": "What is the correct time? / The correct time is ... 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).", "QTS": "Will you send your call sign (and/or name) for ... seconds? / I will send my call sign (and/or name) for ... seconds.",
"QTW": "What is the condition of survivors? / Survivors are in ... condition and urgently need ...", "QTT": "The identification signal which follows is superimposed on another transmission.",
"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).", "QTU": "What are the hours during which your station is open? / My station is open from ... to ... 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)).", "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).",
"QTZ": "Are you continuing the search? / I am continuing the search for ... (aircraft, ship, survival craft, survivors or wreckage).", "QTW": "What is the condition of survivors? / Survivors are in ... condition and urgently need ...",
"QUA": "Have you news of ... (call sign)? / Here is news of ... (call sign).", "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).",
"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.)", "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)).",
"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 ...", "QTZ": "Are you continuing the search? / I am continuing the search for ... (aircraft, ship, survival craft, survivors or wreckage).",
"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.", "QUA": "Have you news of ... (call sign)? / Here is news of ... (call sign).",
"QUE": "Can you speak in ... (language), - with interpreter if necessary; if so, on what frequencies? / I can speak in ... (language) on ... kHz (or MHz).", "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.)",
"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.", "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 ...",
"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.", "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.",
"QUH": "Will you give me the present barometric pressure at sea level? / The present barometric pressure at sea level is ... (units).", "QUE": "Can you speak in ... (language), - with interpreter if necessary; if so, on what frequencies? / I can speak in ... (language) on ... kHz (or MHz).",
"QUI": "Are your navigation lights working? / My navigation lights are working.", "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.",
"QUJ": "Will you indicate the TRUE track to reach you (or ...)? / The TRUE track to reach me (or ...) is ... degrees 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.",
"QUK": "Can you tell me the condition of the sea observed at ... (place or coordinates)? / The sea at ... (place or coordinates) is ...", "QUH": "Will you give me the present barometric pressure at sea level? / The present barometric pressure at sea level is ... (units).",
"QUL": "Can you tell me the swell observed at ... (place or coordinates)? / The swell at ... (place or coordinates) is ...", "QUI": "Are your navigation lights working? / My navigation lights are working.",
"QUM": "May I resume normal working? / Normal working may be resumed.", "QUJ": "Will you indicate the TRUE track to reach you (or ...)? / The TRUE track to reach me (or ...) is ... degrees at ... hours.",
"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 ...", "QUK": "Can you tell me the condition of the sea observed at ... (place or coordinates)? / The sea at ... (place or coordinates) is ...",
"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).", "QUL": "Can you tell me the swell observed at ... (place or coordinates)? / The swell at ... (place or coordinates) is ...",
"QUP": "Will you indicate your position by searchlight/black smoke trail/pyrotechnic lights? / My position is indicated by searchlight/black smoke trail/pyrotechnic lights.", "QUM": "May I resume normal working? / Normal working may be resumed.",
"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.", "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 ...",
"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.", "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).",
"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).", "QUP": "Will you indicate your position by searchlight/black smoke trail/pyrotechnic lights? / My position is indicated by searchlight/black smoke trail/pyrotechnic lights.",
"QUT": "Is position of incident marked? / Position of incident is marked by flame or smoke float/sea marker/sea marker dye/... (specify other marking).", "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.",
"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.", "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.",
"QUW": "Are you in the search area designated as ... (designator or latitude and longitude)? / I am in the ... (designation) search area.", "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).",
"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: ...", "QUT": "Is position of incident marked? / Position of incident is marked by flame or smoke float/sea marker/sea marker dye/... (specify other marking).",
"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).", "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.",
"QUZ": "May I resume restricted working? / Distress phase still in force; restricted working may be resumed.", "QUW": "Are you in the search area designated as ... (designator or latitude and longitude)? / I am in the ... (designation) search area.",
"QZZ": "Daily key change about to take place (German WWII usage)."} "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)."
}
+60
View File
@@ -0,0 +1,60 @@
"""
A listing of hamstudy command resources
---
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.
"""
pool_names = {
"us": {
"technician": "E2",
"tech": "E2",
"t": "E2",
"general": "E3",
"gen": "E3",
"g": "E3",
"extra": "E4",
"e": "E4",
},
"ca": {
"basic": "CA_B",
"b": "CA_B",
"advanced": "CA_A",
"adv": "CA_A",
"a": "CA_A",
"basic_fr": "CA_FB",
"b_fr": "CA_FB",
"base": "CA_FB",
"advanced_fr": "CA_FS",
"adv_fr": "CA_FS",
"a_fr": "CA_FS",
"supérieure": "CA_FS",
"superieure": "CA_FS",
"s": "CA_FS",
},
"us_c": {
"c1": "C1",
"comm1": "C1",
"c3": "C3",
"comm3": "C3",
"c6": "C6",
"comm6": "C6",
"c7": "C7",
"comm7": "C7",
"c7r": "C7R",
"comm7r": "C7R",
"c8": "C8",
"comm8": "C8",
"c9": "C9",
"comm9": "C9",
},
}
pool_emojis = {
"us": "🇺🇸",
"ca": "🇨🇦",
"us_c": "🇺🇸 🏢",
}
+119 -44225
View File
File diff suppressed because it is too large Load Diff
+15 -9
View File
@@ -15,7 +15,10 @@ Settings and options for the bot.
# The prefix for the bot (str). Define a list of stings for multiple prefixes. # The prefix for the bot (str). Define a list of stings for multiple prefixes.
# ie: `["?", "!", "pls "]` # ie: `["?", "!", "pls "]`
prefix = "?" prefix = ["? ", "?"]
# The prefix to use for display purposes (ex: status message).
display_prefix = "?"
# Whether the bot should print full stacktraces for normal exceptions: `True`, # Whether the bot should print full stacktraces for normal exceptions: `True`,
# or be nice and only print small messages: `False` (the default). # or be nice and only print small messages: `False` (the default).
@@ -27,7 +30,7 @@ debug = False
owners_uids = (200102491231092736,) owners_uids = (200102491231092736,)
# The extensions to load when running the bot. # The extensions to load when running the bot.
exts = ['ae7q', 'base', 'fun', 'grid', 'ham', 'image', 'lookup', 'morse', 'qrz', 'study', 'weather'] exts = ["ae7q", "base", "fun", "grid", "ham", "image", "lookup", "morse", "qrz", "study", "weather", "dbconv"]
# Either "time", "random", or "fixed" (first item in statuses) # Either "time", "random", or "fixed" (first item in statuses)
status_mode = "fixed" status_mode = "fixed"
@@ -37,17 +40,20 @@ statuses = ["with lids on the air", "with fire"]
# Timezone for the status (string) # Timezone for the status (string)
# See https://pythonhosted.org/pytz/ for more info # See https://pythonhosted.org/pytz/ for more info
status_tz = 'US/Eastern' status_tz = "US/Eastern"
# The text to put in the "playing" status, with start and stop times # The text to put in the "playing" status, with start and stop times
time_statuses = [('with lids on 3.840', (00, 00), (6, 00)), time_statuses = [("with lids on 3.840", (00, 00), (6, 00)),
('with lids on 7.200', (6, 00), (10, 00)), ("with lids on 7.200", (6, 00), (10, 00)),
('with lids on 14.313', (10, 00), (18, 00)), ("with lids on 14.313", (10, 00), (18, 00)),
('with lids on 7.200', (18, 00), (20, 00)), ("with lids on 7.200", (18, 00), (20, 00)),
('with lids on 3.840', (20, 00), (23, 59))] ("with lids on 3.840", (20, 00), (23, 59))]
# append " | {display_prefix}help" to the Discord playing status
show_help = False
# Emoji IDs and keywords for emoji reactions # Emoji IDs and keywords for emoji reactions
# Use the format {emoji_id (int): ('tuple', 'of', 'lowercase', 'keywords')} # Use the format {emoji_id (int): ("tuple", "of", "lowercase", "keywords")}
msg_reacts = {} msg_reacts = {}
# A :pika: emote's ID, None for no emote :c # A :pika: emote's ID, None for no emote :c
+3
View File
@@ -0,0 +1,3 @@
"""
Various utilities for the bot.
"""
+16
View File
@@ -0,0 +1,16 @@
"""
Wrapper to handle aiohttp connector creation.
---
Copyright (C) 2020 Abigail Gold, 0x5c
This file is part of qrm2 and is released under the terms of
the GNU General Public License, version 2.
"""
import aiohttp
async def new_connector(*args, **kwargs) -> aiohttp.TCPConnector:
"""*Yes, it's just a coro to instantiate a class.*"""
return aiohttp.TCPConnector(*args, **kwargs)