13.diff (4017B)
1 diff --git a/handlers/parseNodes.js b/handlers/parseNodes.js 2 index 6e9d646..4fa3eef 100644 3 --- a/handlers/parseNodes.js 4 +++ b/handlers/parseNodes.js 5 @@ -157,21 +157,36 @@ module.exports = { 6 clients = key["statistics"]["clients"] 7 status = key["flags"]["online"] 8 since = key["firstseen"] 9 + lat = key["nodeinfo"]["location"]["latitude"] 10 + long = key["nodeinfo"]["location"]["longitude"] 11 + request.get('http://nominatim.openstreetmap.org/reverse?format=json&lat='+ lat + '&lon=' + lon + '&zoom=18&addressdetails=1', function (error, response, body) { 12 + if (!error && response.statusCode === 200) { 13 + addressJson = JSON.parse(body) 14 + _.find(addressJson.address, function (key) { 15 + house_number = key["house_number"] 16 + road = key["road"] 17 + town = key["town"] 18 + postcode = key["postcode"] 19 + country = key["country"] 20 + adress = road + " " + house_number + ", " + postcode + " " + town + ", " + country 21 + }); 22 + } 23 + }); 24 if(handler == "telegram"){ 25 - output = "<b>Name: </b>" + name + "\n<b>Router Model: </b>" + router + "\n<b>Firmware Version: </b>" + version + "\n<b>Autoupdater Status: </b>" + autoupdate + "\n<b>Autoupdater Branch: </b>" + autoupdateBranch + "\n<b>Clients Connected: </b>" + clients + "\n<b>Online Status: </b>" + status + "\n<b>First Seen: </b>" + since 26 + output = "<b>Name: </b>" + name + "\n<b>Router Location: </b>" + adress + "\n<b>Router Model: </b>" + router + "\n<b>Firmware Version: </b>" + version + "\n<b>Autoupdater Status: </b>" + autoupdate + "\n<b>Autoupdater Branch: </b>" + autoupdateBranch + "\n<b>Clients Connected: </b>" + clients + "\n<b>Online Status: </b>" + status + "\n<b>First Seen: </b>" + since 27 } 28 if(handler == "irc"){ 29 - output = "Name: " + name + "\nRouter Model: " + router + "\nFirmware Version: " + version + "\nAutoupdater Status: " + autoupdate + "\nAutoupdater Branch: " + autoupdateBranch + "\nClients Connected: " + clients + "\nOnline Status: " + status + "\nFirst Seen: " + since 30 + output = "Name: " + name + "\nRouter Location: " + adress + "\nRouter Model: " + router + "\nFirmware Version: " + version + "\nAutoupdater Status: " + autoupdate + "\nAutoupdater Branch: " + autoupdateBranch + "\nClients Connected: " + clients + "\nOnline Status: " + status + "\nFirst Seen: " + since 31 } 32 if(handler == "slack"){ 33 - output = "<b>Name: </b>" + name + "\n<b>Router Model: </b>" + router + "\n<b>Firmware Version: </b>" + version + "\n<b>Autoupdater Status: </b>" + autoupdate + "\n<b>Autoupdater Branch: </b>" + autoupdateBranch + "\n<b>Clients Connected: </b>" + clients + "\n<b>Online Status: </b>" + status + "\n<b>First Seen: </b>" + since 34 + output = "<b>Name: </b>" + name + "\n<b>Router Location: </b>" + adress + "\n<b>Router Model: </b>" + router + "\n<b>Firmware Version: </b>" + version + "\n<b>Autoupdater Status: </b>" + autoupdate + "\n<b>Autoupdater Branch: </b>" + autoupdateBranch + "\n<b>Clients Connected: </b>" + clients + "\n<b>Online Status: </b>" + status + "\n<b>First Seen: </b>" + since 35 } 36 } 37 }); 38 if (askedNode.toLowerCase() !== "noarg") { 39 if(handler == "telegram"){ 40 bot.sendMessage(TfromId, output, {"parse_mode": "HTML"}) 41 - botan.track(Tmsg, 'node ' + ccode_func) 42 + botan.track(Tmsg, 'node ' + ccode_func + " " + askedNode.toLowerCase()) 43 } 44 if(handler == "irc"){ 45 bot.say(IRCto, output);