@ -39,26 +39,107 @@ function getLocationInfo(callsign, message) {
let lat = data . entries [ 0 ] . lat ;
let lat = data . entries [ 0 ] . lat ;
let lng = data . entries [ 0 ] . lng ;
let lng = data . entries [ 0 ] . lng ;
let altitude = data . entries [ 0 ] . altitude
let altitude = data . entries [ 0 ] . altitude
? ` ${ data . entries [ 0 ] . altitude } m ( ${ Math . round (
/ * ? ` $ { d a t a . e n t r i e s [ 0 ] . a l t i t u d e } m ( $ { M a t h . r o u n d (
data . entries [ 0 ] . altitude * 3.28084
data . entries [ 0 ] . altitude * 3.28084
) } ft ) `
) } ft ) `
: "Not available" ;
: "Not available" ; * /
? ` ${ data . entries [ 0 ] . altitude } m `
: "0.00m" ;
let speed = data . entries [ 0 ] . speed
? ` ${ data . entries [ 0 ] . speed } km/h `
: "0" ;
let course = data . entries [ 0 ] . course
? ` ${ data . entries [ 0 ] . course } `
: "0" ;
let comment = data . entries [ 0 ] . comment
? ` ${ data . entries [ 0 ] . comment } `
: "No comment" ;
let status = data . entries [ 0 ] . status
? ` ${ data . entries [ 0 ] . status } `
: "No status" ;
let path = data . entries [ 0 ] . path
? ` ${ data . entries [ 0 ] . path } `
: "No path" ;
if ( data . entries [ 0 ] . status _lasttime ) {
let status _last = new Date ( parseInt ( data . entries [ 0 ] . status _lasttime , 10 ) * 1000 ) ;
var laststat = status _last . toLocaleString ( "en-US" , dateOptions ) ;
//status += `\nSent on: ${laststat}`;
}
let coords = ` ${ lat } , ${ lng } ` ;
let coords = ` ${ lat } , ${ lng } ` ;
let timeUpdated = new Date ( data . entries [ 0 ] . time * 1000 ) ;
let timeUpdated = new Date ( data . entries [ 0 ] . time * 1000 ) ;
let miniMapUrl = ` https://maps.googleapis.com/maps/api/staticmap?center= ${ coords } &zoom=13&size=600x300&maptype=roadmap&markers=color:blue| ${ coords } &key= ${
let miniMapUrl = ` https://maps.googleapis.com/maps/api/staticmap?center= ${ coords } &zoom=17&size=600x300&maptype=terrain&markers=color:red| ${ coords } &key= ${ config . gmaps _token } ` ;
config . gmaps _token
let title = ` APRS Information for ${ callsign . toUpperCase ( ) } ` ;
} ` ;
let locationEmbed = new Discord . RichEmbed ( )
let locationEmbed = new Discord . RichEmbed ( )
. setColor ( config . embed _color )
. setColor ( config . embed _color )
. setTitle ( title )
. setAuthor ( "APRS Bot" )
. setAuthor ( "APRS Bot" )
. addField ( "Coordinates" , coords )
//.setThumbnail("https://cdn.discordapp.com/avatars/449250687868469258/1709ab4f567c56eaa731518ff621747c.png?size=2048")
. addField ( "Altitude" , altitude )
. addField ( "Coordinates" , coords . replace ( "," , ", " ) )
. addField ( "Time" , timeUpdated . toLocaleString ( "en-US" , dateOptions ) )
. addField ( "Last seen" , timeUpdated . toLocaleString ( "en-US" , dateOptions ) ) ;
. addField (
if ( speed != "0" ) {
"Gmaps" ,
locationEmbed . addField ( "Speed" , speed ) ;
}
if ( course !== "0" ) {
let cc = parseInt ( course , 10 ) ;
let dir = "parse error" ;
switch ( true ) {
case ( cc === 0 ) :
case ( cc === 365 ) :
dir = "Heading north" ;
break ;
case ( cc === 90 ) :
dir = "Heading east" ;
break ;
case ( cc === 180 ) :
dir = "Heading south" ;
break ;
case ( cc === 270 ) :
dir = "Heading west" ;
break ;
case ( cc < 90 ) :
dir = "Heading north-east" ;
break ;
case ( cc < 180 ) :
dir = "Heading south-east" ;
break ;
case ( cc < 270 ) :
dir = "Heading south-west" ;
break ;
case ( cc < 365 ) :
dir = "Heading north-west" ;
break ;
default :
dir = "parse error" ;
}
dir += ` ( ${ cc } °) ` ;
locationEmbed . addField ( "Direction" , dir ) ;
}
if ( altitude !== "0.00m" ) {
locationEmbed . addField ( "Altitude" , altitude ) ;
}
if ( comment !== "No comment" ) {
locationEmbed . addField ( "Comment" , comment ) ;
}
if ( status !== "No status" ) {
locationEmbed . addField ( ` Status ( ${ laststat } ) ` , status ) ;
}
if ( path !== "No path" ) {
locationEmbed . addField ( "Path" , path ) ;
}
/ * l o c a t i o n E m b e d . a d d F i e l d (
"Google Maps" ,
` https://www.google.com/maps/search/?api=1&query= ${ coords } `
` https://www.google.com/maps/search/?api=1&query= ${ coords } `
) * /
locationEmbed . addField (
"APRS.fi" ,
` https://aprs.fi/#!mt=roadmap&z=11&call=a%2F ${ callsign . toUpperCase ( ) } &timerange=3600&tail=3600 `
)
)
. setImage ( miniMapUrl )
. setImage ( miniMapUrl )
//.addField("Path",
. setTimestamp ( )
. setTimestamp ( )
. setFooter ( "Data sourced from https://aprs.fi/" ) ;
. setFooter ( "Data sourced from https://aprs.fi/" ) ;
message . channel . send ( { embed : locationEmbed } ) ;
message . channel . send ( { embed : locationEmbed } ) ;