commit ef4641d5dd5092e428350a84d821d62de4f34c73 Author: ChrisChrome Date: Wed May 7 23:46:28 2025 -0600 Moved to a new repo; Fix small thin preventing startup/message handler fix diff --git a/.forgejo/workflows/ptero-push.yml b/.forgejo/workflows/ptero-push.yml new file mode 100644 index 0000000..ba68c3a --- /dev/null +++ b/.forgejo/workflows/ptero-push.yml @@ -0,0 +1,15 @@ +# Workflow that runs on `chris-runner`, tells a pterodactyl server at https://panel.chrischro.me/ to restart server 8f44f1fd-8d29-4553-96f1-05dacfca454f with token stored in PTERO_KEY +name: ptero-push +on: + push: + branches: + - main +jobs: + build: + runs-on: docker + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Run script + run: | + curl -X POST -H "Authorization: Bearer ${{ secrets.PTERO_KEY }}" -H "Content-Type: application/json" https://panel.chrischro.me/api/client/servers/8f44f1fd-8d29-4553-96f1-05dacfca454f/power -d '{"signal":"restart"}' \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..435deb8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,136 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* +config.json +channels.db +private/ +error/ +old/ +package-lock.json \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ab421c0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 2024 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) 2024 + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/PRIVACY.md b/PRIVACY.md new file mode 100644 index 0000000..8d436aa --- /dev/null +++ b/PRIVACY.md @@ -0,0 +1,7 @@ +# Privacy Policy + +Just to make this simple, heres a list of whats stored and how it's used +- Discord channel/user IDs of subscribed channels/DMs - Should be obvious, in case it's not, we need these to know where to send alerts. +- IEM rooms and filters - Should also be obvious, but again, we need to know which rooms you subscribed to + +Other than that, occasional debug logging may be enabled to fix bugs, and any logs gathered from debugging will be erased immidiately. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ea36919 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +[![Join our Discord](https://img.shields.io/discord/1237792259248750673?color=7289DA&label=Discord&logo=discord&logoColor=white&style=for-the-badge)](https://discord.gg/v7aR9MTau8) [![Add the bot](https://img.shields.io/badge/Add%20Bot-Click%20Here-brightgreen?style=for-the-badge&logo=discord&color=7289DA&logoColor=white)](https://discord.com/oauth2/authorize?client_id=1237621947529957426) + +## Warning +This is SUPER tossed together. Might bother cleaning it up later. + +Also If you run this on Windows for Debugging, Sodium might have a few issues installing with MSVS for certain users. + +## What is this? +This is meant to be a public Discord bot. It connects via XMPP to Weather.IM and allows server owners to subscribe a channel to any number of weather alerts. + +## Pre-requisites +1. Node.js +2. NPM +3. A Discord bot token + +## How do I use this? +1. Clone the repo +2. Install the requirements with `npm install` +3. Copy `config.example.json` to `config.json` and fill in the values + - `token` is your Discord bot token + - `owner` is your Discord user ID + - `mainGuild` is the ID of the guild you want to use as the main guild (This is used for making the support invite) + - `inviteChannel` is the ID of the channel you want to use for the support invite + - NTFY config is optional, leave enabled false if you don't want to use it or don't know how. +4. Run `node .` +5. Profit? + +## TODO +- [ ] Clean up the code +- [X] Add more error handling +- [X] Add more logging +- [X] Add more features +- [X] Add more documentation \ No newline at end of file diff --git a/TERMS.md b/TERMS.md new file mode 100644 index 0000000..d578ee4 --- /dev/null +++ b/TERMS.md @@ -0,0 +1,5 @@ +# Terms of Service +## This is mostly here to comply with Discord verified bot stuff + +Other than complying with the GPL-3.0 License when contributing/using the code of this project, this bot is NOT to be used as an emergency alerting system, and should NOT be trusted with life/property under any circumstances. +Chris Chrome and any other contributors are not to be held liable should this not work in an emergency, as you shouldn't be using it for emergency alerts. \ No newline at end of file diff --git a/config.json.template b/config.json.template new file mode 100644 index 0000000..d0945de --- /dev/null +++ b/config.json.template @@ -0,0 +1,36 @@ +{ + "debug": 0, + "voice_enabled": true, + "priorityColors": { + "1": "#00AFFF", + "2": "#00FF00", + "3": "#FFFF00", + "4": "#FFA500", + "5": "#FF0000" + }, + "discord": { + "token": "YOUR_TOKEN", + "owner": "YOUR_ID", + "mainGuild": "YOUR_GUILD", + "inviteChannel": "INVITE_CHANNEL", + "logChannel": "LOG_CHANNEL" + }, + "ntfy": { + "enabled": false, + "server": "https://your.ntfy.server", + "token": "tk_XXXXXXXXXXXXXXXX", + "prefix": "iem-", + "errors": "iem-errors" + }, + "broadcastify": { + "enabled": false, + "username": "YOUR_USERNAME", + "password": "YOUR_PASSWORD" + }, + + "uptime-kuma": { + "enabled": false, + "url": "", + "interval": 60 + } +} \ No newline at end of file diff --git a/data/blacklist.json b/data/blacklist.json new file mode 100644 index 0000000..f0b3e61 --- /dev/null +++ b/data/blacklist.json @@ -0,0 +1,94 @@ +[ + "rerchat@conference.weather.im", + "ncrfcchat@conference.weather.im", + "mkx_madison_spotters@conference.weather.im", + "zanchat@conference.weather.im", + "michiganwxalerts@conference.weather.im", + "skywarnstatewidechase@conference.weather.im", + "wws44fl@conference.weather.im", + "hatchat@conference.weather.im", + "crisfield-chat@conference.weather.im", + "gstweather@conference.weather.im", + "tws_chat@conference.weather.im", + "franklin_chat@conference.weather.im", + "cnrfcchat@conference.weather.im", + "mke-skywarn@conference.weather.im", + "tnwxdiscuss@conference.weather.im", + "khws@conference.weather.im", + "kcichat@conference.weather.im", + "kodster@conference.weather.im", + "wxst@conference.weather.im", + "reddit_weatherlab@conference.weather.im", + "nalsw@conference.weather.im", + "barnburnerwi@conference.weather.im", + "ohiostormspottersteamoss@conference.weather.im", + "siawx_chat@conference.weather.im", + "n90@conference.weather.im", + "nerfcchat@conference.weather.im", + "lmrfcchat@conference.weather.im", + "mbrfcchat@conference.weather.im", + "pitchat@conference.weather.im", + "chachat@conference.weather.im", + "spcmobile2006@conference.weather.im", + "phl@conference.weather.im", + "wbkoweatherwatchers@conference.weather.im", + "gcwxchat@conference.weather.im", + "zzmkxchat@conference.weather.im", + "dentcoeas@conference.weather.im", + "marfcchat@conference.weather.im", + "easwtalk@conference.weather.im", + "gccc-nc-skywarn@conference.weather.im", + "mseas-weather-discussion@conference.weather.im", + "abc3340@conference.weather.im", + "awpwxchat@conference.weather.im", + "wilchat@conference.weather.im", + "okc_chatrooms@conference.weather.im", + "kdtxchat@conference.weather.im", + "wnpchat@conference.weather.im", + "fox6chat@conference.weather.im", + "cbrfcchat@conference.weather.im", + "wisconsin_storm_spotters@conference.weather.im", + "nwrfcchat@conference.weather.im", + "wgrfcchat@conference.weather.im", + "uswat@conference.weather.im", + "iowawx@conference.weather.im", + "ohrfcchat@conference.weather.im", + "serfcchat@conference.weather.im", + "stichat@conference.weather.im", + "whntweather@conference.weather.im", + "knsw@conference.weather.im", + "test@conference.weather.im", + "abc3340skywatcher@conference.weather.im", + "abrfcchat@conference.weather.im", + "bmxspotterchat@conference.weather.im", + "aprfcchat@conference.weather.im", + "wwsreport@conference.weather.im", + "bmxalertchat@conference.weather.im", + "twitter@conference.weather.im", + "potomac_tracon@conference.weather.im", + "detroiteaschat@conference.weather.im", + "cwest@conference.weather.im", + "sweaseops1@conference.weather.im", + "scwx@conference.weather.im", + "nwsc@conference.weather.im", + "zabchat@conference.weather.im", + "ztlchat@conference.weather.im", + "zbwchat@conference.weather.im", + "zauchat@conference.weather.im", + "zobchat@conference.weather.im", + "zdvchat@conference.weather.im", + "zfwchat@conference.weather.im", + "zhuchat@conference.weather.im", + "zidchat@conference.weather.im", + "zjxchat@conference.weather.im", + "zkcchat@conference.weather.im", + "zlachat@conference.weather.im", + "zmechat@conference.weather.im", + "zmachat@conference.weather.im", + "zmpchat@conference.weather.im", + "zoachat@conference.weather.im", + "zlcchat@conference.weather.im", + "zsechat@conference.weather.im", + "zdcchat@conference.weather.im", + "znychat@conference.weather.im" +] \ No newline at end of file diff --git a/data/commands.json b/data/commands.json new file mode 100644 index 0000000..b0742a6 --- /dev/null +++ b/data/commands.json @@ -0,0 +1,256 @@ +[ + { + "name": "subscribe", + "description": "Subscribe to a weather.im room", + "default_member_permissions": 16, + "options": [ + { + "name": "room", + "description": "The room/WFO you want to subscribe to", + "type": 3, + "required": true, + "autocomplete": false + }, + { + "name": "message", + "description": "Custom message to send when alert is sent", + "type": 3, + "required": false + }, + { + "name": "filter", + "description": "Filter for the alert, you can comma separate multiple strings of text", + "type": 3, + "required": false + }, + { + "name": "minpriority", + "description": "Minimum priority to alert for", + "type": 4, + "required": false, + "choices": [ + { + "name": "Any", + "value": 0 + }, + { + "name": "Minimum", + "value": 1 + }, + { + "name": "Low", + "value": 2 + }, + { + "name": "Normal", + "value": 3 + }, + { + "name": "High", + "value": 4 + }, + { + "name": "Very High", + "value": 5 + } + ] + }, + { + "name": "filterevt", + "description": "Filter for event type, you can comma separate multiple strings of text", + "type": 3, + "required": false + } + ] + }, + { + "name": "unsubscribe", + "description": "Unsubscribe from a weather.im room", + "default_member_permissions": 16, + "options": [ + { + "name": "room", + "description": "The room/WFO you want to unsubscribe from", + "type": 3, + "required": true, + "autocomplete": false + } + ] + }, + + { + "name": "list", + "description": "List all subscribed rooms for this channel", + "default_member_permissions": 16 + }, + { + "name": "about", + "description": "About this bot", + "integration_types": [0,1], + "contexts": [0, 1, 2] + }, + { + "name": "rooms", + "description": "List all available rooms" + }, + { + "name": "setupall", + "description": "[BOT OWNER ONLY] Setup channels in a category for all rooms", + "default_member_permissions": 0, + "type": 1 + }, + { + "name": "support", + "description": "Get support for the bot", + "type": 1, + "integration_types": [0,1], + "contexts": [0, 1, 2] + }, + { + "name": "outlook", + "description": "Get day 1-8 storm or fire outlook from the SPC", + "type": 1, + "integration_types": [0,1], + "contexts": [0, 1, 2], + "options": [ + { + "name": "day", + "description": "Day of outlook", + "type": 4, + "required": true, + "choices": [ + { + "name": "Day 1", + "value": 0 + }, + { + "name": "Day 2", + "value": 1 + }, + { + "name": "Day 3", + "value": 2 + }, + { + "name": "Day 4", + "value": 3 + }, + { + "name": "Day 5", + "value": 4 + }, + { + "name": "Day 6", + "value": 5 + }, + { + "name": "Day 7", + "value": 6 + }, + { + "name": "Day 8", + "value": 7 + } + ] + }, + { + "name": "type", + "description": "Type of outlook", + "type": 3, + "required": true, + "choices": [ + { + "name": "Fire", + "value": "fire" + }, + { + "name": "Convective", + "value": "convective" + } + ] + }, + { + "name": "population_overlay", + "description": "Whether to add the population overlay", + "type": 5, + "required": false + }, + { + "name": "city_overlay", + "description": "Whether to add the city name overlay", + "type": 5, + "required": false + }, + { + "name": "cwa_overlay", + "description": "Whether to add the County Warning Area overlay", + "type": 5, + "required": false + }, + { + "name": "rfc_overlay", + "description": "Whether to add the River Forecast Center overlay", + "type": 5, + "required": false + }, + { + "name": "interstate_overlay", + "description": "Whether to add the interstate overlay", + "type": 5, + "required": false + }, + { + "name": "county_overlay", + "description": "Whether to add the county lines overlay", + "type": 5, + "required": false + }, + { + "name": "tribal_overlay", + "description": "Whether to add the tribal lands overlay", + "type": 5, + "required": false + }, + { + "name": "artcc_overlay", + "description": "Whether to add the Air Route Traffic Control Centers overlay", + "type": 5, + "required": false + }, + { + "name": "fema_overlay", + "description": "Whether to add the FEMA regions overlay", + "type": 5, + "required": false + } + ] + }, + { + "name": "alertmap", + "description": "Get a map of active alerts", + "type": 1, + "integration_types": [0,1], + "contexts": [0, 1, 2] + }, + { + "name": "forecast", + "description": "Get a forecast for a location", + "type": 1, + "integration_types": [0,1], + "contexts": [0, 1, 2], + "options": [ + { + "name": "location", + "description": "Location to get forecast for (In the United States)", + "type": 3, + "required": true + }, + { + "name": "periods", + "description": "Number of periods to get forecast for", + "type": 4, + "required": false + } + ] + } +] \ No newline at end of file diff --git a/data/events.json b/data/events.json new file mode 100644 index 0000000..5b4fc35 --- /dev/null +++ b/data/events.json @@ -0,0 +1,1530 @@ +{ + "ABV": { + "priority": 1, + "text": "Rawinsonde Data Above 100 Millibars" + }, + "ADA": { + "priority": 1, + "text": "Alarm/Alert Administrative Msg" + }, + "ADM": { + "priority": 1, + "text": "Alert Administrative Message" + }, + "ADR": { + "text": "Administrative Message", + "priority": 5 + }, + "ADV": { + "priority": 1, + "text": "Generic Space Environment Advisory" + }, + "AFD": { + "priority": 1, + "text": "Area Forecast Discussion" + }, + "AFM": { + "priority": 1, + "text": "Area Forecast Matrices" + }, + "AFP": { + "priority": 1, + "text": "Area Forecast Product" + }, + "AFW": { + "priority": 1, + "text": "Fire Weather Matrix" + }, + "AGF": { + "priority": 1, + "text": "Agricultural Forecast" + }, + "AGO": { + "priority": 1, + "text": "Agricultural Observations" + }, + "ALT": { + "priority": 1, + "text": "Space Environment Alert" + }, + "AQA": { + "priority": 2, + "text": "Air Quality Alert" + }, + "AQI": { + "priority": 1, + "text": "Air Quality Index Statement" + }, + "ASA": { + "priority": 1, + "text": "Air Stagnation Advisory" + }, + "AVA": { + "text": "Avalanche Watch", + "priority": 3 + }, + "AVG": { + "priority": 1, + "text": "Avalanche Weather Guidance" + }, + "AVW": { + "text": "Avalanche Warning", + "priority": 5 + }, + "AWO": { + "priority": 1, + "text": "Area Weather Outlook" + }, + "AWS": { + "priority": 1, + "text": "Area Weather Summary" + }, + "AWU": { + "priority": 1, + "text": "Area Weather Update" + }, + "AWW": { + "priority": 1, + "text": "Airport Weather Warning" + }, + "BLU": { + "priority": 5, + "text": "Blue Alert" + }, + "BOY": { + "priority": 1, + "text": "Buoy Report" + }, + "BRG": { + "priority": 1, + "text": "Coast Guard Observations" + }, + "BRT": { + "priority": 1, + "text": "Hourly Roundup for Weather Radio" + }, + "CAE": { + "text": "Child Abduction Emergency", + "priority": 5 + }, + "CCF": { + "priority": 1, + "text": "Coded City Forecast" + }, + "CDW": { + "text": "Civil Danger Warning", + "priority": 5 + }, + "CEM": { + "text": "Civil Emergency Message", + "priority": 5 + }, + "CF6": { + "priority": 1, + "text": "WFO Monthly/Daily Climate Data" + }, + "CFP": { + "priority": 1, + "text": "Convective Forecast Product" + }, + "CFW": { + "text": "Coastal Flood Warning", + "priority": 5 + }, + "CGR": { + "priority": 1, + "text": "Coast Guard Surface Report" + }, + "CHG": { + "priority": 1, + "text": "Computer Hurricane Guidance" + }, + "CLA": { + "priority": 1, + "text": "Climatological Report (Annual)" + }, + "CLI": { + "priority": 1, + "text": "Climatological Report (Daily)" + }, + "CLM": { + "priority": 1, + "text": "Climatological Report (Monthly)" + }, + "CLQ": { + "priority": 1, + "text": "Climatological Report (Quarterly)" + }, + "CLS": { + "priority": 1, + "text": "Climatological Report (Seasonal)" + }, + "CLT": { + "priority": 1, + "text": "Climate Report" + }, + "CMM": { + "priority": 1, + "text": "Coded Climatological Monthly Means" + }, + "COD": { + "priority": 1, + "text": "Coded Analysis and Forecasts" + }, + "CPF": { + "priority": 1, + "text": "Great Lakes Port Forecast" + }, + "CUR": { + "priority": 1, + "text": "Routine Space Environment Products" + }, + "CWA": { + "priority": 1, + "text": "Center (CWSU) Weather Advisory" + }, + "CWF": { + "priority": 1, + "text": "Coastal Waters Forecast" + }, + "CWS": { + "priority": 1, + "text": "Center (CWSU) Weather Statement" + }, + "DAY": { + "priority": 1, + "text": "Routine Space Environment Product (Daily)" + }, + "DDO": { + "priority": 1, + "text": "Daily Dispersion Outlook" + }, + "DGT": { + "priority": 1, + "text": "Drought Information Statement" + }, + "DMO": { + "text": "Practice/Demo Warning", + "priority": 1 + }, + "DSA": { + "priority": 1, + "text": "Unnumbered Depression / Suspicious Area Advisory" + }, + "DSM": { + "priority": 1, + "text": "ASOS Daily Summary" + }, + "DSW": { + "text": "Dust Storm Warning", + "priority": 4 + }, + "EFP": { + "priority": 1, + "text": "3 To 5 Day Extended Forecast" + }, + "EOL": { + "priority": 1, + "text": "Average 6 To 10 Day Weather Outlook (Local)" + }, + "EQI": { + "priority": 3, + "text": "Tsunami Bulletin" + }, + "EQR": { + "priority": 1, + "text": "Earthquake Report" + }, + "EQW": { + "text": "Earthquake Warning", + "priority": 5 + }, + "ESF": { + "priority": 1, + "text": "Flood Potential Outlook" + }, + "ESG": { + "priority": 1, + "text": "Extended Streamflow Guidance" + }, + "ESP": { + "priority": 1, + "text": "Extended Streamflow Prediction" + }, + "ESS": { + "priority": 1, + "text": "Water Supply Outlook" + }, + "EVI": { + "text": "Evacuation Immediate", + "priority": 5 + }, + "EWW": { + "priority": 5, + "text": "Extreme Wind Warning" + }, + "FA0": { + "priority": 1, + "text": "Aviation Area Forecasts (Pacific)" + }, + "FA1": { + "priority": 1, + "text": "Aviation Area Forecasts (Northeast)" + }, + "FA2": { + "priority": 1, + "text": "Aviation Area Forecasts (Southeast)" + }, + "FA3": { + "priority": 1, + "text": "Aviation Area Forecasts (North Central)" + }, + "FA4": { + "priority": 1, + "text": "Aviation Area Forecasts (South Central)" + }, + "FA5": { + "priority": 1, + "text": "Aviation Area Forecasts (Rocky Mountains)" + }, + "FA6": { + "priority": 1, + "text": "Aviation Area Forecasts (West Coast)" + }, + "FA7": { + "priority": 1, + "text": "Aviation Area Forecasts (Juneau, AK)" + }, + "FA8": { + "priority": 1, + "text": "Aviation Area Forecasts (Anchorage, AK)" + }, + "FA9": { + "priority": 1, + "text": "Aviation Area Forecasts (Fairbanks, AK)" + }, + "FD0": { + "priority": 1, + "text": "24 Hr Fd Winds Aloft Fcst (45,000 and 53,000 Ft)" + }, + "FD1": { + "priority": 1, + "text": "6 Hour Winds Aloft Forecast" + }, + "FD2": { + "priority": 1, + "text": "12 Hour Winds Aloft Forecast" + }, + "FD3": { + "priority": 1, + "text": "24 Hour Winds Aloft Forecast" + }, + "FD4": { + "priority": 1, + "text": "Winds Aloft Forecast" + }, + "FD5": { + "priority": 1, + "text": "Winds Aloft Forecast" + }, + "FD6": { + "priority": 1, + "text": "Winds Aloft Forecast" + }, + "FD7": { + "priority": 1, + "text": "Winds Aloft Forecast" + }, + "FD8": { + "priority": 1, + "text": "6 Hour Fd Winds Aloft Fcst (45,000 and 53,000 Ft)" + }, + "FD9": { + "priority": 1, + "text": "12 Hr Fd Winds Aloft Fcst (45,000 and 53,000 Ft)" + }, + "FDI": { + "priority": 1, + "text": "Fire Danger Indices" + }, + "FFA": { + "text": "Flash Flood Watch", + "priority": 4 + }, + "FFG": { + "priority": 1, + "text": "Flash Flood Guidance" + }, + "FFH": { + "priority": 1, + "text": "Headwater Guidance" + }, + "FFS": { + "text": "Flash Flood Statement", + "priority": 2 + }, + "FFW": { + "text": "Flash Flood Warning", + "priority": 4 + }, + "FLN": { + "priority": 1, + "text": "National Flood Summary" + }, + "FLS": { + "text": "Flood Statement", + "priority": 2 + }, + "FLW": { + "text": "Flood Warning", + "priority": 3 + }, + "FOF": { + "priority": 1, + "text": "Upper Wind Fallout Forecast" + }, + "FRW": { + "text": "Fire Warning", + "priority": 3 + }, + "FSH": { + "priority": 1, + "text": "Natl Marine Fisheries Administrative Service Message" + }, + "FTM": { + "priority": 3, + "text": "WSR-88D Radar Outage Notification / Free Text Message" + }, + "FTP": { + "priority": 1, + "text": "FOUS Prog Max/Min Temp/Pop Guidance" + }, + "FWA": { + "priority": 1, + "text": "Fire Weather Administrative Message" + }, + "FWD": { + "priority": 1, + "text": "Fire Weather Outlook Discussion" + }, + "FWF": { + "priority": 1, + "text": "Routine Fire Wx Fcst (With/Without 6-10 Day Outlook)" + }, + "FWL": { + "priority": 1, + "text": "Land Management Forecasts" + }, + "FWM": { + "priority": 1, + "text": "Miscellaneous Fire Weather Product" + }, + "FWN": { + "priority": 1, + "text": "Fire Weather Notification" + }, + "FWO": { + "priority": 1, + "text": "Fire Weather Observation" + }, + "FWS": { + "priority": 1, + "text": "Spot Forecast" + }, + "FZL": { + "priority": 1, + "text": "Freezing Level Data (RADAT)" + }, + "GLF": { + "priority": 1, + "text": "Great Lakes Forecast" + }, + "GLS": { + "priority": 1, + "text": "Great Lakes Storm Summary" + }, + "GRE": { + "priority": 1, + "text": "GREEN" + }, + "HD1": { + "priority": 1, + "text": "RFC Derived QPF Data Product" + }, + "HD2": { + "priority": 1, + "text": "RFCDerived QPF Data Product" + }, + "HD3": { + "priority": 1, + "text": "RFC Derived QPF Data Product" + }, + "HD4": { + "priority": 1, + "text": "RFC Derived QPF Data Product" + }, + "HD7": { + "priority": 1, + "text": "RFC Derived QPF Data Product" + }, + "HD8": { + "priority": 1, + "text": "RFC Derived QPF Data Product" + }, + "HD9": { + "priority": 1, + "text": "RFC Derived QPF Data Product" + }, + "HLS": { + "text": "Hurricane Statement", + "priority": 3 + }, + "HMD": { + "priority": 1, + "text": "Hydrometeorological Discussion" + }, + "HML": { + "priority": 1, + "text": "AHPS XML" + }, + "HMW": { + "text": "Hazardous Materials Warning", + "priority": 5 + }, + "HP1": { + "priority": 1, + "text": "RFC QPF Verification Product" + }, + "HP2": { + "priority": 1, + "text": "RFC QPF Verification Product" + }, + "HP3": { + "priority": 1, + "text": "RFC QPF Verification Product" + }, + "HP4": { + "priority": 1, + "text": "RFC QPF Verification Product" + }, + "HP5": { + "priority": 1, + "text": "RFC QPF Verification Product" + }, + "HP6": { + "priority": 1, + "text": "RFC QPF Verification Product" + }, + "HP7": { + "priority": 1, + "text": "RFC QPF Verification Product" + }, + "HP8": { + "priority": 1, + "text": "RFC QPF Verification Product" + }, + "HRR": { + "priority": 1, + "text": "Weather Roundup" + }, + "HSF": { + "priority": 1, + "text": "High Seas Forecast" + }, + "HWO": { + "priority": 2, + "text": "Hazardous Weather Outlook" + }, + "HWR": { + "priority": 1, + "text": "Hourly Weather Roundup" + }, + "HYD": { + "priority": 1, + "text": "Daily Hydrometeorological Products" + }, + "HYM": { + "priority": 1, + "text": "Monthly Hydrometeorological Plain Language Product" + }, + "ICE": { + "priority": 1, + "text": "Ice Forecast" + }, + "IDM": { + "priority": 1, + "text": "Ice Drift Vectors" + }, + "INI": { + "priority": 1, + "text": "ADMINISTR [NOUS51 KWBC]" + }, + "IOB": { + "priority": 1, + "text": "Ice Observation" + }, + "KPA": { + "priority": 1, + "text": "Keep Alive Message" + }, + "LAE": { + "text": "Local Area Emergency", + "priority": 5 + }, + "LCD": { + "priority": 1, + "text": "Preliminary Local Climatological Data" + }, + "LCO": { + "priority": 1, + "text": "Local Cooperative Observation" + }, + "LEW": { + "text": "Law Enforcement Warning", + "priority": 5 + }, + "LFP": { + "priority": 2, + "text": "Local Forecast" + }, + "LKE": { + "priority": 1, + "text": "Lake Stages" + }, + "LLS": { + "priority": 1, + "text": "Low-Level Sounding" + }, + "LOW": { + "priority": 1, + "text": "Low Temperatures" + }, + "LSR": { + "priority": 3, + "text": "Local Storm Report" + }, + "LTG": { + "priority": 1, + "text": "Lightning Data" + }, + "MAN": { + "priority": 1, + "text": "Rawinsonde Observation Mandatory Levels" + }, + "MAP": { + "priority": 1, + "text": "Mean Areal Precipitation" + }, + "MAW": { + "priority": 1, + "text": "Amended Marine Forecast" + }, + "MFM": { + "priority": 1, + "text": "Marine Forecast Matrix" + }, + "MIM": { + "priority": 1, + "text": "Marine Interpretation Message" + }, + "MIS": { + "priority": 1, + "text": "Miscellaneous Local Product" + }, + "MOB": { + "priority": 1, + "text": "MOB Observations" + }, + "MON": { + "priority": 1, + "text": "Routine Space Environment Product Issued Monthly" + }, + "MRP": { + "priority": 1, + "text": "Techniques Development Laboratory Marine Product" + }, + "MSM": { + "priority": 1, + "text": "ASOS Monthly Summary Message" + }, + "MTR": { + "priority": 1, + "text": "METAR Formatted Surface Weather Observation" + }, + "MTT": { + "priority": 1, + "text": "METAR Test Message" + }, + "MVF": { + "priority": 1, + "text": "Marine Verification Coded Message" + }, + "MWS": { + "priority": 1, + "text": "Marine Weather Statement" + }, + "MWW": { + "priority": 1, + "text": "Marine Weather Message" + }, + "NOU": { + "priority": 1, + "text": "Weather Reconnaisance Flights" + }, + "NOW": { + "priority": 1, + "text": "Short Term Forecast" + }, + "NOX": { + "priority": 1, + "text": "Data Mgt Message" + }, + "NPW": { + "priority": 3, + "text": "Non-Precipitation Warnings / Watches / Advisories" + }, + "NSH": { + "priority": 1, + "text": "Nearshore Marine Forecast" + }, + "NUW": { + "text": "Nuclear Power Plant Warning", + "priority": 5 + }, + "NWR": { + "priority": 1, + "text": "NOAA Weather Radio Forecast" + }, + "OAV": { + "priority": 1, + "text": "Other Aviation Products" + }, + "OBS": { + "priority": 1, + "text": "Observations" + }, + "OFA": { + "priority": 1, + "text": "Offshore Aviation Area Forecast" + }, + "OFF": { + "priority": 1, + "text": "Offshore Forecast" + }, + "OMR": { + "priority": 1, + "text": "Other Marine Products" + }, + "OPU": { + "priority": 1, + "text": "Other Public Products" + }, + "OSO": { + "priority": 1, + "text": "Other Surface Observations" + }, + "OSW": { + "priority": 1, + "text": "Ocean Surface Winds" + }, + "OUA": { + "priority": 1, + "text": "Other Upper Air Data" + }, + "OZF": { + "priority": 1, + "text": "Zone Forecast" + }, + "PFM": { + "priority": 1, + "text": "Point Forecast Matrices" + }, + "PFW": { + "priority": 1, + "text": "Fire Weather Point Forecast Matrices" + }, + "PLS": { + "priority": 1, + "text": "Plain Language Ship Report" + }, + "PMD": { + "priority": 1, + "text": "Prognostic Meteorological Discussion" + }, + "PNS": { + "priority": 2, + "text": "Public Information Statement" + }, + "POE": { + "priority": 1, + "text": "Probability of Exceed" + }, + "PRB": { + "priority": 1, + "text": "Heat Index Forecast Tables" + }, + "PRC": { + "priority": 1, + "text": "State Pilot Report Collective" + }, + "PRE": { + "priority": 1, + "text": "Preliminary Forecasts" + }, + "PSH": { + "priority": 2, + "text": "Post Storm Hurricane Report" + }, + "PTS": { + "priority": 3, + "text": "Probabilistic Outlook Points" + }, + "PWO": { + "priority": 1, + "text": "Public Severe Weather Outlook" + }, + "PWS": { + "priority": 1, + "text": "Tropical Cyclone Probabilities" + }, + "QPF": { + "priority": 1, + "text": "Quantitative Precipitation Forecast" + }, + "QPS": { + "priority": 1, + "text": "Quantitative Precipitation Statement" + }, + "RDF": { + "priority": 1, + "text": "Revised Digital Forecast" + }, + "REC": { + "priority": 1, + "text": "Recreational Report" + }, + "RER": { + "priority": 2, + "text": "Record Report" + }, + "RET": { + "priority": 5, + "text": "EAS Activation Request" + }, + "RFD": { + "priority": 1, + "text": "Rangeland Fire Danger Forecast" + }, + "RFI": { + "priority": 1, + "text": "RFI Observation" + }, + "RFR": { + "priority": 1, + "text": "Route Forecast" + }, + "RFW": { + "priority": 3, + "text": "Red Flag Warning" + }, + "RHW": { + "text": "Radiological Hazard Warning", + "priority": 5 + }, + "RMT": { + "text": "Required Monthly Test", + "priority": 1 + }, + "RNS": { + "priority": 1, + "text": "Rain Information Statement" + }, + "RR1": { + "priority": 1, + "text": "Hydro-Met Data Report Part 1" + }, + "RR2": { + "priority": 1, + "text": "Hydro-Met Data Report Part 2" + }, + "RR3": { + "priority": 1, + "text": "Hydro-Met Data Report Part 3" + }, + "RR4": { + "priority": 1, + "text": "Hydro-Met Data Report Part 4" + }, + "RR5": { + "priority": 1, + "text": "Hydro-Met Data Report Part 5" + }, + "RR6": { + "priority": 1, + "text": "Hydro-Met Data Report Part 6" + }, + "RR7": { + "priority": 1, + "text": "Hydro-Met Data Report Part 7" + }, + "RR8": { + "priority": 1, + "text": "Hydro-Met Data Report Part 8" + }, + "RR9": { + "priority": 1, + "text": "Hydro-Met Data Report Part 9" + }, + "RRA": { + "priority": 1, + "text": "Automated Hydrologic Observation Sta Report (AHOS)" + }, + "RRM": { + "priority": 1, + "text": "Miscellaneous Hydrologic Data" + }, + "RRS": { + "priority": 1, + "text": "HADS Data" + }, + "RRY": { + "priority": 1, + "text": "ASOS SHEF Hourly Routine Test Message" + }, + "RSD": { + "priority": 1, + "text": "Daily Snotel Data" + }, + "RSM": { + "priority": 1, + "text": "Monthly Snotel Data" + }, + "RTP": { + "priority": 1, + "text": "Regional Max/Min Temp and Precipitation Table" + }, + "RVA": { + "priority": 1, + "text": "River Summary" + }, + "RVD": { + "priority": 1, + "text": "Daily River Forecasts" + }, + "RVF": { + "priority": 1, + "text": "River Forecast" + }, + "RVI": { + "priority": 1, + "text": "River Ice Statement" + }, + "RVM": { + "priority": 1, + "text": "Miscellaneous River Product" + }, + "RVR": { + "priority": 1, + "text": "River Recreation Statement" + }, + "RVS": { + "priority": 1, + "text": "River Statement" + }, + "RWR": { + "priority": 1, + "text": "Regional Weather Roundup" + }, + "RWS": { + "priority": 1, + "text": "Regional Weather Summary" + }, + "RWT": { + "text": "Required Weekly Test", + "priority": 1 + }, + "SAB": { + "priority": 1, + "text": "Special Avalanche Bulletin" + }, + "SAF": { + "priority": 1, + "text": "Speci Agri Wx Fcst / Advisory / Flying Farmer Fcst Outlook" + }, + "SAG": { + "priority": 1, + "text": "Snow Avalanche Guidance" + }, + "SAT": { + "priority": 1, + "text": "APT Prediction" + }, + "SAW": { + "priority": 1, + "text": "Prelim Notice of Watch & Cancellation Msg (Aviation)" + }, + "SCC": { + "priority": 2, + "text": "Storm Summary" + }, + "SCD": { + "priority": 1, + "text": "Supplementary Climatological Data (ASOS)" + }, + "SCN": { + "priority": 1, + "text": "Soil Climate Analysis Network Data" + }, + "SCP": { + "priority": 1, + "text": "Satellite Cloud Product" + }, + "SCS": { + "priority": 1, + "text": "Selected Cities Summary" + }, + "SDO": { + "priority": 1, + "text": "Supplementary Data Observation (ASOS)" + }, + "SDS": { + "priority": 1, + "text": "Special Dispersion Statement" + }, + "SEL": { + "priority": 4, + "text": "Severe Local Storm Watch and Watch Cancellation Msg" + }, + "SEV": { + "priority": 1, + "text": "SPC Watch Point Information Message" + }, + "SFP": { + "priority": 1, + "text": "State Forecast" + }, + "SFT": { + "priority": 1, + "text": "Tabular State Forecast" + }, + "SGL": { + "priority": 1, + "text": "Rawinsonde Observation Significant Levels" + }, + "SHP": { + "priority": 1, + "text": "Surface Ship Report at Synoptic Time" + }, + "SIG": { + "priority": 1, + "text": "International Sigmet / Convective Sigmet" + }, + "SIM": { + "priority": 1, + "text": "Satellite Interpretation Message" + }, + "SLS": { + "priority": 1, + "text": "Severe Local Storm Watch and Areal Outline" + }, + "SMF": { + "priority": 1, + "text": "Smoke Management Weather Forecast" + }, + "SMW": { + "text": "Special Marine Warning", + "priority": 4 + }, + "SOO": { + "priority": 1, + "text": "SOO Product" + }, + "SPE": { + "priority": 1, + "text": "Satellite Precipitation Estimates (TXUS20 KWBC)" + }, + "SPF": { + "priority": 1, + "text": "Storm Strike Probability Bulletin (TPC)" + }, + "SPS": { + "text": "Special Weather Statement", + "priority": 2 + }, + "SPW": { + "text": "Shelter In Place Warning", + "priority": 5 + }, + "SQW": { + "priority": 5, + "text": "Snow Squall Warning" + }, + "SRD": { + "priority": 1, + "text": "Surf Discussion" + }, + "SRF": { + "priority": 1, + "text": "Surf Forecast" + }, + "SRG": { + "priority": 1, + "text": "Soaring Guidance" + }, + "SSM": { + "priority": 1, + "text": "Main Synoptic Hour Surface Observation" + }, + "STA": { + "priority": 1, + "text": "Network and Severe Weather Statistical Summaries" + }, + "STD": { + "priority": 1, + "text": "Satellite Tropical Disturbance Summary" + }, + "STO": { + "priority": 1, + "text": "Road Condition Reports (State Agencies)" + }, + "STP": { + "priority": 1, + "text": "State Max/Min Temperature and Precipitation Table" + }, + "STQ": { + "priority": 1, + "text": "Spot Forecast Request" + }, + "SUM": { + "priority": 1, + "text": "Space Weather Message" + }, + "SVR": { + "text": "Severe Thunderstorm Warning", + "priority": 5 + }, + "SVS": { + "text": "Severe Weather Statement", + "priority": 3 + }, + "SWO": { + "priority": 4, + "text": "Severe Storm Outlook Narrative (AC)" + }, + "SWS": { + "priority": 1, + "text": "State Weather Summary" + }, + "SYN": { + "priority": 1, + "text": "Regional Weather Synopsis" + }, + "TAF": { + "priority": 1, + "text": "Terminal Aerodrome Forecast" + }, + "TAP": { + "priority": 1, + "text": "Terminal Alerting Products" + }, + "TAV": { + "priority": 1, + "text": "Travelers Forecast Table" + }, + "TCA": { + "priority": 1, + "text": "Aviation Tropical Cyclone Advisory" + }, + "TCD": { + "priority": 1, + "text": "Tropical Cyclone Discussion" + }, + "TCE": { + "priority": 1, + "text": "Tropical Cyclone Position Estimate" + }, + "TCM": { + "priority": 1, + "text": "Marine/Aviation Tropical Cyclone Advisory" + }, + "TCP": { + "priority": 1, + "text": "Public Tropical Cyclone Advisory" + }, + "TCS": { + "priority": 1, + "text": "Satellite Tropical Cyclone Summary" + }, + "TCU": { + "priority": 1, + "text": "Tropical Cyclone Update" + }, + "TCV": { + "priority": 4, + "text": "Tropical Cyclone Watch/Warning Break Points" + }, + "TIB": { + "priority": 4, + "text": "Tsunami Bulletin" + }, + "TID": { + "priority": 1, + "text": "Tide Report" + }, + "TMA": { + "priority": 1, + "text": "Tsunami Tide/Seismic Message Acknowledgement" + }, + "TOE": { + "text": "911 Telephone Outage Emergency", + "priority": 5 + }, + "TOR": { + "text": "Tornado Warning", + "priority": 5 + }, + "TPT": { + "priority": 1, + "text": "Temperature Precipitation Table (Natl and Intnl)" + }, + "TSU": { + "priority": 5, + "text": "Tsunami Watch/Warning" + }, + "TUV": { + "priority": 1, + "text": "Weather Bulletin" + }, + "TVL": { + "priority": 1, + "text": "Travelers Forecast" + }, + "TWB": { + "priority": 1, + "text": "Transcribed Weather Broadcast" + }, + "TWD": { + "priority": 1, + "text": "Tropical Weather Discussion" + }, + "TWO": { + "priority": 1, + "text": "Tropical Weather Outlook and Summary" + }, + "TWS": { + "priority": 1, + "text": "Tropical Weather Summary" + }, + "URN": { + "priority": 1, + "text": "Aircraft Reconnaissance" + }, + "UVI": { + "priority": 1, + "text": "Ultraviolet Index" + }, + "VAA": { + "priority": 3, + "text": "Volcanic Activity Advisory" + }, + "VER": { + "priority": 1, + "text": "Forecast Verification Statistics" + }, + "VFT": { + "priority": 1, + "text": "Terminal Aerodrome Forecast (TAF) Verification" + }, + "VOW": { + "text": "Volcano Warning", + "priority": 5 + }, + "WA0": { + "priority": 1, + "text": "Airmet (Pacific)" + }, + "WA1": { + "priority": 1, + "text": "Airmet (Northeast)" + }, + "WA2": { + "priority": 1, + "text": "Airmet (Southeast)" + }, + "WA3": { + "priority": 1, + "text": "Airmet (North Central)" + }, + "WA4": { + "priority": 1, + "text": "Airmet (South Central)" + }, + "WA5": { + "priority": 1, + "text": "Airmet (Rocky Mountains)" + }, + "WA6": { + "priority": 1, + "text": "Airmet (West Coast)" + }, + "WA7": { + "priority": 1, + "text": "Airmet (Juneau, AK)" + }, + "WA8": { + "priority": 1, + "text": "Airmet (Anchorage, AK)" + }, + "WA9": { + "priority": 1, + "text": "Airmet (Fairbanks, AK)" + }, + "WAR": { + "priority": 1, + "text": "Space Environment Warning" + }, + "WAT": { + "priority": 1, + "text": "Space Environment Watch" + }, + "WCN": { + "priority": 5, + "text": "Weather Watch Clearance Notification" + }, + "WCR": { + "priority": 1, + "text": "Weekly Weather and Crop Report" + }, + "WDA": { + "priority": 1, + "text": "Weekly Data for Agriculture" + }, + "WDU": { + "priority": 2, + "text": "Warning Decision Update" + }, + "WEK": { + "priority": 1, + "text": "Routine Space Environment Product Issued Weekly" + }, + "WOU": { + "priority": 4, + "text": "Tornado/Severe Thunderstorm Watch" + }, + "WS1": { + "priority": 1, + "text": "Sigmet (Northeast)" + }, + "WS2": { + "priority": 1, + "text": "Sigmet (Southeast)" + }, + "WS3": { + "priority": 1, + "text": "Sigmet (North Central)" + }, + "WS4": { + "priority": 1, + "text": "Sigmet (South Central)" + }, + "WS5": { + "priority": 1, + "text": "Sigmet (Rocky Mountains)" + }, + "WS6": { + "priority": 1, + "text": "Sigmet (West Coast)" + }, + "WST": { + "priority": 1, + "text": "Tropical Cyclone Sigmet" + }, + "WSV": { + "priority": 1, + "text": "Volcanic Activity Sigmet" + }, + "WSW": { + "text": "Winter Storm Warning", + "priority": 4 + }, + "WWA": { + "priority": 1, + "text": "Watch Status Report" + }, + "WWP": { + "priority": 3, + "text": "Severe Thunderstorm / Tornado Watch Probabilities" + }, + "ZFP": { + "priority": 2, + "text": "Zone Forecast Product" + }, + "BZW": { + "text": "Blizzard Warning", + "priority": 5 + }, + "CFA": { + "text": "Coastal Flood Watch", + "priority": 4 + }, + "FLA": { + "text": "Flood Watch", + "priority": 2 + }, + "HWA": { + "text": "High Wind Watch", + "priority": 4 + }, + "HWW": { + "text": "High Wind Warning", + "priority": 5 + }, + "HUA": { + "text": "Hurricane Watch", + "priority": 4 + }, + "HUW": { + "text": "Hurricane Warning", + "priority": 5 + }, + "SVA": { + "text": "Severe Thunderstorm Watch", + "priority": 4 + }, + "TOA": { + "text": "Tornado Watch", + "priority": 5 + }, + "TRA": { + "text": "Tropical Storm Watch", + "priority": 4 + }, + "TRW": { + "text": "Tropical Storm Warning", + "priority": 5 + }, + "TSA": { + "text": "Tsunami Watch", + "priority": 4 + }, + "TSW": { + "text": "Tsunami Warning", + "priority": 5 + }, + "WSA": { + "text": "Winter Storm Watch", + "priority": 4 + }, + "EAN": { + "text": "Emergency Action Notification", + "priority": 5 + }, + "EAT": { + "text": "Emergency Action Termination", + "priority": 5 + }, + "NIC": { + "text": "National Information Center", + "priority": 5 + }, + "NPT": { + "text": "National Periodic Test", + "priority": 5 + }, + "BHW": { + "text": "Biological Hazard Warning", + "priority": 5 + }, + "BWW": { + "text": "Boil Water Warning", + "priority": 5 + }, + "CWW": { + "text": "Conataminated Water Warning", + "priority": 5 + }, + "DBA": { + "text": "Dam Break Watch", + "priority": 4 + }, + "DBW": { + "text": "Dam Break Warning", + "priority": 5 + }, + "DEW": { + "text": "Contagious Disease Warning", + "priority": 5 + }, + "EVA": { + "text": "Evacuation Watch", + "priority": 4 + }, + "FCW": { + "text": "Food Contamination Warning", + "priority": 3 + }, + "FSW": { + "text": "Flash Freeze Warning", + "priority": 4 + }, + "FZW": { + "text": "Freeze Warning", + "priority": 5 + }, + "IBW": { + "text": "Iceberg Warning", + "priority": 4 + }, + "IFW": { + "text": "Industrial Fire Warning", + "priority": 4 + }, + "LSW": { + "text": "Land Slide Warning", + "priority": 4 + }, + "NAT": { + "text": "National Audible Test", + "priority": 4 + }, + "NST": { + "text": "National Silent Test", + "priority": 4 + }, + "POS": { + "text": "Power Outage Statement", + "priority": 2 + }, + "WFA": { + "text": "Wild Fire Watch", + "priority": 3 + }, + "WFW": { + "text": "Wild Fire Warning", + "priority": 3 + }, + "NMN": { + "text": "Network Message Notification", + "priority": 5 + }, + "AHD": { + "text": "Area Hydrological Discussion", + "priority": 1 + }, + "GMT": { + "text": "AIRMET", + "priority": 1 + }, + "AHO": { + "text": "High Density Observations (USAF/NOAA)", + "priority": 3 + }, + "REP": { + "text": "RECCO Observations (tropical cyclone)", + "priority": 3 + }, + "PIR": { + "text": "Pilot Reports", + "priority": 1 + } +} diff --git a/data/nwrstreams.json b/data/nwrstreams.json new file mode 100644 index 0000000..8d1c6f9 --- /dev/null +++ b/data/nwrstreams.json @@ -0,0 +1,11 @@ +{ + "callsigns": { + "WXL46": "https://icecast.sirenarchive.xyz/NWR/WXL46", + "WXJ61": "https://icecast.sirenarchive.xyz/NWR/WXJ61", + "KZZ57": "https://wxradio.org/IL-Rockford-KZZ57", + "KXI41": "https://wxradio.org/IL-CrystalLake-KXI41", + "KHB34": "https://wxradio.org/FL-Miami-KHB34", + "WNG663": "https://wxradio.org/FL-Princeton-WNG663", + "KEC80": "https://wxradio.org/GA-Atlanta-KEC80" + } +} \ No newline at end of file diff --git a/data/outlook.json b/data/outlook.json new file mode 100644 index 0000000..a6450b3 --- /dev/null +++ b/data/outlook.json @@ -0,0 +1,22 @@ +{ + "convective": [ + "https://www.spc.noaa.gov/products/outlook/day1otlk.gif", + "https://www.spc.noaa.gov/products/outlook/day2otlk.gif", + "https://www.spc.noaa.gov/products/outlook/day3otlk.gif", + "https://www.spc.noaa.gov/products/exper/day4-8/day4prob.gif", + "https://www.spc.noaa.gov/products/exper/day4-8/day5prob.gif", + "https://www.spc.noaa.gov/products/exper/day4-8/day6prob.gif", + "https://www.spc.noaa.gov/products/exper/day4-8/day7prob.gif", + "https://www.spc.noaa.gov/products/exper/day4-8/day8prob.gif" + ], + "fire": [ + "https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day1otlk_fire.gif", + "https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day2otlk_fire.gif", + "https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day3otlk_fire.gif", + "https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day4otlk_fire.gif", + "https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day5otlk_fire.gif", + "https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day6otlk_fire.gif", + "https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day7otlk_fire.gif", + "https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day8otlk_fire.gif" + ] +} \ No newline at end of file diff --git a/data/satellites.json b/data/satellites.json new file mode 100644 index 0000000..c82967e --- /dev/null +++ b/data/satellites.json @@ -0,0 +1,187 @@ +{ + "GOES-16": { + "products": { + "Full Disk": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/FD/GEOCOLOR/1808x1808.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/FD/AirMass/1808x1808.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/FD/13/1808x1808.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/FD/10/1808x1808.jpg" + }, + "Floater 1": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/MESO/M1/GEOCOLOR/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/MESO/M1/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/MESO/M1/10/1000x1000.jpg" + }, + "Floater 2": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/MESO/M2/GEOCOLOR/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/MESO/M2/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/MESO/M2/10/1000x1000.jpg" + }, + "United States": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/CONUS/GEOCOLOR/2500x1500.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/CONUS/AirMass/2500x1500.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/CONUS/13/2500x1500.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/CONUS/10/2500x1500.jpg" + }, + "Canada": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/can/GEOCOLOR/2250x1125.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/can/AirMass/2250x1125.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/can/13/2250x1125.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/can/10/2250x1125.jpg" + }, + "Mexico": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/mex/GEOCOLOR/1000x1000.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/mex/AirMass/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/mex/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/mex/10/1000x1000.jpg" + }, + "US East Coast": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/eus/GEOCOLOR/1000x1000.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/eus/AirMass/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/eus/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/eus/10/1000x1000.jpg" + }, + "Gulf of Mexico": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/gm/GEOCOLOR/1000x1000.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/gm/AirMass/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/gm/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/gm/10/1000x1000.jpg" + }, + "Puerto Rico": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/pr/GEOCOLOR/1200x1200.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/pr/AirMass/1200x1200.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/pr/13/1200x1200.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/pr/10/1200x1200.jpg" + } + } + }, + "GOES-18": { + "products": { + "Full Disk": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/FD/GEOCOLOR/1808x1808.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/FD/AirMass/1808x1808.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/FD/13/1808x1808.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/FD/10/1808x1808.jpg" + }, + "Floater 1": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/MESO/M1/GEOCOLOR/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/MESO/M1/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/MESO/M1/10/1000x1000.jpg" + }, + "Floater 2": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/MESO/M2/GEOCOLOR/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/MESO/M2/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/MESO/M2/10/1000x1000.jpg" + }, + "US West Coast": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/wus/GEOCOLOR/1000x1000.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/wus/AirMass/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/wus/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/wus/10/1000x1000.jpg" + }, + "Hawaii": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/hi/GEOCOLOR/1200x1200.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/hi/AirMass/1200x1200.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/hi/13/1200x1200.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/hi/10/1200x1200.jpg" + }, + "Alaska": { + "Visible": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/ak/GEOCOLOR/1000x1000.jpg", + "Airmass": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/ak/AirMass/1000x1000.jpg", + "Infrared": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/ak/13/1000x1000.jpg", + "Water Vapor": "https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/ak/10/1000x1000.jpg" + } + } + }, + "Himawari": { + "products": { + "Full Disk": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/full_disk_ahi_true_color.jpg", + "Airmass": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/full_disk_ahi_rgb_airmass.jpg", + "Infrared": "https://www.ssec.wisc.edu/data/geo/images/himawari09/latest-himawari09_11_fd.gif", + "Water Vapor": "https://www.ssec.wisc.edu/data/geo/images/himawari09/latest-himawari09_10_fd.gif" + }, + "Floater 1": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest/himawari-8/floater_02_geocolor.pngv", + "Airmass": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest/himawari-8/floater_02_rgb_airmass.png" + }, + "American Samoa": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/american_samoa_ahi_natural_color.png", + "Airmass": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/american_samoa_ahi_rgb_airmass.png" + }, + "Australia": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest/himawari-8/australia_true_color.jpg", + "Airmass": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/australia_ahi_rgb_airmass.png" + }, + "New Zealand": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/new_zealand_ahi_natural_color.png", + "Airmass": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/new_zealand_ahi_rgb_airmass.png" + }, + "Guam": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/guam_ahi_natural_color.png", + "Airmass": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/guam_ahi_rgb_airmass.png" + }, + "Hawaii": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/hawaii_ahi_natural_color.png" + }, + "Japan": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/japan_ahi_natural_color.png", + "Airmass": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/japan_ahi_rgb_airmass.png" + }, + "Russia": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest/himawari-8/eastern_russia_true_color.jpg" + }, + "China": { + "Visible": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/eastern_china_ahi_natural_color.png", + "Airmass": "https://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/eastern_china_ahi_rgb_airmass.png" + } + } + }, + "EWS-G2": { + "products": { + "Full Disk": { + "Visible": "https://www.ssec.wisc.edu/data/geo/images/ews-g1/latest_ews-g1_01_fd.gif", + "Water Vapor": "https://www.ssec.wisc.edu/data/geo/images/ews-g1/latest_ews-g1_03_fd.gif" + } + } + }, + "FY-2G": { + "products": { + "Full Disk": { + "Visible": "https://www.ssec.wisc.edu/data/geo/images/fy2g/latest_fy2g_01_fd.gif", + "Infrared": "https://www.ssec.wisc.edu/data/geo/images/fy2g/latest_fy2g_02_fd.gif", + "Water Vapor": "https://www.ssec.wisc.edu/data/geo/images/fy2g/latest_fy2g_04_fd.gif" + } + } + }, + "GK-2A": { + "products": { + "Full Disk": { + "Infrared": "https://kiwiweather.com/gk-2a/FD_sanchez.jpg" + } + } + }, + "Meteosat 9": { + "products": { + "Full Disk": { + "Visible": "https://www.ssec.wisc.edu/data/geo/images/met-iodc/latest_met-iodc_01_fd.jpg", + "Infrared": "https://www.ssec.wisc.edu/data/geo/images/met-iodc/latest_met-iodc_04_fd.jpg", + "Water Vapor": "https://www.ssec.wisc.edu/data/geo/images/met-iodc/latest_met-iodc_06_fd.jpg" + } + } + }, + "Meteosat 10": { + "products": { + "Full Disk": { + "Visible": "https://www.ssec.wisc.edu/data/geo/images/met-prime/latest_met-prime_01_fd.gif", + "Infrared": "https://www.ssec.wisc.edu/data/geo/images/met-prime/latest_met-prime_04_fd.gif", + "Water Vapor": "https://www.ssec.wisc.edu/data/geo/images/met-prime/latest_met-prime_06_fd.gif" + }, + "Europe": { + "Visible": "https://www.ssec.wisc.edu/data/geo/images/met-prime/latest_met-prime_01_euro.gif", + "Infrared": "https://www.ssec.wisc.edu/data/geo/images/met-prime/latest_met-prime_04_euro.gif", + "Water Vapor": "https://www.ssec.wisc.edu/data/geo/images/met-prime/latest_met-prime_06_euro.gif" + } + } + } +} \ No newline at end of file diff --git a/data/wfos.json b/data/wfos.json new file mode 100644 index 0000000..1b5b26d --- /dev/null +++ b/data/wfos.json @@ -0,0 +1,594 @@ +{ + "iln": { + "room": "ilnchat", + "location": "Wilmington" + }, + "zhu": { + "room": "zhuchat", + "location": "Houston" + }, + "zme": { + "room": "zmechat", + "location": "Memphis" + }, + "ggw": { + "room": "ggwchat", + "location": "Glasgow" + }, + "sew": { + "room": "sewchat", + "location": "Seattle" + }, + "ohx": { + "room": "ohxchat", + "location": "Nashville" + }, + "meg": { + "room": "megchat", + "location": "Memphis" + }, + "mob": { + "room": "mobchat", + "location": "Mobile" + }, + "bro": { + "room": "brochat", + "location": "Brownsville" + }, + "ddc": { + "room": "ddcchat", + "location": "Dodge_City" + }, + "mfl": { + "room": "mflchat", + "location": "Miami" + }, + "dvn": { + "room": "dvnchat", + "location": "Quad_Cities_Ia" + }, + "gjt": { + "room": "gjtchat", + "location": "Grand_Junction" + }, + "ztl": { + "room": "ztlchat", + "location": "Atlanta" + }, + "lmk": { + "room": "lmkchat", + "location": "Louisville" + }, + "fwd": { + "room": "fwdchat", + "location": "Dallas-Fort_Worth" + }, + "boi": { + "room": "boichat", + "location": "Boise" + }, + "slc": { + "room": "slcchat", + "location": "Salt_Lake_City" + }, + "zob": { + "room": "zobchat", + "location": "Cleveland" + }, + "ama": { + "room": "amachat", + "location": "Amarillo" + }, + "pqr": { + "room": "pqrchat", + "location": "Portland" + }, + "zid": { + "room": "zidchat", + "location": "Indianapolis" + }, + "nhc": { + "room": "nhcchat", + "location": "National_Hurricane_Center" + }, + "sto": { + "room": "stochat", + "location": "Sacramento" + }, + "jkl": { + "room": "jklchat", + "location": "Jackson" + }, + "grr": { + "room": "grrchat", + "location": "Grand_Rapids" + }, + "hnx": { + "room": "hnxchat", + "location": "San_Joaquin_Valley-Hanford" + }, + "spc": { + "room": "spcchat", + "location": "Storm_Prediction_Center" + }, + "lch": { + "room": "lchchat", + "location": "Lake_Charles" + }, + "zbw": { + "room": "zbwchat", + "location": "Boston" + }, + "otx": { + "room": "otxchat", + "location": "Spokane" + }, + "vef": { + "room": "vefchat", + "location": "Las_Vegas" + }, + "pub": { + "room": "pubchat", + "location": "Pueblo" + }, + "psr": { + "room": "psrchat", + "location": "Phoenix" + }, + "sgx": { + "room": "sgxchat", + "location": "San_Diego" + }, + "pbz": { + "room": "pbzchat", + "location": "Pittsburgh" + }, + "eka": { + "room": "ekachat", + "location": "Eureka" + }, + "ilx": { + "room": "ilxchat", + "location": "Lincoln" + }, + "jsj": { + "room": "jsjchat", + "location": "San_Juan" + }, + "mlb": { + "room": "mlbchat", + "location": "Melbourne" + }, + "arx": { + "room": "arxchat", + "location": "La_Crosse" + }, + "ilm": { + "room": "ilmchat", + "location": "Wilmington" + }, + "okx": { + "room": "okxchat", + "location": "New_York" + }, + "bot": { + "room": "botstalk", + "location": "All_Bots_Talk" + }, + "lkn": { + "room": "lknchat", + "location": "Elko" + }, + "rah": { + "room": "rahchat", + "location": "Raleigh" + }, + "afc": { + "room": "afcchat", + "location": "Anchorage" + }, + "lot": { + "room": "lotchat", + "location": "Chicago" + }, + "box": { + "room": "boxchat", + "location": "Boston-Taunton" + }, + "zny": { + "room": "znychat", + "location": "New_York" + }, + "akq": { + "room": "akqchat", + "location": "Wakefield" + }, + "zkc": { + "room": "zkcchat", + "location": "Kansas_City" + }, + "bis": { + "room": "bischat", + "location": "Bismarck" + }, + "twc": { + "room": "twcchat", + "location": "Tucson" + }, + "abr": { + "room": "abrchat", + "location": "Aberdeen" + }, + "pih": { + "room": "pihchat", + "location": "Pocatello-Idaho_Falls" + }, + "zoa": { + "room": "zoachat", + "location": "Oakland" + }, + "mtr": { + "room": "mtrchat", + "location": "San_Francisco" + }, + "sju": { + "room": "sjuchat", + "location": "San_Juan" + }, + "gid": { + "room": "gidchat", + "location": "Hastings" + }, + "zmp": { + "room": "zmpchat", + "location": "Minneapolis" + }, + "phi": { + "room": "phichat", + "location": "Mount_Holly" + }, + "chs": { + "room": "chschat", + "location": "Charleston" + }, + "ajk": { + "room": "ajkchat", + "location": "Juneau" + }, + "bmx": { + "room": "bmxchat", + "location": "Birmingham" + }, + "lix": { + "room": "lixchat", + "location": "New_Orleans" + }, + "apx": { + "room": "apxchat", + "location": "Gaylord" + }, + "hun": { + "room": "hunchat", + "location": "Huntsville" + }, + "zma": { + "room": "zmachat", + "location": "Miami" + }, + "dtx": { + "room": "dtxchat", + "location": "Detroit" + }, + "gum": { + "room": "gumchat", + "location": "Guam" + }, + "crp": { + "room": "crpchat", + "location": "Corpus_Christi" + }, + "zjx": { + "room": "zjxchat", + "location": "Jacksonville" + }, + "shv": { + "room": "shvchat", + "location": "Shreveport" + }, + "tbw": { + "room": "tbwchat", + "location": "Tampa_Bay_Area-Ruskin" + }, + "cys": { + "room": "cyschat", + "location": "Cheyenne" + }, + "hfo": { + "room": "hfochat", + "location": "Honolulu" + }, + "dmx": { + "room": "dmxchat", + "location": "Des_Moines" + }, + "zse": { + "room": "zsechat", + "location": "Seattle" + }, + "rev": { + "room": "revchat", + "location": "Reno" + }, + "car": { + "room": "carchat", + "location": "Caribou" + }, + "mso": { + "room": "msochat", + "location": "Missoula" + }, + "key": { + "room": "keychat", + "location": "Key_West" + }, + "riw": { + "room": "riwchat", + "location": "Riverton" + }, + "mhx": { + "room": "mhxchat", + "location": "Newport-Morehead_City" + }, + "cae": { + "room": "caechat", + "location": "Columbia" + }, + "ind": { + "room": "indchat", + "location": "Indianapolis" + }, + "dlh": { + "room": "dlhchat", + "location": "Duluth" + }, + "unr": { + "room": "unrchat", + "location": "Rapid_City" + }, + "zab": { + "room": "zabchat", + "location": "Albuquerque" + }, + "zlc": { + "room": "zlcchat", + "location": "Salt_Lake_City" + }, + "ffc": { + "room": "ffcchat", + "location": "Peachtree_City" + }, + "epz": { + "room": "epzchat", + "location": "El_Paso_Tx-Santa_Teresa" + }, + "tae": { + "room": "taechat", + "location": "Tallahassee" + }, + "tfx": { + "room": "tfxchat", + "location": "Great_Falls" + }, + "abq": { + "room": "abqchat", + "location": "Albuquerque" + }, + "rlx": { + "room": "rlxchat", + "location": "Charleston" + }, + "oun": { + "room": "ounchat", + "location": "Norman" + }, + "cle": { + "room": "clechat", + "location": "Cleveland" + }, + "lox": { + "room": "loxchat", + "location": "Los_Angeles-Oxnard" + }, + "fsd": { + "room": "fsdchat", + "location": "Sioux_Falls" + }, + "bgm": { + "room": "bgmchat", + "location": "Binghamton" + }, + "ewx": { + "room": "ewxchat", + "location": "Austin-San_Antonio" + }, + "zdv": { + "room": "zdvchat", + "location": "Denver" + }, + "eax": { + "room": "eaxchat", + "location": "Kansas_City-Pleasant_Hill" + }, + "iwx": { + "room": "iwxchat", + "location": "Northern_Indiana" + }, + "lub": { + "room": "lubchat", + "location": "Lubbock" + }, + "buf": { + "room": "bufchat", + "location": "Buffalo" + }, + "pdt": { + "room": "pdtchat", + "location": "Pendleton" + }, + "mkx": { + "room": "mkxchat", + "location": "Milwaukee-Sullivan" + }, + "grb": { + "room": "grbchat", + "location": "Green_Bay" + }, + "top": { + "room": "topchat", + "location": "Topeka" + }, + "rnk": { + "room": "rnkchat", + "location": "Blacksburg" + }, + "lzk": { + "room": "lzkchat", + "location": "Little_Rock" + }, + "ctp": { + "room": "ctpchat", + "location": "State_College" + }, + "gld": { + "room": "gldchat", + "location": "Goodland" + }, + "byz": { + "room": "byzchat", + "location": "Billings" + }, + "mpx": { + "room": "mpxchat", + "location": "Twin_Cities-Chanhassen" + }, + "zdc": { + "room": "zdcchat", + "location": "Washington_DC" + }, + "lsx": { + "room": "lsxchat", + "location": "St_Louis" + }, + "pah": { + "room": "pahchat", + "location": "Paducah" + }, + "bou": { + "room": "bouchat", + "location": "Denver" + }, + "tsa": { + "room": "tsachat", + "location": "Tulsa" + }, + "zfw": { + "room": "zfwchat", + "location": "Fort_Worth" + }, + "zau": { + "room": "zauchat", + "location": "Chicago" + }, + "mqt": { + "room": "mqtchat", + "location": "Marquette" + }, + "maf": { + "room": "mafchat", + "location": "Midland-Odessa" + }, + "mrx": { + "room": "mrxchat", + "location": "Morristown" + }, + "fgz": { + "room": "fgzchat", + "location": "Flagstaff" + }, + "oax": { + "room": "oaxchat", + "location": "Omaha-Valley" + }, + "btv": { + "room": "btvchat", + "location": "Burlington" + }, + "ict": { + "room": "ictchat", + "location": "Wichita" + }, + "mfr": { + "room": "mfrchat", + "location": "Medford" + }, + "hgx": { + "room": "hgxchat", + "location": "Houston-Galveston" + }, + "afg": { + "room": "afgchat", + "location": "Fairbanks" + }, + "sgf": { + "room": "sgfchat", + "location": "Springfield" + }, + "haw": { + "room": "hawaii", + "location": "Hawaii" + }, + "zla": { + "room": "zlachat", + "location": "Los_Angeles" + }, + "aly": { + "room": "alychat", + "location": "Albany" + }, + "sjt": { + "room": "sjtchat", + "location": "San_Angelo" + }, + "jan": { + "room": "janchat", + "location": "Jackson" + }, + "gsp": { + "room": "gspchat", + "location": "Greenville-Spartanburg" + }, + "lwx": { + "room": "lwxchat", + "location": "Baltimore_Md-_Washington_Dc" + }, + "gyx": { + "room": "gyxchat", + "location": "Gray" + }, + "wpc": { + "room": "wpcchat", + "location": "Weather_Prediction_Center" + }, + "lbf": { + "room": "lbfchat", + "location": "North_Platte" + }, + "jax": { + "room": "jaxchat", + "location": "Jacksonville" + }, + "fgf": { + "room": "fgfchat", + "location": "Grand_Forks" + } +} \ No newline at end of file diff --git a/debug.js b/debug.js new file mode 100644 index 0000000..7c7340b --- /dev/null +++ b/debug.js @@ -0,0 +1,17 @@ +const Discord = require('discord.js'); +const client = new Discord.Client({intents: ["Guilds"]}) +const config = require('./config.json'); + +categories = ["1237807432311373895", "1237807432709963807", "1237807433678590023", "1237807434425434164"] + +client.once('ready', () => { + console.log('Ready!'); + client.guilds.cache.get("1237792259248750673").channels.cache.forEach(channel => { + if (!channel.parent) return; + if (categories.includes(channel.parent.id)) { + channel.delete(); + } + }) +}) + +client.login(config.discord.token); \ No newline at end of file diff --git a/funcs.js b/funcs.js new file mode 100644 index 0000000..5faaf82 --- /dev/null +++ b/funcs.js @@ -0,0 +1,137 @@ +// Use OSM API to get coordinates https://nominatim.openstreetmap.org/search?q=search+query&format=json&limit=1 +const getCoordinates = async (location) => { + return new Promise((resolve, reject) => { + // Make location url friendly + location = encodeURIComponent(location); + const url = `https://nominatim.openstreetmap.org/search?q=${location}&format=json&limit=1`; + // use custom useragent (discord-iem-bot, chris@chrischro.me) + const options = { + headers: { + 'User-Agent': 'Discord-IEM-Bot/1.0 (chris@chrischro.me)', + }, + }; + // Make request + fetch(url, options) + .then(response => response.json()) + .then(data => { + if (data.length > 0) { + resolve({ + lat: data[0].lat, + lon: data[0].lon, + }); + } else { + reject('Location not found'); + } + }) + .catch(err => { + reject(err); + }); + }) +}; + +const getForecast = async (lat, lon) => { + return new Promise((resolve, reject) => { + const url = `https://api.weather.gov/points/${lat},${lon}`; + // use same custom ua + const options = { + headers: { + 'User-Agent': 'Discord-IEM-Bot/1.0 (chris@chrischro.me)', + }, + }; + // Make request + fetch(url, options) + .then(response => response.json()) + .then(data => { + if (data.properties?.forecast) { + fetch(data.properties.forecast) + .then(response => response.json()) + .then(data2 => { + data2.properties.relativeLocation = data.properties.relativeLocation; + resolve(data2); + }) + .catch(err => { + reject(err); + }); + + } else { + reject('Forecast not found'); + } + }) + .catch(err => { + reject(err); + }); + }) +}; + +const getWeatherBySearch = async (search) => { + return new Promise((resolve, reject) => { + getCoordinates(search) + .then(coords => { + getForecast(coords.lat, coords.lon) + .then(data => { + resolve(data); + }) + .catch(err => { + reject(err); + }); + }) + .catch(err => { + reject(err); + }); + }) +}; + +const generateDiscordEmbeds = (forecastData, numOfDays) => { + // Take the first 7 periods and make them into embeds + const embeds = []; + if (!numOfDays) numOfDays = 1; + for (let i = 0; i < numOfDays; i++) { + const period = forecastData.properties.periods[i]; + if (period.icon?.startsWith("/")) { + period.icon = `https://api.weather.gov${period.icon}` + } + const embed = { + title: `${period.name} in ${forecastData.properties.relativeLocation.properties.city} ${forecastData.properties.relativeLocation.properties.state}`, + description: `Valid - \n${period.detailedForecast}`, + timestamp: new Date(period.startTime), + thumbnail: { + url: period.icon, + }, + fields: [ + { + name: 'Temperature', + value: `${period.temperature}°F`, + inline: true + }, + { + name: 'Wind', + value: `${period.windDirection}@${period.windSpeed}`, + inline: true + }, + { + name: 'Precipitation', + value: period.probabilityOfPrecipitation?.value ? period.probabilityOfPrecipitation?.value + '%' : '0%', + inline: true + }, + { + name: 'Humidity', + value: period.relativeHumidity?.value ? period.relativeHumidity.value + '%' : "0%", + } + + ], + footer: { + text: `Data provided by the National Weather Service · Elevation ${forecastData.properties.elevation.value}m` + } + }; + embeds.push(embed); + } + return embeds; +} + + +module.exports = { + getCoordinates, + getForecast, + getWeatherBySearch, + generateDiscordEmbeds +}; \ No newline at end of file diff --git a/genblacklist.js b/genblacklist.js new file mode 100644 index 0000000..5b5ccd4 --- /dev/null +++ b/genblacklist.js @@ -0,0 +1,116 @@ +const goodrooms = require("./goodrooms.json"); +// goodrooms is an array of objects {room: string, name: string} +const { client, xml } = require("@xmpp/client"); +const colors = require("colors"); + +const generateRandomString = function (options, length) { + let result = ''; + const characters = { + upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + lower: 'abcdefghijklmnopqrstuvwxyz', + number: '0123456789', + special: '!@#$%^&*()_+' + }; + let chars = ''; + for (const key in options) { + if (options[key]) { + chars += characters[key]; + } + } + for (let i = 0; i < length; i++) { + result += chars.charAt(Math.floor(Math.random() * chars.length)); + } + return result; +} + +// Func to generate UUID +const generateUUID = function () { + return generateRandomString({ lower: true, upper: true, number: true }, 8) + "-" + generateRandomString({ lower: true, upper: true, number: true }, 4) + "-" + generateRandomString({ lower: true, upper: true, number: true }, 4) + "-" + generateRandomString({ lower: true, upper: true, number: true }, 4) + "-" + generateRandomString({ lower: true, upper: true, number: true }, 12); +} + +const xmpp = client({ + service: "xmpp://conference.weather.im", + domain: "weather.im", + resource: `discord-weather-bot-${generateRandomString({ upper: true, lower: true, number: true }, 5)}`, // Weird fix to "Username already in use" +}); + +var blacklist = []; +var rooms = {}; +xmpp.on("stanza", (stanza) => { + // Debug stuff + + + // Handle Room List + if (stanza.is("iq") && stanza.attrs.type === "result" && stanza.getChild("query")) { + query = stanza.getChild("query"); + if (query.attrs.xmlns === "http://jabber.org/protocol/disco#items") { + query.getChildren("item").forEach((item) => { + roomname = item.attrs.jid.split("@")[0]; + console.log(`${colors.cyan("[INFO]")} Found room: ${item.attrs.jid}`); + // if room not in goodrooms list add to blacklist array + if (!goodrooms.find(room => room.room === roomname)) { + blacklist.push(item.attrs.jid); + return console.log(`${colors.red("[INFO]")} Added room to blacklist: ${roomname}`); + } + + // Get proper text name from goodrooms + properName = goodrooms.find(room => room.room === roomname).name; + console.log(properName) + + // room is in goodrooms, get first 3 of room name, add it to rooms object 3char: {room: roomname, name: name} + rooms[roomname.substring(0, 3)] = { room: roomname, location: properName }; + }); + clearTimeout(start); + start = setTimeout(() => { + console.log(`${colors.green("[INFO]")} Blacklist: ${JSON.stringify(blacklist)}`); + console.log(`${colors.green("[INFO]")} Rooms: ${JSON.stringify(rooms)}`); + + xmpp.stop(); + }, 5000); + } + } + +}); + +xmpp.on("online", async (address) => { + + errCount = 0; + // Start listening on all channels, (dont ban me funny man) + // for (const channel in iem) { + // console.log(`Joining ${channel.name}`) + // await xmpp.send(xml("presence", { to: `${channel.jud}/${channel.name}` })); + // } + /* sub format + + + + visitor + + + + */ + + // Request room list + // Automatically find room list + xmpp.send(xml("iq", { type: "get", to: "conference.weather.im", id: "rooms" }, xml("query", { xmlns: "http://jabber.org/protocol/disco#items" }))); + // Join all channels (Old method) + // iem.forEach((channel => { + // console.log(`${colors.cyan("[INFO]")} Joining ${channel.jid}/${channel.name}/${curUUID}`) + // //xmpp.send(xml("presence", { to: `${channel.jid}/${channel.jid.split("@")[0]}` })); + // xmpp.send(xml("presence", { to: `${channel.jid}/${channel.name}/${curUUID}` }, xml("item", { role: "visitor" }))); + // })) + + console.log(`${colors.cyan("[INFO]")} Connected to XMPP server as ${address.toString()}`); + + setTimeout(() => { + startup = false; + console.log(`${colors.cyan("[INFO]")} Startup complete, listening for messages...`); + }, 1000) +}); + +var start = setTimeout(() => { + console.log(`${colors.green("[INFO]")} Blacklist: ${blacklist}`); + console.log(`${colors.green("[INFO]")} Rooms: ${rooms}`); + xmpp.stop(); +}, 5000); +xmpp.start().catch(console.error); diff --git a/goodrooms.json b/goodrooms.json new file mode 100644 index 0000000..58d8f2a --- /dev/null +++ b/goodrooms.json @@ -0,0 +1,654 @@ +[ + { + "room": "botstalk", + "name": "All_Bots_Talk" + }, + { + "room": "nhcchat", + "name": "National_Hurricane_Center" + }, + { + "room": "spcchat", + "name": "Storm_Prediction_Center" + }, + { + "room": "wpcchat", + "name": "Weather_Prediction_Center" + }, + { + "room": "abqchat", + "name": "Albuquerque" + }, + { + "room": "abrchat", + "name": "Aberdeen" + }, + { + "room": "afcchat", + "name": "Anchorage" + }, + { + "room": "afgchat", + "name": "Fairbanks" + }, + { + "room": "ajkchat", + "name": "Juneau" + }, + { + "room": "akqchat", + "name": "Wakefield" + }, + { + "room": "alychat", + "name": "Albany" + }, + { + "room": "amachat", + "name": "Amarillo" + }, + { + "room": "apxchat", + "name": "Gaylord" + }, + { + "room": "arxchat", + "name": "La_Crosse" + }, + { + "room": "bgmchat", + "name": "Binghamton" + }, + { + "room": "bischat", + "name": "Bismarck" + }, + { + "room": "bmxchat", + "name": "Birmingham" + }, + { + "room": "boichat", + "name": "Boise" + }, + { + "room": "bouchat", + "name": "Denver" + }, + { + "room": "boxchat", + "name": "Boston-Taunton" + }, + { + "room": "brochat", + "name": "Brownsville" + }, + { + "room": "btvchat", + "name": "Burlington" + }, + { + "room": "bufchat", + "name": "Buffalo" + }, + { + "room": "byzchat", + "name": "Billings" + }, + { + "room": "caechat", + "name": "Columbia" + }, + { + "room": "carchat", + "name": "Caribou" + }, + { + "room": "chschat", + "name": "Charleston" + }, + { + "room": "clechat", + "name": "Cleveland" + }, + { + "room": "crpchat", + "name": "Corpus_Christi" + }, + { + "room": "ctpchat", + "name": "State_College" + }, + { + "room": "cyschat", + "name": "Cheyenne" + }, + { + "room": "ddcchat", + "name": "Dodge_City" + }, + { + "room": "dlhchat", + "name": "Duluth" + }, + { + "room": "dmxchat", + "name": "Des_Moines" + }, + { + "room": "dtxchat", + "name": "Detroit" + }, + { + "room": "dvnchat", + "name": "Quad_Cities_Ia" + }, + { + "room": "eaxchat", + "name": "Kansas_City-Pleasant_Hill" + }, + { + "room": "ekachat", + "name": "Eureka" + }, + { + "room": "epzchat", + "name": "El_Paso_Tx-Santa_Teresa" + }, + { + "room": "ewxchat", + "name": "Austin-San_Antonio" + }, + { + "room": "ffcchat", + "name": "Peachtree_City" + }, + { + "room": "fgfchat", + "name": "Grand_Forks" + }, + { + "room": "fgzchat", + "name": "Flagstaff" + }, + { + "room": "fsdchat", + "name": "Sioux_Falls" + }, + { + "room": "fwdchat", + "name": "Dallas-Fort_Worth" + }, + { + "room": "ggwchat", + "name": "Glasgow" + }, + { + "room": "gidchat", + "name": "Hastings" + }, + { + "room": "gjtchat", + "name": "Grand_Junction" + }, + { + "room": "gldchat", + "name": "Goodland" + }, + { + "room": "grbchat", + "name": "Green_Bay" + }, + { + "room": "grrchat", + "name": "Grand_Rapids" + }, + { + "room": "gspchat", + "name": "Greenville-Spartanburg" + }, + { + "room": "gumchat", + "name": "Guam" + }, + { + "room": "gyxchat", + "name": "Gray" + }, + { + "room": "hawaii", + "name": "Hawaii" + }, + { + "room": "hfochat", + "name": "Honolulu" + }, + { + "room": "hgxchat", + "name": "Houston-Galveston" + }, + { + "room": "hnxchat", + "name": "San_Joaquin_Valley-Hanford" + }, + { + "room": "hunchat", + "name": "Huntsville" + }, + { + "room": "ictchat", + "name": "Wichita" + }, + { + "room": "ilmchat", + "name": "Wilmington" + }, + { + "room": "ilnchat", + "name": "Wilmington" + }, + { + "room": "ilxchat", + "name": "Lincoln" + }, + { + "room": "indchat", + "name": "Indianapolis" + }, + { + "room": "iwxchat", + "name": "Northern_Indiana" + }, + { + "room": "janchat", + "name": "Jackson" + }, + { + "room": "jaxchat", + "name": "Jacksonville" + }, + { + "room": "jklchat", + "name": "Jackson" + }, + { + "room": "jsjchat", + "name": "San_Juan" + }, + { + "room": "keychat", + "name": "Key_West" + }, + { + "room": "lbfchat", + "name": "North_Platte" + }, + { + "room": "lchchat", + "name": "Lake_Charles" + }, + { + "room": "lixchat", + "name": "New_Orleans" + }, + { + "room": "lknchat", + "name": "Elko" + }, + { + "room": "lmkchat", + "name": "Louisville" + }, + { + "room": "lotchat", + "name": "Chicago" + }, + { + "room": "loxchat", + "name": "Los_Angeles-Oxnard" + }, + { + "room": "lsxchat", + "name": "St_Louis" + }, + { + "room": "lubchat", + "name": "Lubbock" + }, + { + "room": "lwxchat", + "name": "Baltimore_Md-_Washington_Dc" + }, + { + "room": "lzkchat", + "name": "Little_Rock" + }, + { + "room": "mafchat", + "name": "Midland-Odessa" + }, + { + "room": "megchat", + "name": "Memphis" + }, + { + "room": "mflchat", + "name": "Miami" + }, + { + "room": "mfrchat", + "name": "Medford" + }, + { + "room": "mhxchat", + "name": "Newport-Morehead_City" + }, + { + "room": "mkxchat", + "name": "Milwaukee-Sullivan" + }, + { + "room": "mlbchat", + "name": "Melbourne" + }, + { + "room": "mobchat", + "name": "Mobile" + }, + { + "room": "mpxchat", + "name": "Twin_Cities-Chanhassen" + }, + { + "room": "mqtchat", + "name": "Marquette" + }, + { + "room": "mrxchat", + "name": "Morristown" + }, + { + "room": "msochat", + "name": "Missoula" + }, + { + "room": "mtrchat", + "name": "San_Francisco" + }, + { + "room": "oaxchat", + "name": "Omaha-Valley" + }, + { + "room": "ohxchat", + "name": "Nashville" + }, + { + "room": "okxchat", + "name": "New_York" + }, + { + "room": "otxchat", + "name": "Spokane" + }, + { + "room": "ounchat", + "name": "Norman" + }, + { + "room": "pahchat", + "name": "Paducah" + }, + { + "room": "pbzchat", + "name": "Pittsburgh" + }, + { + "room": "pdtchat", + "name": "Pendleton" + }, + { + "room": "phichat", + "name": "Mount_Holly" + }, + { + "room": "pihchat", + "name": "Pocatello-Idaho_Falls" + }, + { + "room": "pqrchat", + "name": "Portland" + }, + { + "room": "psrchat", + "name": "Phoenix" + }, + { + "room": "pubchat", + "name": "Pueblo" + }, + { + "room": "rahchat", + "name": "Raleigh" + }, + { + "room": "revchat", + "name": "Reno" + }, + { + "room": "riwchat", + "name": "Riverton" + }, + { + "room": "rlxchat", + "name": "Charleston" + }, + { + "room": "rnkchat", + "name": "Blacksburg" + }, + { + "room": "sewchat", + "name": "Seattle" + }, + { + "room": "sgfchat", + "name": "Springfield" + }, + { + "room": "sgxchat", + "name": "San_Diego" + }, + { + "room": "shvchat", + "name": "Shreveport" + }, + { + "room": "sjtchat", + "name": "San_Angelo" + }, + { + "room": "sjuchat", + "name": "San_Juan" + }, + { + "room": "slcchat", + "name": "Salt_Lake_City" + }, + { + "room": "stochat", + "name": "Sacramento" + }, + { + "room": "taechat", + "name": "Tallahassee" + }, + { + "room": "tbwchat", + "name": "Tampa_Bay_Area-Ruskin" + }, + { + "room": "tfxchat", + "name": "Great_Falls" + }, + { + "room": "topchat", + "name": "Topeka" + }, + { + "room": "tsachat", + "name": "Tulsa" + }, + { + "room": "twcchat", + "name": "Tucson" + }, + { + "room": "unrchat", + "name": "Rapid_City" + }, + { + "room": "vefchat", + "name": "Las_Vegas" + }, + { + "room": "alrchat", + "name": "Atlanta_RFC" + }, + { + "room": "fwrchat", + "name": "West_Gulf_RFC" + }, + { + "room": "krfchat", + "name": "Missouri_River_Basin_RFC" + }, + { + "room": "msrchat", + "name": "North_Central_RFC" + }, + { + "room": "ornchat", + "name": "Lower_Mississippi_RFC" + }, + { + "room": "pacrchat", + "name": "Alaska_-_Pacific_RFC" + }, + { + "room": "ptrchat", + "name": "Northwest_RFC" + }, + { + "room": "rhachat", + "name": "Mid_Atlantic_RFC" + }, + { + "room": "rsachat", + "name": "California_-_Nevada_RFC" + }, + { + "room": "strchat", + "name": "Colorado_RFC" + }, + { + "room": "tarchat", + "name": "Northeast_RFC" + }, + { + "room": "tirchat", + "name": "Ohio_RFC" + }, + { + "room": "tuachat", + "name": "Arkansas_Red_River_RFC" + }, + { + "room": "pancchat", + "name": "Anchorage" + }, + { + "room": "zabchat", + "name": "Albuquerque" + }, + { + "room": "zauchat", + "name": "Chicago" + }, + { + "room": "zbwchat", + "name": "Boston" + }, + { + "room": "zdcchat", + "name": "Washington_DC" + }, + { + "room": "zdvchat", + "name": "Denver" + }, + { + "room": "zfwchat", + "name": "Fort_Worth" + }, + { + "room": "zhnchat", + "name": "Honolulu_CWSU" + }, + { + "room": "zhuchat", + "name": "Houston" + }, + { + "room": "zidchat", + "name": "Indianapolis" + }, + { + "room": "zjxchat", + "name": "Jacksonville" + }, + { + "room": "zkcchat", + "name": "Kansas_City" + }, + { + "room": "zlachat", + "name": "Los_Angeles" + }, + { + "room": "zlcchat", + "name": "Salt_Lake_City" + }, + { + "room": "zmachat", + "name": "Miami" + }, + { + "room": "zmechat", + "name": "Memphis" + }, + { + "room": "zmpchat", + "name": "Minneapolis" + }, + { + "room": "znychat", + "name": "New_York" + }, + { + "room": "zoachat", + "name": "Oakland" + }, + { + "room": "zobchat", + "name": "Cleveland" + }, + { + "room": "zsechat", + "name": "Seattle" + }, + { + "room": "ztlchat", + "name": "Atlanta" + } +] \ No newline at end of file diff --git a/images/error.gif b/images/error.gif new file mode 100644 index 0000000..bb01af4 Binary files /dev/null and b/images/error.gif differ diff --git a/images/overlays/artcc.png b/images/overlays/artcc.png new file mode 100644 index 0000000..5f2c340 Binary files /dev/null and b/images/overlays/artcc.png differ diff --git a/images/overlays/city.png b/images/overlays/city.png new file mode 100644 index 0000000..d59a183 Binary files /dev/null and b/images/overlays/city.png differ diff --git a/images/overlays/county.png b/images/overlays/county.png new file mode 100644 index 0000000..87282bd Binary files /dev/null and b/images/overlays/county.png differ diff --git a/images/overlays/cwa.png b/images/overlays/cwa.png new file mode 100644 index 0000000..6d16504 Binary files /dev/null and b/images/overlays/cwa.png differ diff --git a/images/overlays/fema.png b/images/overlays/fema.png new file mode 100644 index 0000000..71a018d Binary files /dev/null and b/images/overlays/fema.png differ diff --git a/images/overlays/interstate.png b/images/overlays/interstate.png new file mode 100644 index 0000000..b9db88e Binary files /dev/null and b/images/overlays/interstate.png differ diff --git a/images/overlays/population.png b/images/overlays/population.png new file mode 100644 index 0000000..875db88 Binary files /dev/null and b/images/overlays/population.png differ diff --git a/images/overlays/rfc.png b/images/overlays/rfc.png new file mode 100644 index 0000000..e434339 Binary files /dev/null and b/images/overlays/rfc.png differ diff --git a/images/overlays/tribal.png b/images/overlays/tribal.png new file mode 100644 index 0000000..898ead9 Binary files /dev/null and b/images/overlays/tribal.png differ diff --git a/index.js b/index.js new file mode 100644 index 0000000..fdf27db --- /dev/null +++ b/index.js @@ -0,0 +1,1585 @@ +// Requires +const fs = require("fs"); +const config = require("./config.json"); +const funcs = require("./funcs.js"); +const wfos = require("./data/wfos.json"); +const outlookURLs = require("./data/outlook.json"); +const satellites = require("./data/satellites.json"); +const nwrstreams = { callsigns: {} }; +const Jimp = require("jimp"); +const fetch = require("node-fetch"); +const html = require("html-entities") +const Discord = require("discord.js"); +const dVC = require("@discordjs/voice"); +const colors = require("colors"); +const sqlite3 = require("sqlite3").verbose(); +const WebSocket = require('ws'); + +satMessages = {}; + +// Setup Discord +const discord = new Discord.Client({ + + intents: [ + "Guilds", + "GuildVoiceStates", + "DirectMessages" + ] +}); +const { + REST, + Routes +} = require('discord.js'); +const rest = new REST({ + version: '10' +}).setToken(config.discord.token); + +// Setup SQlite DB +const db = new sqlite3.Database("channels.db", (err) => { + if (err) { + console.log(`${colors.red("[ERROR]")} Error connecting to database: ${err.message}`); + } + console.log(`${colors.cyan("[INFO]")} Connected to the database`); + // Create tables if they dont exist + db.run(`CREATE TABLE IF NOT EXISTS channels (channelid TEXT, iemchannel TEXT, custommessage TEXT, minPriority INTEGER, "filter" TEXT, filterEvt TEXT);`); + db.run(`CREATE TABLE IF NOT EXISTS userAlerts (userid TEXT, iemchannel TEXT, filter TEXT, filterEvt TEXT, minPriority INT, custommessage TEXT);`); + db.run(`ALTER TABLE channels RENAME COLUMN filterevt TO filterEvt;`) +}); + + +// Random funcs +function toTitleCase(str) { + return str.replace( + /\w\S*/g, + function (txt) { + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + } + ); +} + +const parseProductID = function (product_id) { + const [timestamp, station, wmo, pil] = product_id.split("-"); + return { + timestamp: convertDate(timestamp), + originalTimestamp: timestamp, + station, + wmo, + pil + }; +} + +// Convert date format 202405080131 (YYYYMMddHHmm) to iso format, hours and mins is UTC +const convertDate = function (date) { + const year = date.substring(0, 4); + const month = date.substring(4, 6); + const day = date.substring(6, 8); + const hours = date.substring(8, 10); + const mins = date.substring(10, 12); + // Because they don't have seconds, assume current seconds + const secs = new Date().getSeconds(); + return new Date(Date.UTC(year, month - 1, day, hours, mins, secs)); +} + +// Get number of unique channels in the database +const getUniqueChannels = function () { + return new Promise((resolve, reject) => { + db.all(`SELECT DISTINCT channelid FROM channels`, (err, rows) => { + if (err) { + console.error(err.message); + } + // Go through channels. and get number of unique guilds + const guilds = []; + rows.forEach((row) => { + const channel = discord.channels.cache.get(row.channelid); + if (!channel) return; + if (!guilds.includes(channel.guild.id)) { + guilds.push(channel.guild.id); + } + }); + + resolve({ channels: rows.length, guilds: guilds.length }); + }); + }); +} + +// Get first url in a string, return object {string, url} remove the url from the string +const getFirstURL = function (string) { + url = string.match(/(https?:\/\/[^\s]+)/g); + if (!url) return { string, url: null }; + const newString = string.replace(url[0], ""); + return { string: newString, url: url[0] }; +} + +// Function to get the room name from the WFO code +const getWFOroom = function (code) { + code = code.toLowerCase(); + if (wfos[code]) { + return wfos[code].room; + } else { + return code; + } +} + +// Function to get WFO data +const getWFO = function (code) { + code = code.toLowerCase(); + if (wfos[code]) { + return wfos[code]; + } else { + return null; + } +} + +// Get WFO data from room name + +function getWFOByRoom(room) { + room = room.toLowerCase(); + for (const key in wfos) { + if (wfos.hasOwnProperty(key) && wfos[key].room === room) { + return wfos[key]; + } + } + return { + location: room, + room: room + }; +} + +// Voice funcs +function JoinChannel(channel, track, volume, message) { + connection = dVC.joinVoiceChannel({ + channelId: channel.id, + guildId: channel.guild.id, + adapterCreator: channel.guild.voiceAdapterCreator, + selfDeaf: true + }); + + + resource = dVC.createAudioResource(track, { inlineVolume: true, silencePaddingFrames: 5 }); + player = dVC.createAudioPlayer(); + connection.player = player; // So we can access it later to pause/play/stop etc + resource.volume.setVolume(volume); + connection.subscribe(player) + player.play(resource); + connection.on(dVC.VoiceConnectionStatus.Ready, () => { player.play(resource); }) + connection.on(dVC.VoiceConnectionStatus.Disconnected, async (oldState, newState) => { + try { + await Promise.race([ + dVC.entersState(connection, VoiceConnectionStatus.Signalling, 5_000), + dVC.entersState(connection, VoiceConnectionStatus.Connecting, 5_000), + ]); + } catch (error) { + message.channel.send(`Failed to reconnect to the voice channel. Stopping for now.`); + connection.destroy(); + return false; + } + }); + player.on('error', error => { + console.error(`Error: ${error.message} with resource ${error.resource.metadata.title}`); + message.channel.send(`Error while streaming. Stopping for now.`); + player.stop(); + }); + player.on(dVC.AudioPlayerStatus.Playing, () => { + message.channel.send(`Playing stream in <#${channel.id}>`); + connection.paused = false; + }); + player.on('idle', () => { + message.channel.send(`Stream idle.`); + }) + return true; +} + +function LeaveVoiceChannel(channel) { + // Get resource, player, etc, and destroy them + const connection = dVC.getVoiceConnection(channel.guild.id); + if (connection) { + connection.destroy(); + return true + } + return false +} + +function toggleVoicePause(channel) { + const connection = dVC.getVoiceConnection(channel.guild.id); + if (connection) { + if (connection.paused) { + connection.player.unpause(); + connection.paused = false; + return true; + } + else { + connection.player.pause(); + connection.paused = true; + return true + } + } + else { + return false; + } +}; + +function setVolume(channel, volume) { + const connection = dVC.getVoiceConnection(channel.guild.id); + if (connection) { + connection.player.state.resource.volume.setVolume(volume); + return true; + } +} + +// func to Generate random string, ({upper, lower, number, special}, length) + +const generateRandomString = function (options, length) { + let result = ''; + const characters = { + upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + lower: 'abcdefghijklmnopqrstuvwxyz', + number: '0123456789', + special: '!@#$%^&*()_+' + }; + let chars = ''; + for (const key in options) { + if (options[key]) { + chars += characters[key]; + } + } + for (let i = 0; i < length; i++) { + result += chars.charAt(Math.floor(Math.random() * chars.length)); + } + return result; +} + +// Func to generate UUID +const generateUUID = function () { + return generateRandomString({ lower: true, upper: true, number: true }, 8) + "-" + generateRandomString({ lower: true, upper: true, number: true }, 4) + "-" + generateRandomString({ lower: true, upper: true, number: true }, 4) + "-" + generateRandomString({ lower: true, upper: true, number: true }, 4) + "-" + generateRandomString({ lower: true, upper: true, number: true }, 12); +} + +// Variable setup +var iem = [] +var startup = true; +var startTimestap = new Date(); +var messages = 0; + + + +// nwrstreams setup +// get icecast json data +const fetchNWRstreams = () => { + fetch("https://icestats.weatherradio.org/").then((res) => { + res.json().then((json) => { + json.icestats.source.forEach((source) => { + nwrstreams.callsigns[source.server_name] = source.listenurl; + }); + }); + console.log(`${colors.cyan("[INFO]")} Fetched NWR streams`); + }).catch((err) => { + console.error(err); + }); +} + +fetchNWRstreams(); +setInterval(fetchNWRstreams, 5 * 60 * 1000); // Every 5 minutes + + +/* We are replacing the xmpp client with a websocket. +The new data will look something like this +{ + type: 'iem-message', + data: { + channel: { room: 'botstalk', location: 'All_Bots_Talk' }, + event: { priority: 1, text: 'Marine Weather Message', code: 'MWW' }, + body: 'LCH updates Small Craft Advisory (expires Coastal waters from Cameron LA to High Island TX out 20 NM, Coastal waters from Intracoastal City to Cameron LA out 20 NM, Coastal waters from Lower Atchafalaya River to Intracoastal City LA out 20 NM [GM], continues Waters from Cameron LA to High Island TX from 20 to 60 NM, Waters from Intracoastal City to +Cameron LA from 20 to 60 NM, Waters from Lower Atchafalaya River to Intracoastal City LA from 20 to 60 NM [GM]) . ', + timestamp: '2025-04-20T15:12:22.000Z', + wmo: 'WHUS74', + pil: 'MWWLCH', + station: 'KLCH', + raw: '202504201512-KLCH-WHUS74-MWWLCH', + rawBody: 'LCH updates Small Craft Advisory (expires Coastal waters from Cameron LA to High Island TX out 20 NM, Coastal waters from Intracoastal City to Cameron LA out 20 NM, Coastal waters from Lower Atchafalaya River to Intracoastal City LA out 20 NM [GM], continues Waters from Cameron LA to High Island TX from 20 to 60 NM, Waters from Intracoastal City +to Cameron LA from 20 to 60 NM, Waters from Lower Atchafalaya River to Intracoastal City LA from 20 to 60 NM [GM]) . https://mesonet.agron.iastate.edu/vtec/f/2025-O-EXP-KLCH-SC-Y-0028_2025-04-20T15:12Z', + image: 'https://mesonet.agron.iastate.edu/plotting/auto/plot/208/network:WFO::wfo:LCH::year:2025::phenomenav:SC::significancev:Y::etn:28::valid:2025-04-20%201512::_r:86.png', + productText: '570 \n' + + 'WHUS74 KLCH 201512\n' + + 'MWWLCH\n' + + '\n' + + 'URGENT - MARINE WEATHER MESSAGE\n' + + 'National Weather Service Lake Charles LA\n' + + '1012 AM CDT Sun Apr 20 2025\n' + + '\n' + + 'GMZ450-452-455-201615-\n' + + '/O.EXP.KLCH.SC.Y.0028.000000T0000Z-250420T1500Z/\n' + + 'Coastal waters from Cameron LA to High Island TX out 20 NM-\n' + + 'Coastal waters from Intracoastal City to Cameron LA out 20 NM-\n' + + 'Coastal waters from Lower Atchafalaya River to Intracoastal City\n' + + 'LA out 20 NM-\n' + + '1012 AM CDT Sun Apr 20 2025\n' + + '\n' + + '...SMALL CRAFT ADVISORY HAS EXPIRED...\n' + + '\n' + + '$$\n' + + '\n' + + 'GMZ470-472-475-202100-\n' + + '/O.CON.KLCH.SC.Y.0028.000000T0000Z-250420T2100Z/\n' + + 'Coastal waters from Cameron LA to High Island TX from 20 to 60 NM-\n' + + 'Coastal waters from Intracoastal City to Cameron LA from 20 to\n' + + '60 NM-\n' + + 'Coastal waters from Lower Atchafalaya River to Intracoastal City\n' + + 'LA from 20 to 60 NM-\n' + + '1012 AM CDT Sun Apr 20 2025\n' + + '\n' + + '...SMALL CRAFT ADVISORY REMAINS IN EFFECT UNTIL 4 PM CDT THIS\n' + + 'AFTERNOON...\n' + + '\n' + + '* WHAT...Seas 4 to 7 ft.\n' + + '\n' + + '* WHERE...Coastal waters from Cameron LA to High Island TX from \n' + + ' 20 to 60 NM, Coastal waters from Intracoastal City to Cameron \n' + + ' LA from 20 to 60 NM and Coastal waters from Lower Atchafalaya \n' + + ' River to Intracoastal City LA from 20 to 60 NM.\n' + + '\n' + + '* WHEN...Until 4 PM CDT this afternoon.\n' + + '\n' + + '* IMPACTS...Conditions will be hazardous to small craft.\n' + + '\n' + + 'PRECAUTIONARY/PREPAREDNESS ACTIONS...\n' + + '\n' + + 'Inexperienced mariners, especially those operating smaller\n' + + 'vessels, should avoid navigating in hazardous conditions.\n' + + '\n' + + '&&\n' + + '\n' + + '$$\n' + } +} + +Image and product text are optional, but if they exist, they will be in the data object. + +*/ + +const handleDiscordGuilds = function (data) { + const rawBody = data.data.body; + const text = data.data.productText; + const product_id_raw = data.data.raw + const product_id = data.product_data; + const fromChannel = data.data.channel.room; + const bodyData = data.data.body; + + + let embed = { + description: ` ${bodyData.string}`, + color: parseInt(config.priorityColors[evt.priority].replace("#", ""), 16) || 0x000000, + timestamp: product_id.timestamp, + footer: { + text: `Station: ${product_id.station} PID: ${product_id_raw} Channel: ${fromChannel}` + } + } + if (data.data.image) { + embed.image = { + url: data.data.image + } + } + + let discordMsg = { + embeds: [embed], + components: [ + { + type: 1, + components: [ + { + type: 2, + label: "Product", + style: 5, + url: bodyData.url + }, + { + type: 2, + style: 1, + custom_id: `product|${product_id_raw}`, + label: "Product Text", + emoji: { + name: "📄" + } + } + ] + } + ] + } + // Discord Channel Handling + db.all(`SELECT * FROM channels WHERE iemchannel = ?`, [fromChannel], (err, rows) => { + if (err) { + console.log(`${colors.red("[ERROR]")} ${err.message}`); + } + if (!rows) return; // No channels to alert + rows.forEach(async (row) => { + // Get Filters as arrays + if (!row.filterEvt) row.filterEvt = ""; + if (!row.filter) row.filter = ""; + let filterEvt = row.filterEvt.toLowerCase().split(","); + let filters = row.filter.toLowerCase().split(","); + if (evt.priority < row.minPriority) return; + // If the event type is not in th filter, ignore it. Make sure filterEvt isnt null + if (!filterEvt[0]) filterEvt = []; + if (!filterEvt.includes(evt.code.toLowerCase()) && !filterEvt.length == 0) return; + + let channel = discord.channels.cache.get(row.channelid); + if (!channel) return console.log(`${colors.red("[ERROR]")} Channel ${row.channelid} not found`); + + if (!filters.some((filter) => body.toLowerCase().includes(filter)) && !filters.some((filter) => text.toLowerCase().includes(filter))) return; + thisMsg = JSON.parse(JSON.stringify(discordMsg)); + thisMsg.content = row.custommessage || null; + channel.send(thisMsg).catch((err) => { + console.error(err); + }).then((msg) => { + if (msg.channel.type === Discord.ChannelType.GuildAnnouncement) msg.crosspost(); + }).catch(() => { + console.log(`${colors.yellow("[WARN]")} Failed to send message to ${channel.guild.name}/${channel.name} (${channel.guild.id}/${channel.id})`); + const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel); + logChannel.send({ + embeds: [ + { + title: "Failed to send message", + description: `There is likely an issue with permissions. Please notify the server owner if possible. + Guild: ${channel.guild.name} (${channel.guild.id}) + Channel: ${channel.name} (${channel.id}) + Guild Owner: <@${channel.guild.ownerId}> (${channel.guild.ownerId}) + Sub Info: \`\`\`json\n${JSON.stringify(row)}\`\`\``, + color: 0xff0000 + } + ] + }); + + discord.users.fetch(channel.guild.ownerId).then((user) => { + user.send({ + embeds: [ + { + title: "Issue with your subscribed channel.", + description: `There is likely an issue with permissions. Please check that I can send messages in <#${channel.id}>\nYour subscription has been removed, and you will need to resubscribe to get alerts.`, + color: 0xff0000, + fields: [ + { + name: "Guild", + value: `${channel.guild.name} (${channel.guild.id})` + }, + { + name: "Channel", + value: `${channel.name} (${channel.id})` + } + ] + } + ] + }).catch((err) => { + console.log(`${colors.red("[ERROR]")} Failed to send message to ${channel.guild.ownerId}`); + }).then(() => { + if (channel.guildId == config.discord.mainGuild) return; + db.run(`DELETE FROM channels WHERE channelid = ? AND iemchannel = ?`, [channel.id, fromChannel], (err) => { + if (err) { + console.error(err.message); + } + console.log(`${colors.cyan("[INFO]")} Deleted channel ${channel.id} from database`); + }); + }) + }); + }); + }); + }); + + + // User DM alert handling + db.all(`SELECT * FROM userAlerts WHERE iemchannel = ?`, [fromChannel], (err, rows) => { + if (err) { + console.error(err.message); + } + if (!rows) return; // No users to alert + rows.forEach((row) => { + // Get Filters as arrays + if (!row.filterEvt) row.filterEvt = ""; + if (!row.filter) row.filter = ""; + let filterEvt = row.filterEvt.toLowerCase().split(","); + let filters = row.filter.toLowerCase().split(","); + + // If priority is less than the min priority, ignore it + if (evt.priority < row.minPriority) return; + // If the event type is not in th filter, ignore it. Make sure filterEvt isnt null + if (!filterEvt[0]) filterEvt = []; + if (!filterEvt.includes(evt.code.toLowerCase()) && !filterEvt.length == 0) return; + let user = discord.users.cache.get(row.userid); + if (!user) return console.log(`${colors.red("[ERROR]")} User ${row.userid} not found`); + + if (!filters.some((filter) => body.toLowerCase().includes(filter)) && !filters.some((filter) => text.toLowerCase().includes(filter))) return; + thisMsg = JSON.parse(JSON.stringify(discordMsg)); + thisMsg.content = row.custommessage || null; + user.send(thisMsg).catch((err) => { + console.error(err); + }).catch((err) => { + console.log(`${colors.yellow("[WARN]")} Failed to send message to ${user.tag} (${user.id})`); + const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel); + logChannel.send({ + embeds: [ + { + title: "Failed to send DM", + description: `User may have DMs disabled, or bot doesnt' share a server anymore!. + User: ${user.tag} (${user.id}) + Sub Info: \`\`\`json\n${JSON.stringify(row)}\`\`\``, + color: 0xff0000 + } + ] + }).then(() => { + db.run(`DELETE FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [user.id, fromChannel], (err) => { + if (err) { + console.error(err.message); + } + console.log(`${colors.cyan("[INFO]")} Deleted user ${user.id} from database`); + }); + }) + }); + }); + }); +}; + +var retries = 0; + +function connectWebSocket() { + console.log('Attempting to connect to WebSocket...'); + const ws = new WebSocket(config.WS_URL || "wss://iem-alerter.ko4wal.radio/iem"); + + ws.on('open', () => { + console.log('Connected to WebSocket'); + ws.send(JSON.stringify({ type: 'subscribe', channel: '*' })); // Subscribe to all channels + retries = 0; // Reset retries on successful connection + }); + + ws.on('message', (rawData) => { + try { + const data = JSON.parse(rawData); + switch (data.type) { + case "iem-message": + handleDiscordGuilds(data); + handleDiscordDMs(data); + break; + + case "internal-response": + if (data.code == 200) { + console.log(`${colors.cyan("[INFO]")} ${data.data.message}`); + } else { + console.log(`${colors.red(`[ERROR] ${data.code}`)} ${data.data.error}`); + } + break; + case "connection-info": + console.log(`${colors.cyan("[INFO]")} Connected to ${data.host} (${data.uuid})`); + iem = data.iem; + + } + } catch (err) { + console.log(`${colors.red("[ERROR]")} Error parsing WebSocket message: ${err}`); + } + }); + + ws.on('close', () => { + console.log('WebSocket connection closed. Reconnecting...'); + retries++; + const retryDelay = Math.min(5000, Math.pow(2, retries) * 100); + console.log(`Retrying connection in ${retryDelay} ms...`); + setTimeout(connectWebSocket, retryDelay); + }); + + ws.on('error', (err) => { + console.error('WebSocket error:', err); + ws.close(); // Ensure the connection is closed before retrying + }); +} + +connectWebSocket(); + +// START DISCORD + +discord.on('ready', async () => { + console.log(`${colors.cyan("[INFO]")} Logged in as ${discord.user.tag}`); + if (config["uptime-kuma"].enabled) { + fetch(config["uptime-kuma"].url).then(() => { + console.log(`${colors.cyan("[INFO]")} Sent heartbeat to Uptime Kuma`) + }) + setInterval(() => { + // Send POST request to config["uptime-kuma"].url + fetch(config["uptime-kuma"].url).then(() => { + console.log(`${colors.cyan("[INFO]")} Sent heartbeat to Uptime Kuma`) + }) + }, config["uptime-kuma"].interval * 1000) // Every X seconds + } + + // Get all guilds, and log them + discord.guilds.cache.forEach((guild) => { + console.log(`${colors.cyan("[INFO]")} In guild: ${guild.name} (${guild.id})`); + }); + + // Do slash command stuff + commands = require("./data/commands.json"); + // Add dynamic commands (based on datas files) + satCommand = { + "name": "satellite", + "description": "Get the latest satellite images from a given satellite", + "options": [ + { + "name": "satellite", + "description": "The satellite to get images from", + "type": 3, + "required": true, + "choices": [] + } + ] + } + for (const key in satellites) { + satCommand.options[0].choices.push({ + "name": key, + "value": key + }); + } + commands.push(satCommand); + + if (config.broadcastify.enabled) { + // Add commands to join vc, leave vc, and play stream + commands.push( + { + "name": "playbcfy", + "description": "Play the broadcastify stream", + "options": [ + { + "name": "id", + "description": "The ID of the stream to play", + "type": 3, + "required": true + } + ] + } + ) + } + if (config.voice_enabled) { + // Add commands to join vc, leave vc, and play stream + commands.push( + { + "name": "leave", + "description": "Leave the current voice chat", + "default_member_permissions": 0 + }, + { + "name": "play", + "type": 1, + "description": "Play a stream", + "options": [ + { + "name": "url", + "description": "The URL of the stream to play", + "type": 3, + "required": true + } + ] + }, + { + "name": "pause", + "description": "Pause/Unpause the current stream", + "type": 1 + }, + { + "name": "volume", + "description": "Set the volume of the current stream", + "options": [ + { + "name": "volume", + "description": "The volume to set", + "type": 4, + "required": true + } + ] + } + ) + + nwrplayCommand = { + "name": "nwrplay", + "description": "Nwr stream", + "type": 1, + "options": [ + { + "name": "callsign", + "description": "The URL of the stream to play", + "type": 3, + "required": true, + "autocomplete": true + } + ] + } + commands.push(nwrplayCommand); + } + await (async () => { + try { + //Global + if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} Registering global commands`); + await rest.put(Routes.applicationCommands(discord.user.id), { body: commands }) + } catch (error) { + console.error(error); + } + })(); + + setTimeout(() => { + // Wait 10 seconds, if startup is still true, something went wrong + if (startup) { + console.log(`${colors.red("[ERROR]")} Startup failed, exiting...`); + process.exit(1); + } + }, 10000) + + // Check all channels in DB, fetch them, if they dont exist, delete all subscriptions + db.all(`SELECT channelid FROM channels`, (err, rows) => { + if (err) { + console.error(err.message); + } + rows.forEach((row) => { + const channel = discord.channels.cache.get(row.channelid); + if (!channel) { + // Delete the channel from the database and return + return db.run(`DELETE FROM channels WHERE channelid = ?`, [row.channelid], (err) => { + if (err) { + console.error(err.message); + } + console.log(`${colors.cyan("[INFO]")} Deleted channel ${row.channelid} from database`); + }); + }; + }); + }); + + // Get all users in userAlerts and fetch them + db.all(`SELECT userid FROM userAlerts`, (err, rows) => { + if (err) { + console.error(err.message); + } + rows.forEach((row) => { + discord.users.fetch(row.userid); + }); + }); +}); + +discord.on("interactionCreate", async (interaction) => { + switch (interaction.type) { + case Discord.InteractionType.ApplicationCommand: + switch (interaction.commandName) { + case "subscribe": + room = getWFOroom(interaction.options.getString("room")); + if (!iem.find((channel) => channel.jid.split("@")[0] === room)) { + interaction.reply({ content: "Invalid room", ephemeral: true }); + return; + } + if (interaction.options.getString("filter")) { + filter = interaction.options.getString("filter").toLowerCase(); + } else { + filter = ""; + } + minPriority = interaction.options.getInteger("minpriority"); + filterEvt = interaction.options.getString("filterevt") || null; + message = interaction.options.getString("message") || null; + if (interaction.inGuild()) { + interaction.channel.send("Permission check").then((msg) => { + msg.delete(); + db.get(`SELECT * FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err, row) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to subscribe to room", ephemeral: true }); + } else if (row) { + return interaction.reply({ content: `Already subscribed to \`${getWFOByRoom(room).location}\`\nIf you want to update a subscribtion, please unsubscribe and resubscribe. This will be made a command eventually.`, ephemeral: true }); + } + db.run(`INSERT INTO channels (channelid, iemchannel, custommessage, filter, filterEvt, minPriority) VALUES (?, ?, ?, ? ,? ,?)`, [interaction.channel.id, room, message, filter, filterEvt, minPriority], (err) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to subscribe to room", ephemeral: true }); + } else { + interaction.reply({ content: `Subscribed to \`${getWFOByRoom(room).location}\``, ephemeral: true }); + } + }); + }); + }).catch((err) => { + interaction.reply({ content: "Failed to subscribe to room. Bot does not have send message permissions here!", ephemeral: true }); + }); + } else { // We're in a DM + db.get(`SELECT * FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err, row) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to subscribe to room", ephemeral: true }); + } else if (row) { + return interaction.reply({ content: `Already subscribed to \`${getWFOByRoom(room).location}\`\nIf you want to update a subscribtion, please unsubscribe and resubscribe. This will be made a command eventually.`, ephemeral: true }); + } + db.run(`INSERT INTO userAlerts (userid, iemchannel, custommessage, filter, filterEvt, minPriority) VALUES (?, ?, ?, ? ,?, ?)`, [interaction.user.id, room, message, filter, filterEvt, minPriority], (err) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to subscribe to room", ephemeral: true }); + } else { + interaction.reply({ content: `Subscribed to \`${getWFOByRoom(room).location}\``, ephemeral: true }); + } + }); + }); + } + break; + case "unsubscribe": + // Check that the room is valid + room = getWFOroom(interaction.options.getString("room")); + if (!iem.find((channel) => channel.jid.split("@")[0] === room)) { + interaction.reply({ content: "Invalid room", ephemeral: true }); + return; + } + if (interaction.inGuild()) { + // Check if subbed + db.get(`SELECT * FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err, row) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to unsubscribe from room", ephemeral: true }); + } + if (!row) { + return interaction.reply({ content: `Not subscribed to \`${getWFOByRoom(room).location}\``, ephemeral: true }); + } + db.run(`DELETE FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to unsubscribe from room", ephemeral: true }); + } + interaction.reply({ content: `Unsubscribed from \`${getWFOByRoom(room).location}\``, ephemeral: true }); + }); + }); + } else { + db.get(`SELECT * FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err, row) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to unsubscribe from room", ephemeral: true }); + } + if (!row) { + return interaction.reply({ content: `Not subscribed to \`${getWFOByRoom(room).location}\``, ephemeral: true }); + } + db.run(`DELETE FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to unsubscribe from room", ephemeral: true }); + } + interaction.reply({ content: `Unsubscribed from \`${getWFOByRoom(room).location}\``, ephemeral: true }); + }); + }); + } + break; + case "list": + // List all the subscribed rooms + if (interaction.inGuild()) { + db.all(`SELECT * FROM channels WHERE channelid = ?`, [interaction.channel.id], (err, rows) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to get subscribed rooms", ephemeral: true }); + } + if (!rows) { + return interaction.reply({ content: "No subscribed rooms", ephemeral: true }); + } + let roomList = []; + rows.forEach((row) => { + roomList.push({ + name: `${row.iemchannel}: ${getWFOByRoom(row.iemchannel).location}`, + value: `Message: \`\`${row.custommessage || "None"}\`\`\nFilter: \`\`${row.filter || "None"}\`\`\nEvent Filter: \`\`${row.filterEvt || "None"}\`\`\nMin Priority: \`\`${row.minPriority || "None"}\`\`` + }); + }); + const embed = { + title: "Subscribed Rooms", + fields: roomList, + color: 0x00ff00 + } + interaction.reply({ embeds: [embed], ephemeral: true }); + }); + } else { + db.all(`SELECT * FROM userAlerts WHERE userid = ?`, [interaction.user.id], (err, rows) => { + if (err) { + console.error(err.message); + interaction.reply({ content: "Failed to get subscribed rooms", ephemeral: true }); + } + if (!rows) { + return interaction.reply({ content: "No subscribed rooms", ephemeral: true }); + } + let roomList = []; + rows.forEach((row) => { + roomList.push({ + name: `${row.iemchannel}: ${getWFOByRoom(row.iemchannel).location}`, + value: `Message: \`\`${row.custommessage || "None"}\`\`\nFilter: \`\`${row.filter || "None"}\`\`\nEvent Filter: \`\`${row.filterEvt || "None"}\`\`\nMin Priority: \`\`${row.minPriority || "None"}\`\`` + }); + }); + const embed = { + title: "Subscribed Rooms", + fields: roomList, + color: 0x00ff00 + } + interaction.reply({ embeds: [embed], ephemeral: true }); + }); + } + break; + case "about": + // Send an embed showing info about the bot, including number of guilds, number of subscribed rooms, etc + let guilds = discord.guilds.cache.size; + let channels = 0; + let uniques = 0; + await db.get(`SELECT COUNT(*) as count FROM channels`, async (err, row) => { + channels = row.count + + await getUniqueChannels().then((unique) => { + uniques = unique.channels; + guilds = unique.guilds; + }); + discord.users.fetch("289884287765839882").then((chrisUser) => { + const embed = { + title: "About Me!", + thumbnail: { + url: discord.user?.avatarURL() + }, + description: `I listen to all the weather.im rooms and send them to discord channels.\nI am open source, you can find my code [here!](https://github.com/ChrisChrome/iembot-2.0)\n\nThis bot is not affiliated with NOAA, the National Weather Service, or the IEM project.`, + fields: [ + { + name: "Uptime", + value: `Since , Started `, + }, + { + name: "Caught Messages", + value: `Got ${messages.toLocaleString()} messages since startup`, + }, + { + name: "Guilds", + value: guilds.toLocaleString(), + inline: true + }, + { + name: "Subscribed Rooms", + value: `${channels.toLocaleString()}`, + inline: true + }, + { + name: "Unique Channels", + value: `${uniques.toLocaleString()} in ${guilds} guilds.`, + inline: true + } + ], + color: 0x00ff00, + footer: { + text: "Made by @chrischrome with <3", + icon_url: chrisUser.avatarURL() + } + } + interaction.reply({ embeds: [embed] }); + }) + }); + break; + case "rooms": + // // Send an embed showing all the available rooms + // let roomList = ""; + // iem.forEach((channel) => { + // room = channel.jid.split("@")[0] + // console.log(getWFOByRoom(room)) + // roomList += `\`${room}\`: ${getWFOByRoom(room).location}\n`; + // }); + // const roomEmbed = { + // title: "Available Rooms", + // description: roomList, + // color: 0x00ff00 + // } + // interaction.reply({ embeds: [roomEmbed], ephemeral: true }); + // Do the above, but paginate like the product text + let roomList = ""; + iem.forEach((channel) => { + room = channel.jid.split("@")[0] + roomList += `\`${room}\`: ${getWFOByRoom(room).location || "Unknown"}\n`; + }); + const pages = roomList.match(/[\s\S]{1,2000}(?=\n|$)/g); + embeds = pages.map((page, ind) => ({ + title: `Available Rooms Pg ${ind + 1}/${pages.length}`, + description: page, + color: 0x00ff00 + })); + interaction.reply({ embeds, ephemeral: true }); + break; + case "setupall": + if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true }); + if (!config.discord.owner) return interaction.reply({ content: "Owner not set in config", ephemeral: true }); + if (interaction.user.id !== config.discord.owner) return interaction.reply({ content: "You are not the owner", ephemeral: true }); + await interaction.deferReply({ ephemeral: true }) + var category; + + + + // New setup, we're pulling from wfos.json now + const chunks = []; + const chunkSize = 50; + const total = iem.length; + // wfos is object "wfo": {"location": "Text Name", "room": "roomname"} + for (let i = 0; i < total; i += chunkSize) { + chunks.push(iem.slice(i, i + chunkSize)); + console.log(iem.slice(i, i + chunkSize)) + } + + + + chunks.forEach((chunk, index) => { + const categoryName = `Rooms ${index + 1}`; + interaction.guild.channels.create({ + name: categoryName, + type: Discord.ChannelType.GuildCategory + }).then((newCategory) => { + console.log(`${colors.cyan("[INFO]")} Created category ${newCategory.name}`); + chunk.forEach((channel) => { + channelName = `${channel.jid.split("@")[0]}_${getWFOByRoom(channel.jid.split("@")[0]).location}` + if (channelName == "Unknown") channelName = channel.jid.split("@")[0] + newCategory.guild.channels.create({ + name: channelName, + type: Discord.ChannelType.GuildText, + parent: newCategory, + topic: `Weather.im room for ${getWFOByRoom(channel.jid.split("@")[0]).location} - ${channel.jid.split("@")[0]}` + }).then((newChannel) => { + console.log(`${colors.cyan("[INFO]")} Created channel ${newChannel.name}`); + db.run(`INSERT INTO channels (channelid, iemchannel, custommessage) VALUES (?, ?, ?)`, [newChannel.id, channel.jid.split("@")[0], null], (err) => { + if (err) { + console.error(err.message); + } + console.log(`${colors.cyan("[INFO]")} Added channel ${newChannel.id} to database`); + }); + }).catch((err) => { + console.log(`${colors.red("[ERROR]")} Failed to create channel: ${err.message}`); + }); + }); + }).catch((err) => { + console.log(`${colors.red("[ERROR]")} Failed to create category: ${err.message}`); + }); + }); + interaction.editReply({ content: "Setup complete", ephemeral: true }); + break; + case "support": + // Generate an invite link to the support server (use widget channel) + const invite = await discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.inviteChannel).createInvite(); + const embed = { + title: "Support Server", + description: `Need help with the bot? Join the support server [here](${invite.url})`, + color: 0x00ff00 + } + interaction.reply({ embeds: [embed] }); + break; + + case "playbcfy": // Play broadcastify stream + if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true }); + if (!config.broadcastify.enabled) return interaction.reply({ content: "Broadcastify is not enabled", ephemeral: true }); + streamID = interaction.options.getString("id"); + // Check if the stream ID is valid (up to 10 digit alphanumeric) + if (!streamID.match(/^[a-zA-Z0-9]{1,10}$/)) return interaction.reply({ content: "Invalid stream ID", ephemeral: true }); + // Get the stream URL + url = `https://${config.broadcastify.username}:${config.broadcastify.password}@audio.broadcastify.com/${streamID}.mp3`; + // Get the channel + channel = interaction.member.voice?.channel; + if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true }); + // Join the channel and play the stream + res = JoinChannel(channel, url, .1, interaction) + if (res) { + interaction.reply({ content: "Playing Stream", ephemeral: true }); + } else { + interaction.reply({ content: `Failed to play stream`, ephemeral: true }); + } + break; + + case "play": // Play generic stream + if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true }); + // Use local variables & Get the URL + interactionUrl = interaction.options.getString("url"); + // Get the channel + channel = interaction.member.voice?.channel; + // Check if in channel + if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true }); + // Join the channel and play the stream + st = JoinChannel(channel, interactionUrl, .1, interaction); + + if (st) { + interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true }); + } else { + interaction.reply({ content: `Failed to play stream`, ephemeral: true }); + } + break; + + case "nwrplay": // Play NWR stream + if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true }); + + // Get the callsign + const callsign = interaction.options.getString("callsign"); + // Get the URL associated with the callsign + url = nwrstreams.callsigns[callsign]; + + // Get the voice channel + channel = interaction.member.voice?.channel; // Use a unique variable name + if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true }); + + // Join the channel and play the stream + const streamStatus = JoinChannel(channel, url, .1, interaction); // Use a unique variable name + if (streamStatus) { + interaction.reply({ content: "Joined, trying to start playing.", ephemeral: true }); + } else { + interaction.reply({ content: `Failed to play stream`, ephemeral: true }); + } + break; + + + case "leave": // Leave Channel + if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true }); + channel = interaction.member.voice.channel; + if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true }); + res = LeaveVoiceChannel(channel) + if (res) { + interaction.reply({ content: "Left voice channel", ephemeral: true }); + } else { + interaction.reply({ content: "Failed to leave voice channel (Was i ever in one?)", ephemeral: true }); + } + + break; + case "pause": // Pause/unpause stream + if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true }); + channel = interaction.member.voice.channel; + if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true }); + res = toggleVoicePause(channel) + if (res) { + interaction.reply({ content: "Toggled pause", ephemeral: true }); + } else { + interaction.reply({ content: "Failed to toggle pause", ephemeral: true }); + } + break; + case "volume": // Set volume + if (!interaction.inGuild()) return interaction.reply({ content: "This command can only be used in a guild", ephemeral: true }); + channel = interaction.member.voice.channel; + if (!channel) return interaction.reply({ content: "You need to be in a voice channel", ephemeral: true }); + volume = interaction.options.getInteger("volume") / 100; + // Make sure volume isnt negative + if (volume < 0) volume = 0; + if (volume > 1) volume = 1; + res = setVolume(channel, volume) + if (res) { + interaction.reply({ content: `Set volume to ${volume * 100}%` }); + } else { + interaction.reply({ content: "Failed to set volume", ephemeral: true }); + } + break; + case "outlook": + day = interaction.options.getInteger("day"); + type = interaction.options.getString("type"); + if (day < 0 || day > 7) return interaction.reply({ content: "Invalid day", ephemeral: true }); + if (type !== "fire" && type !== "convective") return interaction.reply({ content: "Invalid type", ephemeral: true }); + url = outlookURLs[type][day]; + await interaction.deferReply(); + fetch(url).then((res) => { + if (res.status !== 200) { + interaction.editReply({ content: "Failed to get outlook", ephemeral: true }); + return; + } + res.buffer().then(async (buffer) => { + // Check all overlays and add them to image as selected using Jimp + overlays = ["population", "city", "cwa", "rfc", "interstate", "county", "tribal", "artcc", "fema"] + await Jimp.read(buffer).then((image) => { + outImg = image; + cnt = 0; + sendMsg = setTimeout(() => { + interaction.editReply({ + embeds: [{ + title: `${toTitleCase(type)} Outlook Day ${day + 1}`, + image: { + url: `attachment://${type}_${day}.png` + }, + color: 0x00ff00 + }], + files: [{ + attachment: buffer, + name: `${type}_${day}.png` + }] + }); + }, 150) + overlays.forEach((overlay) => { + if (interaction.options.getBoolean(`${overlay}_overlay`)) { + clearTimeout(sendMsg); + Jimp.read(`./images/overlays/${overlay}.png`).then((overlayImage) => { + outImg.composite(overlayImage, 0, 0); + sendMsg = setTimeout(() => { + outImg.getBufferAsync(Jimp.MIME_PNG).then((buffer) => { + interaction.editReply({ + embeds: [{ + title: `${toTitleCase(type)} Outlook Day ${day + 1}`, + image: { + url: `attachment://${type}_${day}.png` + }, + color: 0x00ff00 + }], + files: [{ + attachment: buffer, + name: `${type}_${day}.png` + }] + }); + }); + }, 150) + }); + } + }) + + + + // interaction.editReply({ + // embeds: [{ + // title: `${toTitleCase(type)} Outlook Day ${day + 1}`, + // image: { + // url: `attachment://${type}_${day}.png` + // }, + // color: 0x00ff00 + // }], + // files: [{ + // attachment: buffer, + // name: `${type}_${day}.png` + // }] + // }); + }); + }); + }).catch((err) => { + interaction.editReply({ content: "Failed to get outlook", ephemeral: true }); + console.log(`${colors.red("[ERROR]")} Failed to get outlook: ${err.message}`); + console.error(err); + }); + break; + case "alertmap": + const alertmapurl = "https://forecast.weather.gov/wwamap/png/US.png" + await interaction.deferReply(); + fetch(alertmapurl).then((res) => { + if (res.status !== 200) { + interaction.editReply({ content: "Failed to get alert map", ephemeral: true }); + return; + } + res.buffer().then(async (buffer) => { + interaction.editReply({ + embeds: [{ + title: `Alert Map`, + image: { + url: `attachment://alerts.png` + }, + color: 0x00ff00 + }], + files: [{ + attachment: buffer, + name: `alerts.png` + }] + }); + }); + }).catch((err) => { + interaction.editReply({ content: "Failed to get alert map", ephemeral: true }); + console.log(`${colors.red("[ERROR]")} Failed to get alert map: ${err.message}`); + console.error(err); + }); + break; + case "satellite": // Get satellite images + sat = interaction.options.getString("satellite"); + if (!satellites[sat]) return interaction.reply({ content: "Invalid satellite", ephemeral: true }); + // Fetch all the images + productOptions = [] + await (() => { + for (const key in satellites[sat].products) { + // make a discord customid safe id for the product name, add it to the satellites object + satellites[sat].products[key].customid = key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(); + productOptions.push({ + label: key, + value: satellites[sat].products[key].customid + }) + } + console.log(JSON.stringify(productOptions, null, 2)) + })(); + satMessages[interaction.id] = { + sat + } + await interaction.reply({ + content: "Choose a product", + components: [ + { + type: 1, + components: [ + { + type: 3, + custom_id: `satproduct|${interaction.id}`, + label: "Product", + // map options to product names + options: productOptions + } + ] + } + ] + }) + break; + + case "forecast": + await interaction.deferReply(); + periods = interaction.options.getInteger("periods") || 1; + funcs.getWeatherBySearch(interaction.options.getString("location")).then((weather) => { + if (config.debug >= 1) console.log(JSON.stringify(weather, null, 2)) + embeds = funcs.generateDiscordEmbeds(weather, periods); + interaction.editReply({ embeds }); + }).catch((err) => { + interaction.editReply({ content: "Failed to get forecast", ephemeral: true }); + if (config.debug >= 1) console.log(`${colors.red("[ERROR]")} Failed to get forecast: ${err}`); + }); + break; + + + + + } + case Discord.InteractionType.MessageComponent: + if (!interaction.customId) return; + switch (interaction.customId.split("|")[0]) { + case "product": + if (interaction.customId) { + const product_id = interaction.customId.split("|")[1]; + url = `https://mesonet.agron.iastate.edu/api/1/nwstext/${product_id}`; + await interaction.deferReply({ ephemeral: true }); + fetch(url).then((res) => { + if (res.status !== 200) { + interaction.reply({ content: "Failed to get product text", ephemeral: true }); + return; + } + // Retruns raw text, paginate it into multiple embeds if needed + res.text().then(async (text) => { + const pages = text.match(/[\s\S]{1,1900}(?=\n|$)/g); + // const embeds = pages.map((page, ind) => ({ + // title: `Product Text for ${product_id} Pg ${ind + 1}/${pages.length}`, + // description: `\`\`\`${page}\`\`\``, + // color: 0x00ff00 + // })); + const messages = pages.map((page, ind) => { + return `\`\`\`${page}\`\`\`` + }) + messages.forEach(async (message) => { + interaction.followUp({ content: message, ephemeral: true }); + }) + }); + }).catch((err) => { + interaction.reply({ content: "Failed to get product text", ephemeral: true }); + console.log(`${colors.red("[ERROR]")} Failed to get product text: ${err.message}`); + }); + } + break; + case "satproduct": + satData = satMessages[interaction.customId.split("|")[1]]; + sat = satData.sat + product = interaction.values[0]; + // find the original product name + product_name = Object.keys(satellites[sat].products).find(key => satellites[sat].products[key].customid === product); + imageOptions = [] + satMessages[interaction.customId.split("|")[1]] = { + sat, + product, + product_name, + images: {} + } + await (() => { + // for key, value in satellites[sat].products[product_name] + console.log(product_name) + for (const key in satellites[sat].products[product_name]) { + // make a discord customid safe id for the product name, add it to the satellites object + //console.log(satellites[sat].products[product_name]) + if (key === "customid") continue; + satMessages[interaction.customId.split("|")[1]].images[key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()] = satellites[sat].products[product_name][key]; + imageOptions.push({ + label: key, + value: key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase() + }) + } + })(); + interaction.deferReply(); + await interaction.message.edit({ + content: "Choose an image to view", + components: [ + { + type: 1, + components: [ + { + type: 3, + custom_id: `satproduct2|${interaction.customId.split("|")[1]}`, + label: "Image", + // map options to product names + options: imageOptions + } + ] + } + ] + }).then(() => { + interaction.deleteReply(); + }); + break; + case "satproduct2": + satData = satMessages[interaction.customId.split("|")[1]]; + sat = satData.sat; + product = satData.product; + product_name = satData.product_name; + image = interaction.values[0]; + url = satData.images[image]; + // get filename from url + filename = url.split("/").pop(); + interaction.deferReply(); + // Get the image + fetch(url).then((res) => { + if (res.status !== 200) { + interaction.message.edit({ content: "Failed to get image", ephemeral: true }).then(() => { + interaction.deleteReply(); + }); + return; + } + embeds = []; + files = []; + + res.buffer().then(async (buffer) => { + files.push({ + attachment: buffer, + name: filename + }) + embeds.push({ + title: `${sat}/${product_name}/${image}`, + image: { + url: `attachment://${filename}` + }, + color: 0x00ff00 + }); + interaction.message.edit({ + embeds, + files, + components: [], + content: null + }).then(() => { + interaction.deleteReply(); + }); + } + ); + }).catch((err) => { + interaction.message.edit({ content: "Failed to get image", ephemeral: true }).then(() => { + interaction.deleteReply(); + }); + console.log(`${colors.red("[ERROR]")} Failed to get image: ${err.stack}`); + }); + break; + } + break; + + case Discord.InteractionType.ApplicationCommandAutocomplete: + //map nwrstreams + if (interaction.commandName === "nwrplay") { + let callsignSearch = interaction.options.getString("callsign"); + let callsigns = Object.keys(nwrstreams.callsigns); + let results = callsigns.filter((callsign) => callsign.toLowerCase().includes(callsignSearch.toLowerCase())); + if (results.length > 25) { + results = results.slice(0, 25); + } + interaction.respond(results.map((callsign) => ({ name: callsign, value: callsign }))); + } + break; + + } +}); + +discord.on("guildCreate", async (guild) => { + let logs = await guild.fetchAuditLogs() + logs = logs.entries.filter(e => e.action === Discord.AuditLogEvent.BotAdd) + let user = logs.find(l => l.target?.id === discord.user.id)?.executor + // Get the main guild + const myGuild = discord.guilds.cache.get(config.discord.mainGuild); + // Get the log channel + const channel = myGuild.channels.cache.get(config.discord.logChannel); + // Send a message to the log channel + let invite = await discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.inviteChannel).createInvite(); + user.send({ + embeds: [{ + description: `Thanks for adding ${discord.user.username}!\nIf you have **ANY** questions, comments, suggestions, bug reports, etc, please feel free to throw it by us in our support server!\n\nTo get started use \`/subscribe\` to get alerts!`, + color: 0x00ff00 + }], + components: [ + { + type: Discord.ComponentType.ActionRow, + components: [ + { + type: Discord.ComponentType.Button, + url: `https://discord.gg/${invite.code}`, + style: Discord.ButtonStyle.Link, + emoji: "ℹ", + label: "IEM Alerter Support Server" + } + ] + } + ] + }).catch((err) => { + console.log(`${colors.red("[ERROR]")} Failed to send message to user ${user.id}: ${err.message}`); + }) + channel.send({ + embeds: [ + { + description: `I joined \`${guild.name}\``, + fields: [ + { + "name": "User", + "value": `<@${user.id}> (@${user.username}) ${user.displayName}` + } + ], + color: 0x00ff00 + } + ] + }) + +}) + +discord.on("guildDelete", (guild) => { + // Get the main guild + const myGuild = discord.guilds.cache.get(config.discord.mainGuild); + // Get the log channel + const channel = myGuild.channels.cache.get(config.discord.logChannel); + // Send a message to the log channel + channel.send({ + embeds: [ + { + description: `I left \`${guild.name}\``, + color: 0xff0000 + } + ] + }) +}) + +process.on("unhandledRejection", (error, promise) => { + console.log(`${colors.red("[ERROR]")} Unhandled Rejection @ ${promise}: ${error.stack}`); + // create errors folder if it doesnt exist + if (!fs.existsSync("./error")) { + fs.mkdirSync("./error"); + } + // write ./error/rejection_timestamp.txt + fs.writeFileSync(`./error/rejection_${Date.now()}.txt`, `ERROR:\n${error}\n\nPROMISE:\n${JSON.stringify(promise)}`); + // Send discord log + const myGuild = discord.guilds.cache.get(config.discord.mainGuild); + const channel = myGuild.channels.cache.get(config.discord.logChannel); + channel.send({ + embeds: [ + { + description: `Unhandled Rejection\n\`\`\`${error}\n${JSON.stringify(promise)}\`\`\``, + color: 0xff0000 + } + ] + }) + return; +}); + +process.on("uncaughtException", (error) => { + + console.log(`${colors.red("[ERROR]")} Uncaught Exception: ${error.message}\n${error.stack}`); + if (!fs.existsSync("./error")) { + fs.mkdirSync("./error"); + } + // write ./error/exception_timestamp.txt + fs.writeFileSync(`./error/exception_${Date.now()}.txt`, error.stack); + // Send message to log channel + const myGuild = discord.guilds.cache.get(config.discord.mainGuild); + const channel = myGuild.channels.cache.get(config.discord.logChannel); + channel.send({ + embeds: [ + { + description: `Uncaught Exception\n\`\`\`${error.message}\n${error.stack}\`\`\``, + color: 0xff0000 + } + ] + }) + return; +}); + + + +// Login to discord +discord.login(config.discord.token); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..12f4929 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "weather-bot", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "GPL-3.0", + "dependencies": { + "@discordjs/opus": "^0.9.0", + "@discordjs/voice": "^0.17.0", + "@xmpp/client": "^0.13.1", + "@xmpp/debug": "^0.13.0", + "colors": "^1.4.0", + "discord.js": "14.14.1", + "geolib": "^3.3.4", + "html-entities": "^2.5.2", + "jimp": "^0.22.12", + "sodium": "^3.0.2", + "sqlite3": "^5.1.7", + "ts-node": "^10.9.2", + "xml2json": "^0.12.0" + } +} diff --git a/testing/voicetest.js b/testing/voicetest.js new file mode 100644 index 0000000..ebbab8f --- /dev/null +++ b/testing/voicetest.js @@ -0,0 +1,69 @@ +const Discord = require('discord.js'); +const { Client, Intents } = require('discord.js'); +const client = new Client({ intents: ["GuildVoiceStates", "Guilds"] }); + +const config = require('../config.json'); + +const dVC = require('@discordjs/voice'); +const { join } = require('path'); + +// get user input for url and channel +console.log(process.argv) + +channelIN = process.argv[2]; +urlIN = process.argv[3]; + +client.once('ready', () => { + console.log("ready"); + JoinChannel(client.channels.cache.get(channelIN), urlIN); +}); + +client.login(config.discord.token); + +function JoinChannel(channel, track, volume) { + const connection = dVC.joinVoiceChannel({ + channelId: channel.id, + guildId: channel.guild.id, + adapterCreator: channel.guild.voiceAdapterCreator, + selfDeaf: true + }); + + + const resource = dVC.createAudioResource(track, {inlineVolume: true, silencePaddingFrames: 5}); + const player = dVC.createAudioPlayer(); + resource.volume.setVolume(2); + connection.subscribe(player) + player.play(resource); + + connection.on(dVC.VoiceConnectionStatus.Ready, () => {console.log("ready"); player.play(resource);}) + connection.on(dVC.VoiceConnectionStatus.Disconnected, async (oldState, newState) => { + try { + console.log("Disconnected.") + await Promise.race([ + dVC.entersState(connection, VoiceConnectionStatus.Signalling, 5_000), + dVC.entersState(connection, VoiceConnectionStatus.Connecting, 5_000), + ]); + } catch (error) { + connection.destroy(); + } + }); + player.on('error', error => { + console.error(`Error: ${error.message} with resource ${error.resource.metadata.title}`); + player.stop(); + }); + player.on(dVC.AudioPlayerStatus.Playing, () => { + console.log('The audio player has started playing!'); + }); + player.on('idle', () => { + connection.destroy(); + }) + console.log(player.state.resource.volume.volume) +} + +function LeaveVoiceChannel(channel) { + // Get resource, player, etc, and destroy them + const connection = dVC.getVoiceConnection(channel.guild.id); + if (connection) { + connection.destroy(); + } +} \ No newline at end of file diff --git a/testing/wfo.js b/testing/wfo.js new file mode 100644 index 0000000..02682d9 --- /dev/null +++ b/testing/wfo.js @@ -0,0 +1,30 @@ +// load wfos.json, find all wfos that have a 3 character room code, and add `chat` to the end of room codes + +const fs = require('fs'); +const path = require('path'); + +const wfos = require('../wfos.json'); + +// wfos is an object of objects + +// const newWfos = Object.keys(wfos).reduce((acc, key) => { +// const wfo = wfos[key]; +// if (wfo.room.length === 3) { +// wfo.room = `${wfo.room}chat`; +// } +// acc[key] = wfo; +// return acc; +// }, {}); + +// Loop thru wfos and find locations that have at the end, remove that +const newWfos = Object.keys(wfos).reduce((acc, key) => { + const wfo = wfos[key]; + if (wfo.location.endsWith('')) { + wfo.location = wfo.location.slice(0, -5); + } + acc[key] = wfo; + return acc; +}, {}); + + +fs.writeFileSync(path.join(__dirname, 'wfos.json'), JSON.stringify(newWfos, null, 2)); diff --git a/testing/xml2jsontmp.js b/testing/xml2jsontmp.js new file mode 100644 index 0000000..98bbb5a --- /dev/null +++ b/testing/xml2jsontmp.js @@ -0,0 +1,231 @@ +// Leaving this here for future use +const xml2json = require('xml2json'); + +const xml = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; + +const json = xml2json.toJson(xml, { object: true }); + +console.log(JSON.stringify(json, null, 2));