Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config_clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ config.wwff = {
listUrl: 'http://wwff.co/wwff-data/wwff_directory.csv'
};

config.wwbota = {
spotsUrl: 'https://api.wwbota.org/spots/?age=0',
listUrl: 'https://wwbota.org/wwbota-3',
};

config.mongodb = {
url: 'mongodb://hamalert:<redacted>@localhost:27017/hamalert',
dbName: 'hamalert'
Expand Down
3 changes: 3 additions & 0 deletions hamutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ exports.makeSpotParams = function(spot, comment, actions) {
wwffRef: spot.wwffRef,
wwffDivision: spot.wwffDivision,
wwffName: spot.wwffName,
wwbotaRef: spot.wwbotaRef,
wwbotaScheme: spot.wwbotaScheme,
wwbotaName: spot.wwbotaName,
iotaGroupRef: spot.iotaGroupRef,
iotaGroupName: spot.iotaGroupName
};
Expand Down
8 changes: 8 additions & 0 deletions notify/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ class EmailNotifier extends Notifier {
text += `Park name: ${spot.wwffName}\n`;
}
}

if (spot.wwbotaRef) {
text += "\n";
text += `Bunker ref: ${spot.wwbotaRef}\n`;
if (spot.wwbotaName) {
text += `Bunker name: ${spot.wwbotaName}\n`;
}
}

if (spot.iotaGroupRef) {
text += "\n";
Expand Down
3 changes: 3 additions & 0 deletions notify/telnetconn.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class TelnetConnection extends EventEmitter {
if (spot.wwffRef) {
commentElements.push(spot.wwffRef);
}
if (spot.wwbotaRef) {
commentElements.push(spot.wwbotaRef);
}
if (spot.iotaGroupRef) {
commentElements.push(spot.iotaGroupRef);
}
Expand Down
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"carrier": "^0.3.0",
"clone": "^2.1.2",
"csv": "^5.3.2",
"eventsource": "^4.0.0",
"expand-template": "^1.1.1",
"express": "^4.17.1",
"firebase-admin": "^13.4.0",
Expand Down
9 changes: 9 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const util = require('util');
const SotaSpotReceiver = require('./sotaspots');
const PotaSpotReceiver = require('./potaspots');
const WwbotaSpotReceiver = require('./wwbotaspots');
const RbnReceiver = require('./rbn');
const PskReporterReceiver = require('./pskreporter');
const ClusterReceiver = require('./cluster');
Expand Down Expand Up @@ -85,6 +86,10 @@ function startReceivers() {
let potaSpotReceiver = new PotaSpotReceiver(db);
potaSpotReceiver.on('spot', notifySpot);
potaSpotReceiver.start();

let wwbotaSpotReceiver = new WwbotaSpotReceiver(db);
wwbotaSpotReceiver.on('spot', notifySpot);
wwbotaSpotReceiver.start();

config.rbn.forEach(rbnConfig => {
let rbnReceiver = new RbnReceiver(rbnConfig);
Expand Down Expand Up @@ -163,6 +168,10 @@ function runMatcher(spot) {
if (spot.wwffDivision) {
conditions.wwffDivision = [spot.wwffDivision, "*"];
}

if (spot.wwbotaScheme) {
conditions.wwbotaScheme = [spot.wwbotaScheme, "*"];
}

if (spot.iotaGroupRef) {
conditions.iotaGroupRef = [spot.iotaGroupRef, "*"];
Expand Down
50 changes: 50 additions & 0 deletions tools/updateWwbotaBunkers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const request = require('request');
const axios = require('axios');
const MongoClient = require('mongodb').MongoClient;
const config = require('../config');
const assert = require('assert');
const parse = require('csv-parse');
const fs = require('fs');
const async = require('async');

let client = new MongoClient(config.mongodb.url)
client.connect((err) => {
assert.equal(null, err);
let db = client.db(config.mongodb.dbName);

processBunkersList(db);
});

function processBunkersList(db) {
let schemes = new Map();

request.get(config.wwbota.listUrl, {headers: {'User-Agent': 'Mozilla'}})
.on('error', (err) => {
callback(err);
return;
})
.pipe(parse({columns: true, relax_column_count: true, relax: true}, (err, newBunkers) => {
assert.equal(err, null);

if (newBunkers.length < 20000) {
callback(new Error("Bad number of WWBOTA bunkers, expecting more than 20000"));
return;
}

for (let bunker of newBunkers) {
if (bunker.Scheme) {
let scheme = bunker.Scheme.trim().toUpperCase()
let schemeData = schemes.get(scheme);
if (!scheme) {
schemeData = {scheme: scheme, dxcc: bunker.DXCC, program: 'wwbota'};
schemes.set(scheme, schemeData);
}
}
}

let schemesCollection = db.collection('wwbotaSchemes');
schemesCollection.deleteMany({});
schemesCollection.insertMany([...schemes.values()]);
client.close();
}));
}
87 changes: 87 additions & 0 deletions wwbotaspots.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const eventsource = require('eventsource');
const config = require('./config');
const EventEmitter = require('events');
const sprintf = require('sprintf');

class WwbotaSpotReceiver extends EventEmitter {
constructor(db) {
super();
this.db = db;
this.lastProcessedTime = null;
}

start() {
let es = new eventsource.EventSource(config.wwbota.spotsUrl,{
fetch: (input, init) =>
fetch(input, {
...init,
headers: {
...init.headers,
'User-Agent': 'HamAlert/1.0 (+https://hamalert.org)',
},
}),
});
es.addEventListener('message', (event) => this.processSpotEvent(event));
es.addEventListener('error', (error) => {
console.error(`Loading WWBOTA feed failed: ${error.responseCode}`)
})
}

processSpotEvent(spotEvent) {
try {
let jsonSpot = JSON.parse(spotEvent.data);
jsonSpot.time = new Date(jsonSpot.time);

// Ignore QRT/Test spots
if (jsonSpot.type !== "Live") {
return;
}

jsonSpot.call = jsonSpot.call.toUpperCase().replace(/\s/g, '');

if (jsonSpot.comment === null) {
jsonSpot.comment = "";
}

// Clean up frequency
let frequency = sprintf("%.4f", jsonSpot.freq);

let spot = {
source: 'wwbota',
time: jsonSpot.time.toISOString().substring(11, 16),
fullCallsign: jsonSpot.call,
wwbotaScheme: jsonSpot.references[0].scheme, // Multiple, but lets just take the first.
wwbotaRef: jsonSpot.references[0].reference,
wwbotaName: jsonSpot.references[0].name,
frequency,
mode: jsonSpot.mode.toLowerCase().trim(),
comment: jsonSpot.comment.trim(),
spotter: jsonSpot.spotter.toUpperCase().trim().replace('-#', '')
};

spot.rawText = `${spot.time} ${spot.fullCallsign} in ${spot.wwbotaRef} (${spot.wwbotaName}) ${spot.frequency}`;
if (spot.mode) {
spot.rawText += ` ${spot.mode.toUpperCase()}`;
}
if (spot.comment) {
spot.rawText += `: ${spot.comment}`;
}
spot.title = `WWBOTA ${spot.fullCallsign} in ${spot.wwbotaRef} (${spot.frequency}`;
if (spot.mode) {
spot.title += " " + spot.mode.toUpperCase();
}
spot.title += ")";

//console.log(spot);
this.emit("spot", spot);

} catch (e) {
console.error("Exception while processing WWBOTA spot", e);
}
}
}

let rec = new WwbotaSpotReceiver();
rec.start();

module.exports = WwbotaSpotReceiver;