Skip to content
Merged
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: 4 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@
// webhook queue is kept under control; if this clears nicely in between drops from your scanner you are keeping up. For outbound, a lower number of
// concurrent senders will reduce chance of hitting the global rate limit (probably) which is why we haven't defaulted too high here
//
// fastMonsters - Eliminate SQL lookups for monster matching by activating in memory pokemon matching
// disablePokemonCache - The impact of this will be that poracle uses a lot less memory
// maxDatabaseConnections - This is the max number of database connections Poracle can have (per worker)
// webhookProcessingWorkers - Number of threads to run inbound webhook workers. Five is enough for very big systems, going too high is probably
// counter productive so talk to me before playing with this one
Expand All @@ -524,7 +526,8 @@
// concurrentDiscordWebhookConnections - How many concurrent discord webhook destinations to send to at once
//
"tuning": {
"fastMonsters": false,
"fastMonsters": true,
"disablePokemonCache": true,
"maxDatabaseConnections": 15,
"webhookProcessingWorkers": 5,
"concurrentWebhookProcessorsPerWorker": 4,
Expand Down
16 changes: 15 additions & 1 deletion locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"channel":"Kanal",
"Charged TM":"Lade-TM",
"Chill":"Gefriermodul",
"clean":"aufräumen",
"clean":"bereinigen",
"Cleaning finished":"Säuberung beendet!",
"clear":"leeren",
"Cliff":"Cliff",
Expand Down Expand Up @@ -147,6 +147,7 @@
"incident":"ereignis",
"include_empty":"auch_leer",
"including battle changes":"inklusive Teamänderungen",
"including rsvp updates":"mit rsvp updates",
"including slot changes":"inklusive Platzänderungen",
"individually":"individuell",
"instinct":"Intuition",
Expand Down Expand Up @@ -290,6 +291,7 @@
"Rock":"Gestein",
"role":"Rolle",
"Roles available":"Aktuell sind folgende Rollen verfügbar",
"rsvp only":"nur rsvp",
"russian":"Russisch",
"s location to : ":"“ wurde gesetzt auf: ",
"'s location to the following coordinates in":"“ wurde wie folgt gesetzt:",
Expand All @@ -299,6 +301,7 @@
"settime":"Zeit",
"Shadow":"Crypto",
"Shadow Legendary":"Crypto Legendär",
"Shiny":"schillernd",
"Shiny information not yet calculated - wait a few minutes and try again":"Shinyinfos noch nicht berechnet - warte ein paar Minuten und versuche es erneut",
"Shiny Rate":"Shinyrate",
"Shiny Stats (Last few hours)":"Shiny Statistik (der letzen Stunden)",
Expand Down Expand Up @@ -416,11 +419,20 @@
"Winter":"Winter",
"with":"mit",
"with move":"mit Attacke",
"without rsvp updates":"ohne rsvp updates",
"yellow":"gelb",
"You are currently set to receive alarms in":"Folgende Gebiete sind gesetzt:",
"You can start receiving alerts again using {0}{1}":"Du kannst mit {0}{1} wieder Benachrichtigungen erhalten",
"You do not have any profiles":"Kein Profil vorhanden",
"You do not have permission to execute this command":"keine Berechtigung dieses Komando zu benutzen",
"You do not have permission to track monsters":"keine Berechtigung Pokémon zu tracken",
"You do not have permission to track raids":"keine Berechtigung Raids zu tracken",
"You do not have permission to track quests":"keine Berechtigung Quests zu tracken",
"You do not have permission to track invasions":"keine Berechtigung Team-GO-Rocket-Invasionen zu tracken",
"You do not have permission to track lures":"keine Berechtigung Lockmodule zu tracken",
"You do not have permission to track nests":"keine Berechtigung Nester zu tracken",
"You do not have permission to track gyms":"keine Berechtigung Arenen zu tracken",
"You do not have permission to track fort changes":"keine Berechtigung Gym und Stop Änderungen zu tracken",
"You don't have a profile set":"Kein Profil gewählt",
"You have been granted the role {0}":"Folgende Rolle wurde hinzugefügt: {0}",
"You have breached the rate limit too many times in the last 24 hours. Your messages are now stopped, use {0}start to resume":"24 Std. Nachrichtenlimit wurde überschritten. Benachrichtigungen sind nun deaktiviert, nutze {0}start um diese wieder zu aktivieren",
Expand All @@ -443,12 +455,14 @@
"You're not tracking any nests":"Es werden keine Nester beobachtet.",
"You're not tracking any quests":"Es werden keine Quests beobachtet.",
"You're not tracking any raids":"Es werden keine Raids beobachtet.",
"You're not tracking any fort changes":"Es werden keine Gym und Stop Änderungen beobachtet.",
"You're tracking the following gyms:":"Folgende Arenen werden beobachtet:",
"You're tracking the following invasions:":"Folgende Team-GO-Rocket-Invasionen werden beobachtet:",
"You're tracking the following lures:":"Folgende Lockmodule werden beobachtet:",
"You're tracking the following monsters:":"Folgende Pokémon werden beobachtet:",
"You're tracking the following nests:":"Folgende Nester werden beobachtet:",
"You're tracking the following quests:":"Folgende Quests werden beobachtet:",
"You're tracking the following raids:":"Folgende Raids werden beobachtet:",
"You're tracking the following fort changes:":"Folgende Gym und Stop Änderungen werden beobachtet:",
"Zen":"Trance-Modus"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "poracle",
"version": "4.8.3",
"version": "4.8.4",
"description": "Webhook processing and personalised discord|telegram alarms",
"keywords": [
"poracle",
Expand Down Expand Up @@ -42,7 +42,7 @@
"discord.js": "^13.16.0",
"fast-json-stable-stringify": "^2.1.0",
"fastify": "^4.25.2",
"flat-cache": "^4.0.0",
"flat-cache": "^5.0.0",
"form-data": "^4.0.0",
"geo-tz": "^8.0.0",
"handlebars": "^4.7.7",
Expand Down
42 changes: 40 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,50 @@ async function processOne(hook) {
fastify.webhooks.info(`raid ${JSON.stringify(hook.message)}`)
const cacheKey = `${hook.message.gym_id}${hook.message.end}${hook.message.pokemon_id}`

if (fastify.cache.get(cacheKey)) {
const raidDetails = fastify.cache.get(cacheKey)
let rsvpDifference = false
const oldRsvpsLen = raidDetails?.rsvps?.length ?? 0
const newRsvpsLen = hook.message.rsvps?.length ?? 0
if (newRsvpsLen > oldRsvpsLen) {
rsvpDifference = true
} else if (raidDetails && raidDetails.rsvps && hook.message.rsvps) {
// Allow for old timeslots to have disappeared, so only compare the
// new ones present
for (let x = 0; x < newRsvpsLen; x++) {
const newRsvp = hook.message.rsvps[x]

let found = false
for (const oldRsvp of raidDetails.rsvps) {
if (newRsvp.timeslot === oldRsvp.timeslot) {
found = true
if (newRsvp.going_count !== oldRsvp.going_count
|| newRsvp.maybe_count !== oldRsvp.maybe_count) {
rsvpDifference = true
}
break
}
}

if (found) {
if (rsvpDifference) break
} else {
// timeslot was not in old rsvps
rsvpDifference = true
break
}
}
}

if (raidDetails && !rsvpDifference) {
fastify.controllerLog.debug(`${hook.message.gym_id}: Raid was sent again too soon, ignoring`)
break
}

fastify.cache.set(cacheKey, 'x')
hook.message.firstNotification = !raidDetails

fastify.cache.set(cacheKey, {
rsvps: hook.message.rsvps,
})
}

await processHook(hook)
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/fortupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class FortUpdate extends Controller {
data.fortType = data.new?.type || data.old?.type || 'unknown'
Object.assign(data, this.config.general.dtsDictionary)
data.googleMapUrl = `https://maps.google.com/maps?q=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/maps?daddr=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/place?coordinate=${data.latitude},${data.longitude}`
data.wazeMapUrl = `https://www.waze.com/ul?ll=${data.latitude},${data.longitude}&navigate=yes&zoom=17`
if (this.config.general.rdmURL) {
data.rdmUrl = `${this.config.general.rdmURL}${!this.config.general.rdmURL.endsWith('/') ? '/' : ''}@${data.latitude}/@${data.longitude}/18`
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/gym.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Gym extends Controller {
Object.assign(data, this.config.general.dtsDictionary)
data.gymId = data.id || data.gym_id
data.googleMapUrl = `https://maps.google.com/maps?q=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/maps?daddr=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/place?coordinate=${data.latitude},${data.longitude}`
data.wazeMapUrl = `https://www.waze.com/ul?ll=${data.latitude},${data.longitude}&navigate=yes&zoom=17`
if (this.config.general.rdmURL) {
data.rdmUrl = `${this.config.general.rdmURL}${!this.config.general.rdmURL.endsWith('/') ? '/' : ''}@gym/${data.gymId}`
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/monster.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class Monster extends Controller {
if (data.boosted_weather) data.weather = data.boosted_weather
if (!data.weather) data.weather = 0
Object.assign(data, this.config.general.dtsDictionary)
data.appleMapUrl = `https://maps.apple.com/maps?daddr=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/place?coordinate=${data.latitude},${data.longitude}`
data.googleMapUrl = `https://maps.google.com/maps?q=${data.latitude},${data.longitude}`
data.wazeMapUrl = `https://www.waze.com/ul?ll=${data.latitude},${data.longitude}&navigate=yes&zoom=17`
if (this.config.general.rdmURL) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/nest.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Nest extends Controller {

Object.assign(data, this.config.general.dtsDictionary)
data.googleMapUrl = `https://maps.google.com/maps?q=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/maps?daddr=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/place?coordinate=${data.latitude},${data.longitude}`
data.wazeMapUrl = `https://www.waze.com/ul?ll=${data.latitude},${data.longitude}&navigate=yes&zoom=17`
if (this.config.general.rdmURL) {
data.rdmUrl = `${this.config.general.rdmURL}${!this.config.general.rdmURL.endsWith('/') ? '/' : ''}@${data.latitude}/@${data.longitude}/18`
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/pokestop.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Invasion extends Controller {

Object.assign(data, this.config.general.dtsDictionary)
data.googleMapUrl = `https://maps.google.com/maps?q=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/maps?daddr=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/place?coordinate=${data.latitude},${data.longitude}`
data.wazeMapUrl = `https://www.waze.com/ul?ll=${data.latitude},${data.longitude}&navigate=yes&zoom=17`
if (this.config.general.rdmURL) {
data.rdmUrl = `${this.config.general.rdmURL}${!this.config.general.rdmURL.endsWith('/') ? '/' : ''}@pokestop/${data.pokestop_id}`
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/pokestop_lure.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Lure extends Controller {

Object.assign(data, this.config.general.dtsDictionary)
data.googleMapUrl = `https://maps.google.com/maps?q=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/maps?daddr=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/place?coordinate=${data.latitude},${data.longitude}`
data.wazeMapUrl = `https://www.waze.com/ul?ll=${data.latitude},${data.longitude}&navigate=yes&zoom=17`
if (this.config.general.rdmURL) {
data.rdmUrl = `${this.config.general.rdmURL}${!this.config.general.rdmURL.endsWith('/') ? '/' : ''}@pokestop/${data.pokestop_id}`
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/quest.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Quest extends Controller {

Object.assign(data, this.config.general.dtsDictionary)
data.googleMapUrl = `https://maps.google.com/maps?q=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/maps?daddr=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/place?coordinate=${data.latitude},${data.longitude}`
data.wazeMapUrl = `https://www.waze.com/ul?ll=${data.latitude},${data.longitude}&navigate=yes&zoom=17`
if (this.config.general.rdmURL) {
data.rdmUrl = `${this.config.general.rdmURL}${!this.config.general.rdmURL.endsWith('/') ? '/' : ''}@pokestop/${data.pokestop_id}`
Expand Down
48 changes: 44 additions & 4 deletions src/controllers/raid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Raid extends Controller {
const { areastring, strictareastring } = this.buildAreaString(data.matched)

let query = `
select humans.id, humans.name, humans.type, humans.language, humans.latitude, humans.longitude, raid.template, raid.distance, raid.clean, raid.ping from raid
select humans.id, humans.name, humans.type, humans.language, humans.latitude, humans.longitude, raid.template, raid.distance, raid.clean, raid.ping, raid.rsvp_changes from raid
join humans on (humans.id = raid.id and humans.current_profile_no = raid.profile_no)
where humans.enabled = 1 and humans.admin_disable = false and (humans.blocked_alerts IS NULL OR humans.blocked_alerts NOT LIKE '%raid%') and
(pokemon_id=${data.pokemon_id} or (pokemon_id=9000 and (raid.level=${data.level} or raid.level=90))) and
Expand Down Expand Up @@ -72,7 +72,7 @@ class Raid extends Controller {
const { areastring, strictareastring } = this.buildAreaString(data.matched)

let query = `
select humans.id, humans.name, humans.type, humans.language, humans.latitude, humans.longitude, egg.template, egg.distance, egg.clean, egg.ping from egg
select humans.id, humans.name, humans.type, humans.language, humans.latitude, humans.longitude, egg.template, egg.distance, egg.clean, egg.ping, egg.rsvp_changes from egg
join humans on (humans.id = egg.id and humans.current_profile_no = egg.profile_no)
where humans.enabled = 1 and humans.admin_disable = false and (humans.blocked_alerts IS NULL OR humans.blocked_alerts NOT LIKE '%egg%') and
(egg.level = ${data.level} or egg.level = 90) and
Expand Down Expand Up @@ -139,7 +139,7 @@ class Raid extends Controller {

Object.assign(data, this.config.general.dtsDictionary)
data.googleMapUrl = `https://maps.google.com/maps?q=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/maps?daddr=${data.latitude},${data.longitude}`
data.appleMapUrl = `https://maps.apple.com/place?coordinate=${data.latitude},${data.longitude}`
data.wazeMapUrl = `https://www.waze.com/ul?ll=${data.latitude},${data.longitude}&navigate=yes&zoom=17`
if (this.config.general.rdmURL) {
data.rdmUrl = `${this.config.general.rdmURL}${!this.config.general.rdmURL.endsWith('/') ? '/' : ''}@gym/${data.gym_id}`
Expand All @@ -165,7 +165,8 @@ class Raid extends Controller {
data.gymColor = this.GameData.utilData.teams[data.team_id].color
data.ex = !!(data.ex_raid_eligible ?? data.is_ex_raid_eligible)
data.gymUrl = data.gym_url || data.url || ''
const disappearTime = moment(data.end * 1000).tz(geoTz.find(data.latitude, data.longitude)[0].toString())
const timezone = geoTz.find(data.latitude, data.longitude)[0].toString()
const disappearTime = moment(data.end * 1000).tz(timezone)
data.disappearTime = disappearTime.format(this.config.locale.time)
data.applemap = data.appleMapUrl // deprecated
data.mapurl = data.googleMapUrl // deprecated
Expand All @@ -188,6 +189,22 @@ class Raid extends Controller {
return []
}

const unixMsNow = new Date().getTime()

if (data.rsvps) {
const newRsvps = []
for (const rsvp of data.rsvps) {
if (rsvp.timeslot > unixMsNow) {
rsvp.timeSlot = Math.ceil(rsvp.timeslot / 1000)
rsvp.time = moment(rsvp.timeslot).tz(timezone).format(this.config.locale.time)
rsvp.goingCount = rsvp.going_count || 0
rsvp.maybeCount = rsvp.maybe_count || 0
newRsvps.push(rsvp)
}
}
data.rsvps = newRsvps
}

if (data.pokemon_id) {
data.form ??= 0
const monster = this.GameData.monsters[`${data.pokemon_id}_${data.form}`] || this.GameData.monsters[`${data.pokemon_id}_0`]
Expand Down Expand Up @@ -271,6 +288,18 @@ class Raid extends Controller {
await require('./common/weather').calculateForecastImpact(data, this.GameData, weatherCellId, this.weatherData, data.end, this.config)

for (const cares of whoCares) {
if (cares.rsvp_changes === 0 && !data.firstNotification) {
this.log.debug(`${logReference}: Not creating raid alert for ${cares.id} ${cares.name} ${cares.type} ${cares.language} ${cares.template} - no rsvp changes`, cares)
// eslint-disable-next-line no-continue
continue
}

if (cares.rsvp_changes === 2 && (!data.rsvps || data.rsvps?.length === 0)) {
this.log.debug(`${logReference}: Not creating raid alert for ${cares.id} ${cares.name} ${cares.type} ${cares.language} ${cares.template} - only rsvp changes`, cares)
// eslint-disable-next-line no-continue
continue
}

this.log.debug(`${logReference}: Creating raid alert for ${cares.id} ${cares.name} ${cares.type} ${cares.language} ${cares.template}`, cares)

const rateLimitTtr = this.getRateLimitTimeToRelease(cares.id)
Expand Down Expand Up @@ -520,6 +549,17 @@ class Raid extends Controller {
data.staticmap = data.staticMap // deprecated

for (const cares of whoCares) {
if (cares.rsvp_changes === 0 && !data.firstNotification) {
this.log.debug(`${logReference}: Not creating egg alert for ${cares.id} ${cares.name} ${cares.type} ${cares.language} ${cares.template} - no rsvp changes`, cares)
// eslint-disable-next-line no-continue
continue
}

if (cares.rsvp_changes === 2 && (!data.rsvps || data.rsvps?.length === 0)) {
this.log.debug(`${logReference}: Not creating egg alert for ${cares.id} ${cares.name} ${cares.type} ${cares.language} ${cares.template} - only rsvp changes`, cares)
// eslint-disable-next-line no-continue
continue
}
this.log.debug(`${logReference}: Creating egg alert for ${cares.id} ${cares.name} ${cares.type} ${cares.language} ${cares.template}`, cares)
const rateLimitTtr = this.getRateLimitTimeToRelease(cares.id)
if (rateLimitTtr) {
Expand Down
Loading