@atmosx/event-product-parser 3.0.4 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +1 -1
- package/.github/SUPPORTED_EVENTS.md +370 -0
- package/.github/docs/docs-functions.md +30 -0
- package/.github/docs/docs-general-configurations.md +199 -0
- package/.github/docs/docs-integrations.md +38 -0
- package/.github/docs/docs-listeners.md +28 -0
- package/.github/docs/docs-source-configuration.md +218 -0
- package/.github/docs/docs-technical.md +50 -0
- package/.github/logo.png +0 -0
- package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
- package/.github/samples/SAMPLE_GEOJSON.json +204 -0
- package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +119 -0
- package/README.md +157 -337
- package/dist/cjs/index.cjs +24125 -15815
- package/dist/esm/index.mjs +24144 -15839
- package/package.json +56 -53
- package/pnpm-workspace.yaml +4 -0
- package/src/bootstrap.ts +83 -43
- package/src/building/CreateEvent.ts +54 -0
- package/src/{@building/building.clean.ts → building/GetCleanedEvent.ts} +4 -4
- package/src/building/GetEventAttachments.ts +88 -0
- package/src/building/GetEventDirection.ts +28 -0
- package/src/{@building/building.enhance.ts → building/GetEventEnhancedName.ts} +13 -17
- package/src/{@building/building.geometry.ts → building/GetEventGeometry.ts} +19 -13
- package/src/{@building/building.headers.ts → building/GetEventHeader.ts} +13 -13
- package/src/{@building/building.polygon.ts → building/GetEventNodes.ts} +26 -22
- package/src/{@building/building.office.ts → building/GetEventOffice.ts} +14 -14
- package/src/building/GetEventProperties.ts +105 -0
- package/src/{@building/building.signature.ts → building/GetEventSignature.ts} +16 -17
- package/src/{@core/core.createListener.ts → building/GetEventTags.ts} +11 -6
- package/src/building/GetEventTheme.ts +26 -0
- package/src/building/GetEventTracking.ts +64 -0
- package/src/components/audio/GenerateAudioMessage.ts +149 -0
- package/src/components/audio/components/GetCleanDescription.ts +91 -0
- package/src/{@modules/@eas/eas.getFloatPCM16.ts → components/audio/components/GetFloatPCM16.ts} +3 -3
- package/src/{@modules/@eas/eas.getMergedPCM16.ts → components/audio/components/GetMergedPCM16.ts} +3 -3
- package/src/{@modules/@eas/eas.getPCM16.ts → components/audio/components/GetPCM16.ts} +13 -8
- package/src/{@modules/@eas/eas.getPCMToFloat.ts → components/audio/components/GetPCMToFloat.ts} +3 -3
- package/src/{@modules/@eas/eas.getSampledPCM16.ts → components/audio/components/GetSampledPCM16.ts} +14 -8
- package/src/components/audio/components/GetTTS.ts +61 -0
- package/src/{@modules/@eas/eas.getWavPCM16.ts → components/audio/components/GetWavPCM16.ts} +8 -8
- package/src/{@modules/@eas/eas.setAFSK.ts → components/audio/components/SetAFSK.ts} +12 -8
- package/src/{@modules/@eas/eas.setAsciiToBits.ts → components/audio/components/SetAsciiToBits.ts} +3 -4
- package/src/{@modules/@eas/eas.setAttentionTone.ts → components/audio/components/SetAttentionTone.ts} +11 -6
- package/src/{@modules/@eas/eas.setNoise.ts → components/audio/components/SetNoise.ts} +14 -8
- package/src/{@modules/@eas/eas.setRadioEffect.ts → components/audio/components/SetRadioEffect.ts} +14 -8
- package/src/{@modules/@eas/eas.setSameHeader.ts → components/audio/components/SetSameHeader.ts} +22 -15
- package/src/{@modules/@utilities/utilities.setWarning.ts → components/database/CreateQuery.ts} +18 -13
- package/src/{@modules/@database/database.cache.ts → components/database/GetCachedEvents.ts} +19 -14
- package/src/components/database/ImportBoundaries.ts +168 -0
- package/src/components/database/ImportBroadcastify.ts +60 -0
- package/src/components/database/ImportCities.ts +87 -0
- package/src/{@modules/@database/database.shapefiles.ts → components/database/ImportShapefiles.ts} +31 -37
- package/src/components/database/ImportStanza.ts +43 -0
- package/src/components/database/InitializeDatabase.ts +71 -0
- package/src/components/images/GenerateGraphic.ts +234 -0
- package/src/components/images/components/CreateRectangle.ts +22 -0
- package/src/components/images/components/CreateText.ts +22 -0
- package/src/components/images/modules/CreateSVG.ts +37 -0
- package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
- package/src/components/images/modules/GetGeographicalCities.ts +58 -0
- package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
- package/src/components/images/modules/GetGeometryBounds.ts +82 -0
- package/src/components/images/modules/GetParsedBoundary.ts +58 -0
- package/src/components/images/modules/GetSVGPath.ts +53 -0
- package/src/components/images/modules/NormalizePolygon.ts +57 -0
- package/src/{@modules/@stanza/stanza.getAwipsType.ts → components/stanza/GetAwipsType.ts} +19 -18
- package/src/components/stanza/ValidateStanza.ts +62 -0
- package/src/components/utilities/CreateHttp.ts +83 -0
- package/src/{@modules/@utilities/utilities.getFormattedTime.ts → components/utilities/GetFormattedTime.ts} +3 -3
- package/src/components/utilities/GetLatestIssuance.ts +32 -0
- package/src/components/utilities/GetMatched.ts +38 -0
- package/src/{@modules/@utilities/utilities.getShapeNearestPoint.ts → components/utilities/GetShapeNearestPoint.ts} +24 -19
- package/src/components/utilities/GetUnionPolygon.ts +36 -0
- package/src/components/utilities/QueueManager.ts +70 -0
- package/src/components/utilities/SetCronSchedule.ts +98 -0
- package/src/{@core/core.clearEvents.ts → components/utilities/SetDebug.ts} +17 -12
- package/src/components/utilities/SetEventEmit.ts +42 -0
- package/src/{@modules/@utilities/utilities.setSettings.ts → components/utilities/SetSettings.ts} +7 -7
- package/src/{@modules/@utilities/utilities.setSleep.ts → components/utilities/SetSleep.ts} +5 -5
- package/src/components/utilities/SetTimeoutAction.ts +64 -0
- package/src/components/utilities/SetWarning.ts +47 -0
- package/src/{@modules/@xmpp/xmpp.xDeploy.ts → components/xmpp/DeployXMPP.ts} +26 -27
- package/src/components/xmpp/ErrorXMPP.ts +27 -0
- package/src/{@modules/@xmpp/xmpp.xError.ts → components/xmpp/OfflineXMPP.ts} +17 -9
- package/src/{@modules/@xmpp/xmpp.xOnline.ts → components/xmpp/OnlineXMPP.ts} +21 -20
- package/src/components/xmpp/ReconnectXMPP.ts +64 -0
- package/src/components/xmpp/StanzaXMPP.ts +63 -0
- package/src/{@building/building.tags.ts → core/ClearEvents.ts} +12 -5
- package/src/{@core/core.getVersion.ts → core/GetEvents.ts} +5 -6
- package/src/core/GetNodes.ts +24 -0
- package/src/{@core/core.getNodes.ts → core/GetRandomEvent.ts} +5 -6
- package/src/core/GetVersion.ts +24 -0
- package/src/core/ManualEvent.ts +55 -0
- package/src/core/QueryStanza.ts +40 -0
- package/src/core/SetNode.ts +87 -0
- package/src/core/StartService.ts +62 -0
- package/src/core/StopService.ts +32 -0
- package/src/enums/AWIPS.ts +366 -0
- package/src/{@dictionaries/dictionaries.eventActions.ts → enums/Actions.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventCancelMessages.ts → enums/Cancellation.ts} +4 -3
- package/src/{@dictionaries/dictionaries.eventCauses.ts → enums/Causes.ts} +3 -3
- package/src/{@dictionaries/dictionaries.statusCorrelationText.ts → enums/Correlations.ts} +3 -3
- package/src/enums/Enhanced.ts +70 -0
- package/src/{@dictionaries/dictionaries.eventTypes.ts → enums/Events.ts} +3 -3
- package/src/{@dictionaries/dictionaries.regExp.ts → enums/Expressions.ts} +5 -4
- package/src/{@core/core.getEvents.ts → enums/GlobalFilter.ts} +7 -8
- package/src/{@dictionaries/dictionaries.hailStrings.ts → enums/Hail.ts} +9 -4
- package/src/{@dictionaries/dictionaries.officeICAOs.ts → enums/ICAO.ts} +5 -3
- package/src/enums/Matches.ts +60 -0
- package/src/{@dictionaries/dictionaries.eventProducts.ts → enums/Products.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventRecords.ts → enums/Records.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventSeverity.ts → enums/Severity.ts} +3 -3
- package/src/{@dictionaries/dictionaries.shapefileLinks.ts → enums/Shapefiles.ts} +3 -3
- package/src/enums/States.ts +136 -0
- package/src/{@dictionaries/dictionaries.eventStatus.ts → enums/Status.ts} +3 -3
- package/src/enums/Strings.ts +22 -0
- package/src/enums/Tags.ts +172 -0
- package/src/{@dictionaries/dictionaries.testSignatures.ts → enums/Testing.ts} +5 -4
- package/src/enums/Themes.ts +70 -0
- package/src/events/ParseAPI.ts +129 -0
- package/src/{@events/events.text.ts → events/ParseText.ts} +32 -23
- package/src/{@events/events.ugc.ts → events/ParseUGC.ts} +36 -26
- package/src/events/ParseVTEC.ts +88 -0
- package/src/index.ts +60 -38
- package/src/manager/MakeEvents.ts +110 -0
- package/src/manager/RemoveEvent.ts +74 -0
- package/src/{@manager/manager.setHash.ts → manager/SetHash.ts} +19 -15
- package/src/manager/UpdateEvents.ts +35 -0
- package/src/manager/UpdateNode.ts +62 -0
- package/src/manager/ValidateEvents.ts +144 -0
- package/src/{@parsers/@hvtec/hvtec.extract.ts → parsers/hvtec/HVExtract.ts} +13 -13
- package/src/parsers/text/GetDescriptionFromProduct.ts +59 -0
- package/src/parsers/text/GetEmbededText.ts +57 -0
- package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
- package/src/parsers/text/GetStringText.ts +58 -0
- package/src/{@parsers/@text/text.getTextFromProduct.ts → parsers/text/GetTextFromProduct.ts} +12 -12
- package/src/parsers/ugc/GetCache.ts +24 -0
- package/src/{@parsers/@ugc/ugc.expiry.ts → parsers/ugc/GetExpiry.ts} +3 -3
- package/src/{@parsers/@ugc/ugc.header.ts → parsers/ugc/GetHeader.ts} +6 -6
- package/src/parsers/ugc/GetLocations.ts +57 -0
- package/src/parsers/ugc/GetZonePolygon.ts +73 -0
- package/src/{@parsers/@ugc/ugc.zones.ts → parsers/ugc/GetZones.ts} +3 -3
- package/src/{@modules/@utilities/utilities.setListener.ts → parsers/ugc/SetCache.ts} +13 -10
- package/src/{@parsers/@ugc/ugc.extract.ts → parsers/ugc/UGCExtract.ts} +15 -15
- package/src/{@parsers/@pvtec/pvtec.expires.ts → parsers/vtec/GetExpiry.ts} +3 -3
- package/src/parsers/vtec/VTECExtract.ts +49 -0
- package/src/{@types/types.attributes.ts → static/Attributes.ts} +2 -3
- package/src/{@types/type.event.ts → static/Event.ts} +11 -8
- package/src/{@types/type.properties.ts → static/Properties.ts} +17 -10
- package/src/{@types/types.stanza.ts → static/Stanza.ts} +2 -2
- package/src/tasks/CreateTasks.ts +123 -0
- package/src/{@core/core.stop.ts → tasks/TaskGenerateJSON.ts} +14 -12
- package/src/tasks/TaskGenerateText.ts +34 -0
- package/src/tasks/TaskSendNTFY.ts +97 -0
- package/src/tasks/TaskSendWebhook.ts +107 -0
- package/src/types/Actions.ts +37 -0
- package/src/{@types/types.hvtec.ts → types/HVTEC.ts} +6 -6
- package/src/{@types/types.hash.ts → types/Hash.ts} +5 -5
- package/src/types/Nodes.ts +29 -0
- package/src/{@types/types.settings.ts → types/Settings.ts} +42 -10
- package/src/{@types/types.compiled.ts → types/StanzaCompiled.ts} +15 -14
- package/src/{@types/types.ugc.ts → types/UGC.ts} +5 -5
- package/src/{@modules/@utilities/utilities.getSettings.ts → types/VTEC.ts} +12 -7
- package/tools/build.js +47 -0
- package/tsconfig.json +28 -1
- package/dist/index.d.mts +0 -239
- package/dist/index.d.ts +0 -239
- package/src/@building/building.create.ts +0 -42
- package/src/@building/building.properties.ts +0 -89
- package/src/@building/building.tracking.ts +0 -68
- package/src/@building/building.validate.ts +0 -147
- package/src/@core/core.getRandomEvent.ts +0 -25
- package/src/@core/core.setNode.ts +0 -81
- package/src/@core/core.start.ts +0 -61
- package/src/@dictionaries/dictionaries.betterEventNames.ts +0 -99
- package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +0 -364
- package/src/@dictionaries/dictionaries.eventTags.ts +0 -93
- package/src/@dictionaries/dictionaries.eventsMatchText.ts +0 -36
- package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
- package/src/@events/events.api.ts +0 -113
- package/src/@events/events.vtec.ts +0 -87
- package/src/@manager/manager.mkEvent.ts +0 -96
- package/src/@manager/manager.rmEvent.ts +0 -49
- package/src/@manager/manager.updateEvents.ts +0 -35
- package/src/@manager/manager.updateNodes.ts +0 -55
- package/src/@manager/manager.updateWebhooks.ts +0 -50
- package/src/@modules/@database/database.init.ts +0 -45
- package/src/@modules/@database/database.stanza.ts +0 -48
- package/src/@modules/@eas/eas.setEasTone.ts +0 -137
- package/src/@modules/@stanza/stanza.validate.ts +0 -50
- package/src/@modules/@utilities/utilities.createHttp.ts +0 -85
- package/src/@modules/@utilities/utilities.createWebhook.ts +0 -115
- package/src/@modules/@utilities/utilities.setCronSchedule.ts +0 -65
- package/src/@modules/@utilities/utilities.setEventEmit.ts +0 -41
- package/src/@modules/@utilities/utilities.setTimeoutAction.ts +0 -59
- package/src/@modules/@xmpp/xmpp.xOffline.ts +0 -38
- package/src/@modules/@xmpp/xmpp.xReconnect.ts +0 -64
- package/src/@modules/@xmpp/xmpp.xStanza.ts +0 -63
- package/src/@parsers/@pvtec/pvtec.extract.ts +0 -49
- package/src/@parsers/@text/text.getDescriptionFromProduct.ts +0 -53
- package/src/@parsers/@text/text.getPolygonFromProduct.ts +0 -32
- package/src/@parsers/@text/text.getXML.ts +0 -61
- package/src/@parsers/@ugc/ugc.coordinates.ts +0 -110
- package/src/@parsers/@ugc/ugc.locations.ts +0 -29
- package/src/@types/types.pvtec.ts +0 -30
- package/src/@types/types.webhook.ts +0 -27
- package/test.js +0 -91
- package/tsup.config.ts +0 -16
- /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
- /package/{LICENSE → .github/LICENSE} +0 -0
- /package/{SECURITY.md → .github/SECURITY.md} +0 -0
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { createWebhook } from "../@modules/@utilities/utilities.createWebhook";
|
|
21
|
-
import { TypeEvent } from "../@types/type.event";
|
|
22
|
-
import { TypeWebhook } from "../@types/types.webhook";
|
|
23
|
-
import { bootstrap } from "../bootstrap"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export const updateWebhooks = async (event: TypeEvent): Promise<void> => {
|
|
27
|
-
const settings = bootstrap.settings;
|
|
28
|
-
const webhooks = settings.WebhookSettings as TypeWebhook[];
|
|
29
|
-
const eventName = event.properties.event;
|
|
30
|
-
for (const socket of webhooks) {
|
|
31
|
-
const events = socket.events;
|
|
32
|
-
if (!events || events.length === 0) {
|
|
33
|
-
await createWebhook({ webhook: socket, event });
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const matched = events.some(pattern => {
|
|
37
|
-
if (!pattern) return false;
|
|
38
|
-
if (pattern === "*" || pattern === eventName) return true;
|
|
39
|
-
if (pattern.includes("*")) {
|
|
40
|
-
const regex = "^" +
|
|
41
|
-
pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*") + "$";
|
|
42
|
-
return new RegExp(regex).test(eventName);
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
});
|
|
46
|
-
if (matched) {
|
|
47
|
-
await createWebhook({ webhook: socket, event });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import fs from 'fs'
|
|
21
|
-
import sqlite3 from 'better-sqlite3'
|
|
22
|
-
import { TypeSettings } from "../../@types/types.settings"
|
|
23
|
-
import { bootstrap } from "../../bootstrap"
|
|
24
|
-
import { setWarning } from '../@utilities/utilities.setWarning'
|
|
25
|
-
import { importShapefiles } from './database.shapefiles'
|
|
26
|
-
|
|
27
|
-
export const initializeDatabase = async (): Promise<void> => {
|
|
28
|
-
const settings = bootstrap.settings as TypeSettings;
|
|
29
|
-
try {
|
|
30
|
-
if (!fs.existsSync(settings.Database)) {
|
|
31
|
-
fs.writeFileSync(settings.Database, '')
|
|
32
|
-
setWarning({ message: `Creating new database at ${settings.Database}` })
|
|
33
|
-
}
|
|
34
|
-
bootstrap.database = new sqlite3(settings.Database);
|
|
35
|
-
bootstrap.database
|
|
36
|
-
.prepare(`CREATE TABLE IF NOT EXISTS stanzas ( id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, issued TEXT, stanza TEXT )`)
|
|
37
|
-
.run();
|
|
38
|
-
bootstrap.database
|
|
39
|
-
.prepare(`CREATE TABLE IF NOT EXISTS shapefiles (id TEXT PRIMARY KEY, location TEXT, geometry TEXT)`)
|
|
40
|
-
.run();
|
|
41
|
-
await importShapefiles();
|
|
42
|
-
} catch (error) {
|
|
43
|
-
setWarning({ message: `An error occurred while initializing the database: ${error.message}` })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import { bootstrap } from '../../bootstrap'
|
|
22
|
-
import { setWarning } from '../@utilities/utilities.setWarning';
|
|
23
|
-
import { TypeSettings } from "../../@types/types.settings"
|
|
24
|
-
import { TypeStanzaCompiled } from '../../@types/types.compiled';
|
|
25
|
-
|
|
26
|
-
export const importStanza = async (stanza: TypeStanzaCompiled): Promise<void> => {
|
|
27
|
-
const settings = bootstrap.settings as TypeSettings;
|
|
28
|
-
try {
|
|
29
|
-
if (!settings.NOAAWeatherWireServiceSettings.CacheSettings.Enabled) { return }
|
|
30
|
-
bootstrap.database
|
|
31
|
-
.prepare(`INSERT OR IGNORE INTO stanzas (type, stanza, issued) VALUES (?, ?, ?)`)
|
|
32
|
-
.run(stanza.getType.type, JSON.stringify(stanza), stanza.attributes.issue)
|
|
33
|
-
const count = bootstrap.database
|
|
34
|
-
.prepare(`SELECT COUNT(*) as total FROM stanzas`)
|
|
35
|
-
.get() as { total: number }
|
|
36
|
-
const max = settings.NOAAWeatherWireServiceSettings.CacheSettings.MaxDatabaseHistory;
|
|
37
|
-
if (count.total > max) {
|
|
38
|
-
const toDelete = count.total - max;
|
|
39
|
-
if (toDelete > 0) {
|
|
40
|
-
bootstrap.database
|
|
41
|
-
.prepare(`DELETE FROM stanzas WHERE id IN (SELECT id FROM stanzas ORDER BY issued ASC LIMIT ?)`)
|
|
42
|
-
.run(toDelete);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
} catch (error) {
|
|
46
|
-
setWarning({ message: `An error occurred while importing stanza: ${error.message}` })
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { TypeSettings } from "../../@types/types.settings";
|
|
21
|
-
import { transcribedMessageReplacements } from "../../@dictionaries/dictionaries.transcribedMessageReplacements";
|
|
22
|
-
import { bootstrap } from "../../bootstrap";
|
|
23
|
-
import { setSleep } from "../@utilities/utilities.setSleep"
|
|
24
|
-
import { getWavPCM16 } from "./eas.getWavPCM16";
|
|
25
|
-
import { getSampledPCM16 } from "./eas.getSampledPCM16";
|
|
26
|
-
import { setRadioEffect } from "./eas.setRadioEffect";
|
|
27
|
-
import { setSameHeader } from "./eas.setSameHeader";
|
|
28
|
-
import { setAttentionTone } from "./eas.setAttentionTone";
|
|
29
|
-
import { getMergedPCM16 } from "./eas.getMergedPCM16";
|
|
30
|
-
import { setNoise } from "./eas.setNoise";
|
|
31
|
-
import { getPCM16 } from "./eas.getPCM16";
|
|
32
|
-
import { join } from 'path'
|
|
33
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from 'fs'
|
|
34
|
-
import { execSync } from 'child_process'
|
|
35
|
-
import { platform } from 'os'
|
|
36
|
-
import { setWarning } from "../@utilities/utilities.setWarning";
|
|
37
|
-
import say from 'say'
|
|
38
|
-
|
|
39
|
-
interface GenerateEASOptions {
|
|
40
|
-
message: string
|
|
41
|
-
header: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const setEasTone = async (options: GenerateEASOptions): Promise<string> => {
|
|
45
|
-
const settings = bootstrap.settings as TypeSettings;
|
|
46
|
-
const directory = settings.GlobalSettings.EASSettings.ArchiveDirectory;
|
|
47
|
-
const prefix = settings.GlobalSettings.EASSettings.IntroWavFile;
|
|
48
|
-
let message = options.message;
|
|
49
|
-
let header = options.header;
|
|
50
|
-
let buffTTS: Buffer;
|
|
51
|
-
let buffRadio: any;
|
|
52
|
-
let buffFull: any[] = [];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const tmpTTS = join(directory, `/temp/${Math.random().toString(36).substring(2, 15)}-${header.replace(/[^a-zA-Z0-9]/g, '')}.wav`)
|
|
56
|
-
const outTTS = join(directory, `/output/${Math.random().toString(36).substring(2, 15)}-${header.replace(/[^a-zA-Z0-9]/g, '')}.wav`)
|
|
57
|
-
const vTTS = process.platform === `win32` ? `Microsoft David Desktop` : `en-US-GuyNerual`;
|
|
58
|
-
const vPlatform = platform();
|
|
59
|
-
|
|
60
|
-
if (!existsSync(directory)) {
|
|
61
|
-
mkdirSync(directory, { recursive: true });
|
|
62
|
-
}
|
|
63
|
-
if (!existsSync(join(directory, `/temp`))) {
|
|
64
|
-
mkdirSync(join(directory, `/temp`), { recursive: true });
|
|
65
|
-
}
|
|
66
|
-
if (!existsSync(join(directory, `/output`))) {
|
|
67
|
-
mkdirSync(join(directory, `/output`), { recursive: true });
|
|
68
|
-
}
|
|
69
|
-
for (const {regex, replacement} of transcribedMessageReplacements) {
|
|
70
|
-
message = message.replace(regex, replacement)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (vPlatform != `win32`) {
|
|
74
|
-
setWarning({
|
|
75
|
-
title: `EAS`,
|
|
76
|
-
message: `Generation isn't supported with this OS. Please wait for further updates before trying again`
|
|
77
|
-
})
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
say.export(message, vTTS, 1.0, tmpTTS)
|
|
82
|
-
while (!existsSync(tmpTTS) || (buffTTS = readFileSync(tmpTTS)).length == 0) {
|
|
83
|
-
await setSleep({timeout: 25});
|
|
84
|
-
}
|
|
85
|
-
const vWav = getWavPCM16(buffTTS);
|
|
86
|
-
const vSamples = getSampledPCM16(vWav.samples, vWav.sampleRate, 8000)
|
|
87
|
-
const vRadio = setRadioEffect(vSamples, 8000)
|
|
88
|
-
|
|
89
|
-
if (existsSync(prefix)) {
|
|
90
|
-
let tBuffer = readFileSync(prefix);
|
|
91
|
-
let tWav = getWavPCM16(tBuffer);
|
|
92
|
-
|
|
93
|
-
if (tWav == null) {
|
|
94
|
-
try {
|
|
95
|
-
const converted = join(directory, `/temp/${Math.random().toString(36).substring(2, 15)}.converted.wav`)
|
|
96
|
-
execSync(`ffmpeg -y -i "${prefix}" -ar 8000 -ac 1 -sample_fmt s16 "${converted}"`, { stdio: 'ignore' })
|
|
97
|
-
if (existsSync(converted)) {
|
|
98
|
-
tBuffer = readFileSync(converted)
|
|
99
|
-
tWav = getWavPCM16(tBuffer)
|
|
100
|
-
try { unlinkSync(converted) } catch {}
|
|
101
|
-
}
|
|
102
|
-
} catch (e) {}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (tWav == null) {
|
|
106
|
-
setWarning({ title: `EAS`, message: `Intro tone isn't a valid .WAV file or isn't in PCM 16-bit format. Converted attempt failed; please convert it then try again.` })
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const tSamples = (tWav.sampleRate != 8000 ? getSampledPCM16(tWav.samples, tWav.sampleRate, 8000) : tWav.samples)
|
|
111
|
-
buffRadio = setRadioEffect(tSamples, 8000)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
buffFull = buffRadio != null ? [buffRadio, new Int16Array(Math.floor(0.5 * 8000))] : [];
|
|
115
|
-
buffFull.push(
|
|
116
|
-
setSameHeader(header, 3, 8000, {
|
|
117
|
-
preMarkSec: 1.1,
|
|
118
|
-
gapSec: 0.5,
|
|
119
|
-
}),
|
|
120
|
-
new Int16Array(Math.floor(0.5 * 8000)),
|
|
121
|
-
setAttentionTone(8, 8000),
|
|
122
|
-
new Int16Array(Math.floor(0.5 * 8000)),
|
|
123
|
-
vRadio
|
|
124
|
-
)
|
|
125
|
-
for (let i = 0; i < 3; i++) {
|
|
126
|
-
buffFull.push(setSameHeader(header, 1, 8000, { preMarkSec: 0.5, gapSec: 0.1 }))
|
|
127
|
-
buffFull.push(new Int16Array(Math.floor(0.5 * 8000)));
|
|
128
|
-
}
|
|
129
|
-
const aSamples = getMergedPCM16(buffFull);
|
|
130
|
-
const aFinal = setNoise(aSamples, 0.002);
|
|
131
|
-
const aBuffer = getPCM16(Array.from(aFinal).map(v => ({ value: v })), 8000);
|
|
132
|
-
writeFileSync(outTTS, aBuffer)
|
|
133
|
-
try{unlinkSync(tmpTTS)} catch {}
|
|
134
|
-
return outTTS;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { TypeStanza } from "../../@types/types.stanza"
|
|
21
|
-
import { TypeStanzaCompiled } from "../../@types/types.compiled"
|
|
22
|
-
import { regExp } from "../../@dictionaries/dictionaries.regExp"
|
|
23
|
-
import { getAwipsType } from "./stanza.getAwipsType"
|
|
24
|
-
|
|
25
|
-
interface ValidateOptions {
|
|
26
|
-
stanza: TypeStanza
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const validate = (options: ValidateOptions): TypeStanzaCompiled => {
|
|
30
|
-
if (options.stanza.is(`message`)) {
|
|
31
|
-
const cb = options.stanza.getChild(`x`) as TypeStanza;
|
|
32
|
-
if (cb && cb.children) {
|
|
33
|
-
const message = unescape(cb.children[0]);
|
|
34
|
-
const attributes = cb.attrs;
|
|
35
|
-
if (attributes.awipsid && attributes.awipsid.length > 1) {
|
|
36
|
-
const isCapEvent = message.includes(`<?xml`);
|
|
37
|
-
const isCapAreaDescription = message.includes(`<areaDesc>`)
|
|
38
|
-
const isVTEC = message.match(regExp.pvtec) != null;
|
|
39
|
-
const isUGC = message.match(regExp.ugc1) != null;
|
|
40
|
-
const getType = getAwipsType({ attributes: attributes})
|
|
41
|
-
if (getType.type != null) {
|
|
42
|
-
return {
|
|
43
|
-
message, attributes, isCapEvent, isVTEC, isUGC, isCapAreaDescription, isIgnored: false, isNWWS: true, getType
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return { isIgnored: true}
|
|
50
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import request from 'request'
|
|
21
|
-
|
|
22
|
-
interface CreateHttpOptions {
|
|
23
|
-
proxy?: string
|
|
24
|
-
url: string
|
|
25
|
-
headers?: any
|
|
26
|
-
timeout?: number
|
|
27
|
-
method?: `GET` | `POST` | `PUT` | `DELETE`
|
|
28
|
-
body?: any;
|
|
29
|
-
formData?: any;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const createHttp = async (options: CreateHttpOptions): Promise<any> => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
const requestOptions = {
|
|
35
|
-
url: options.url ?? `https://api.weather.gov/alerts/active`,
|
|
36
|
-
headers: options.headers ?? {
|
|
37
|
-
"User-Agent": "AtmosphericX",
|
|
38
|
-
"Accept": "application/geo+json, text/plain, */*; q=0.9",
|
|
39
|
-
"Accept-Language": "en-US,en;q=0.9"
|
|
40
|
-
},
|
|
41
|
-
method: options.method ?? `GET`,
|
|
42
|
-
timeout: options.timeout ?? 10e3,
|
|
43
|
-
proxy: options.proxy ?? null,
|
|
44
|
-
maxRedirects: 1,
|
|
45
|
-
};
|
|
46
|
-
if (options.formData) {
|
|
47
|
-
requestOptions['formData'] = options.formData;
|
|
48
|
-
} else if (options.body) {
|
|
49
|
-
requestOptions['body'] = options.body;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
request(requestOptions, (error, response, body) => {
|
|
53
|
-
if (error) {
|
|
54
|
-
return resolve({
|
|
55
|
-
error: true,
|
|
56
|
-
options: requestOptions,
|
|
57
|
-
status: -1,
|
|
58
|
-
message: error.message ?? `Unknown Error`
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
62
|
-
return resolve({
|
|
63
|
-
error: true,
|
|
64
|
-
options: requestOptions,
|
|
65
|
-
status: response.statusCode ?? -1,
|
|
66
|
-
message: `HTTP Status Code ${response.statusCode ?? `Unknown Status Code`} (${body})`
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
if (body == undefined || body == null) {
|
|
70
|
-
return resolve({
|
|
71
|
-
error: true,
|
|
72
|
-
options: requestOptions,
|
|
73
|
-
status: response.statusCode ?? -1,
|
|
74
|
-
message: `Empty Response Body`
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
resolve({
|
|
78
|
-
error: false,
|
|
79
|
-
options: requestOptions,
|
|
80
|
-
status: response.statusCode ?? -1,
|
|
81
|
-
message: body
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { TypeEvent } from "../../@types/type.event";
|
|
21
|
-
import { setTimeoutAction } from "./utilities.setTimeoutAction"
|
|
22
|
-
import { createHttp } from "./utilities.createHttp"
|
|
23
|
-
import { TypeWebhook } from "../../@types/types.webhook";
|
|
24
|
-
import { getCleanedEvent } from "../../@building/building.clean";
|
|
25
|
-
import FormData from "form-data";
|
|
26
|
-
|
|
27
|
-
interface CreateWebhookOptions {
|
|
28
|
-
webhook: TypeWebhook
|
|
29
|
-
event: TypeEvent
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const createWebhook = async (options: CreateWebhookOptions): Promise<void> => {
|
|
33
|
-
const event = options.event.properties;
|
|
34
|
-
const settings = options.webhook;
|
|
35
|
-
|
|
36
|
-
let body = [
|
|
37
|
-
event.locations ? `**Locations**: ${event.locations.slice(0,100)}` : null,
|
|
38
|
-
event.issued ? `**Issued**: <t:${Math.floor(new Date(event.issued).getTime()/1000)}:R>` : null,
|
|
39
|
-
event.expires && event.status != `Statement` ? `**Expires**: <t:${Math.floor(new Date(event.expires).getTime()/1000)}:R>` : null,
|
|
40
|
-
(() => {
|
|
41
|
-
const val = event.parameters.estimated_wind_gusts ?? null
|
|
42
|
-
const th = event.parameters.wind_threat ?? null
|
|
43
|
-
const combined = [val, th].filter(Boolean).join(' ');
|
|
44
|
-
return combined ? `**Wind Gusts**: ${val} ${th ? `(${th})` : ''}` : null;
|
|
45
|
-
})(),
|
|
46
|
-
(() => {
|
|
47
|
-
const val = event.parameters.estimated_hail_size ?? null
|
|
48
|
-
const th = event.parameters.hail_threat ?? null
|
|
49
|
-
return (val || th) ? `**Hail Threat**: ${val} ${th ? `(${th})` : ''}` : null;
|
|
50
|
-
})(),
|
|
51
|
-
event.parameters.damage_threat ? `**Damage Threat**: ${event.parameters.damage_threat}` : null,
|
|
52
|
-
event.parameters.flood_threat ? `**Flood Threat**: ${event.parameters.flood_threat}` : null,
|
|
53
|
-
event.parameters.tornado_threat ? `**Tornado Threat**: ${event.parameters.tornado_threat}` : null,
|
|
54
|
-
event.spc_parameters.spc_max_tornado ? `**Max Tornado Threat**: ${event.spc_parameters.spc_max_tornado}` : null,
|
|
55
|
-
event.spc_parameters.spc_max_hail ? `**Max Hail Threat**: ${event.spc_parameters.spc_max_hail}` : null,
|
|
56
|
-
event.spc_parameters.spc_max_wind ? `**Max Wind Threat**: ${event.spc_parameters.spc_max_wind}` : null,
|
|
57
|
-
event.spc_parameters.spc_watch_issuance ? `**Watch Issuance**: ${event.spc_parameters.spc_watch_issuance}%` : null,
|
|
58
|
-
event.watch_parameters.watch_number ? `**Watch Number**: ${event.watch_parameters.watch_number}` : null,
|
|
59
|
-
event.watch_parameters.strong_tornadoes_probability ? `**Strong Tornadoes Probability**: ${event.watch_parameters.strong_tornadoes_probability}%` : null,
|
|
60
|
-
event.watch_parameters.additional_tornadoes_probability ? `**Additional Tornadoes Probability**: ${event.watch_parameters.additional_tornadoes_probability}%` : null,
|
|
61
|
-
event.watch_parameters.combined_hail_wind_probability ? `**Combined Hail/Wind Probability**: ${event.watch_parameters.combined_hail_wind_probability}%` : null,
|
|
62
|
-
event.watch_parameters.severe_hail_probability ? `**Severe Hail Probability**: ${event.watch_parameters.severe_hail_probability}%` : null,
|
|
63
|
-
event.watch_parameters.hail_2in_probability ? `**Hail ≥2in Probability**: ${event.watch_parameters.hail_2in_probability}%` : null,
|
|
64
|
-
event.watch_parameters.max_hail_in ? `**Max Hail Inches**: ${event.watch_parameters.max_hail_in}` : null,
|
|
65
|
-
event.watch_parameters.severe_wind_probability ? `**Severe Wind Probability**: ${event.watch_parameters.severe_wind_probability}%` : null,
|
|
66
|
-
event.watch_parameters.max_wind_surface ? `**Max Surface Wind**: ${event.watch_parameters.max_wind_surface}` : null,
|
|
67
|
-
event.watch_parameters.max_tops_x100feet ? `**Max Tops (x100 feet)**: ${event.watch_parameters.max_tops_x100feet}` : null,
|
|
68
|
-
(event.parameters.tags?.length > 0) ? `**Tags**: ${event.parameters.tags.join(', ')}` : null,
|
|
69
|
-
(() => {
|
|
70
|
-
const val = event.geocode?.office?.name ?? `N/A`
|
|
71
|
-
const th = event.geocode?.office?.office ?? null
|
|
72
|
-
return (val || th) ? `**Sender**: ${val} ${th ? `(${th})` : ''}` : null;
|
|
73
|
-
})(),
|
|
74
|
-
event.metadata?.tracking ? `**Tracking**: ${event.metadata.tracking}` : null,
|
|
75
|
-
(() => {
|
|
76
|
-
const desc = (event.description || '').split('\n').map(l => l.trim()).filter(Boolean).join('\n');
|
|
77
|
-
return desc ? '```' + '\n' + desc + '\n' + '```' : null;
|
|
78
|
-
})(),
|
|
79
|
-
].filter(Boolean).join('\n');
|
|
80
|
-
|
|
81
|
-
const isLimited = setTimeoutAction({ identifier: options.webhook.webhook, interval: options.webhook.rate, max: options.webhook.rate, addTime: true })
|
|
82
|
-
if (isLimited.limited) { return }
|
|
83
|
-
|
|
84
|
-
if (body.length > 1900) {
|
|
85
|
-
body = body.substring(0, 1900) + "\n\n[Message truncated due to length]";
|
|
86
|
-
const blocks = (body.match(/```/g) || []).length;
|
|
87
|
-
if (blocks % 2 !== 0) body += "```";
|
|
88
|
-
}
|
|
89
|
-
const form = new FormData();
|
|
90
|
-
const embed = {
|
|
91
|
-
title: `${event.event} (${event.status})`,
|
|
92
|
-
description: body,
|
|
93
|
-
color: 16711680,
|
|
94
|
-
timestamp: new Date().toISOString(),
|
|
95
|
-
footer: { text: settings.title }
|
|
96
|
-
};
|
|
97
|
-
form.append("payload_json", JSON.stringify({
|
|
98
|
-
username: settings.title ?? "AtmosphericX",
|
|
99
|
-
content: settings.message ?? "",
|
|
100
|
-
embeds: [embed]
|
|
101
|
-
}));
|
|
102
|
-
if (settings.upload) {
|
|
103
|
-
form.append("file", Buffer.from(JSON.stringify((getCleanedEvent(event)), null, 2)), {
|
|
104
|
-
filename: `${event.event}_${event.status}_${event.metadata.tracking}.json`,
|
|
105
|
-
contentType: "application/json"
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
await createHttp({
|
|
109
|
-
url: settings.webhook,
|
|
110
|
-
timeout: 2000,
|
|
111
|
-
method: `POST`,
|
|
112
|
-
headers: form.getHeaders(),
|
|
113
|
-
body: form
|
|
114
|
-
})
|
|
115
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import { TypeSettings } from "../../@types/types.settings";
|
|
22
|
-
import { xReconnect } from "../@xmpp/xmpp.xReconnect"
|
|
23
|
-
import { bootstrap } from "../../bootstrap";
|
|
24
|
-
import { createHttp } from "./utilities.createHttp";
|
|
25
|
-
import { createEvent } from "../../@building/building.create";
|
|
26
|
-
import { setEventEmit } from "./utilities.setEventEmit";
|
|
27
|
-
|
|
28
|
-
export const setCronSchedule = async (): Promise<void> => {
|
|
29
|
-
const settings = bootstrap.settings as TypeSettings;
|
|
30
|
-
if (settings.EnableWireService) {
|
|
31
|
-
if (settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.Enabled) {
|
|
32
|
-
void xReconnect(settings.NOAAWeatherWireServiceSettings.ReconnectionSettings.ReconnectionInterval)
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
const response = await createHttp({
|
|
36
|
-
url: settings.NationalWeatherServiceSettings.EventsEndpoint,
|
|
37
|
-
headers: {
|
|
38
|
-
"User-Agent": "@atmosx/event-product-parser"
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
if (response.error) {
|
|
42
|
-
return setEventEmit({
|
|
43
|
-
event: `onServiceStatus`,
|
|
44
|
-
metadata: {
|
|
45
|
-
type: "fetch-api",
|
|
46
|
-
message: `Failed to fetch latest events from National Weather Service API - ${response.message}`,
|
|
47
|
-
data: {},
|
|
48
|
-
error: true
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
setEventEmit({
|
|
53
|
-
event: `onServiceStatus`,
|
|
54
|
-
metadata: {
|
|
55
|
-
message: `Fetched latest events from National Weather Service API`,
|
|
56
|
-
data: {},
|
|
57
|
-
type: "fetch-api",
|
|
58
|
-
error: false
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
createEvent({ message: response.message, isNWWS: false })
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
-
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
-
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
-
|
|
16
|
-
Internal Package: @atmosx/event-product-parser
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { bootstrap } from "../../bootstrap"
|
|
21
|
-
import { setTimeoutAction } from "./utilities.setTimeoutAction";
|
|
22
|
-
import { setWarning } from "./utilities.setWarning";
|
|
23
|
-
|
|
24
|
-
interface SetEventEmitOptions {
|
|
25
|
-
event: string
|
|
26
|
-
metadata: any
|
|
27
|
-
message?: string
|
|
28
|
-
limited?: boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const setEventEmit = (options: SetEventEmitOptions): void => {
|
|
32
|
-
if (options.limited) {
|
|
33
|
-
const isTimeout = setTimeoutAction({ identifier: `event.${options.event}`, addTime: true, max: 1, interval: 1 })
|
|
34
|
-
if (isTimeout.limited) return;
|
|
35
|
-
}
|
|
36
|
-
bootstrap.listener.emit(options.event, options.metadata)
|
|
37
|
-
if (options.event != `log`) { bootstrap.listener.emit(`*`, {event: options.event, data: options.metadata}) }
|
|
38
|
-
if (options.message) {
|
|
39
|
-
setWarning({ message: options.message })
|
|
40
|
-
}
|
|
41
|
-
}
|