kartuludus / poraclejs Goto Github PK
View Code? Open in Web Editor NEWNodeJS application for PokémonGo WebHook Discord alarms
Home Page: https://kartuludus.github.io/PoracleJS/#/
License: ISC License
NodeJS application for PokémonGo WebHook Discord alarms
Home Page: https://kartuludus.github.io/PoracleJS/#/
License: ISC License
Since Poracle currently resends all the active notifications on a restart, it is best to avoid restarts as much as possible. However changing DTS or adding a new location to the geofence file currently requires a reload.
It would be great if Poracle could detect changes in those files and dynamically load them without a restart of the entire service.
Admin makes changes to dts.json, and saves the file. Poracle detects the change and loads the new DTS or geofence file.
Currently the Poracle service has to be restarted to pick up new DTS or Geofence.
Hey.
The following is absolutely not that important,... so just close it if you don't see an easy way.
I recently started with a localised version for a /help
text for our community here, and quickly ran into the problem, that Telegram has a pretty small maximum message size, and apparently also a maximum number of format codes it accepts per message.
So would be nice if one could set the reply for such commands to be split into multiple messages from the bot, cause when one wants to explain "all" aspects of poracle, one can easily hit the limit.
Cheers!
Discord doesn't let users delete DMs received from bot, which means that if
... users en up with old message in the DM to the bot which they cannot remove.
The Bot itself should be able to remove those messages using the API.
Would it be possible to add a !clean_history
command that would remove all old messages sent by the bot so users can keep a clean channel ?
This is a pure discord only issue, Telegram has an integrated "clean history" capability.
This will
As a user, I want a Map that shows my centered Poracle !location
, with overlay circles showing the distance-radius for 0.5/1/2/3/4/5 kilometres away.
Perhaps there's some way to make GoogleMaps automatically show an overlay like this, as output from the !tracked
command?
Or, maybe someone can invent a !radius
command? :-D
Example: I've found this site, which kinda works, but it doesn't adjust the placement of the circles if you type in a new address directly (awkward drag-and-drop x5, or you have to recreate the circles yourself from a fresh map).
E.g. 0.5km/1km/2km circles. https://www.mapdevelopers.com/draw-circle-tool.php?circles=%5B%5B1000%2C43.3199051%2C6.2897851%2C%22%23AAAAAA%22%2C%22%23000000%22%2C0%5D%2C%5B500%2C43.3199051%2C6.2897851%2C%22%23AAAAAA%22%2C%22%23000000%22%2C0%5D%2C%5B2000%2C43.3199051%2C6.2897851%2C%22%23AAAAAA%22%2C%22%23000000%22%2C0%5D%5D
🗺️ 🔴 💠 Maps radius circles! -- "How far away is that park?" -- Wonder no more! 0.5km/1km/2km circles! Type !radius 123 common road, town
to see a visualization.
Allow quests tracking to track mega-energy for a specific Pokemon.
At the moment you can only track based on the amount of mega energy, but most people don't care about the amount mega-energy if it's not for the pokemon they need it.
This would request the addition of a new column in DB as currently, there is only one reward
column, being used both for the pokemon_id (reward_type 7) and for the amount of mega-energy (reward-type 12). Pokemon_id would need to be stored in a separate field together with the amount of energy available in reward.
Street names and pokestops that contain - eg ' - have HTML text instead -- St. George's Street
all notifications should be 24h format, for me at least :P
at v4 start/restart initial notifications are en 12 hour format afterwards notifications are send in 24h format
Add DnD (Do Not Disturb) to PoracleJS bot.
This would save some webhook calls and as well some nerves / frustration.
First of all it might be good to state which version would be better in long term.
Easy one is as simple as setting static hours range for all days and switching it on / off. Might be good for starter.
Hard way would be based on schedules, where user can define more than one DnD rules for a week days.
!dnd <hours_range>
- enable DnD schedule on current user for provided hours range.
!dnd 22-8
- enable DnD from 22:00 till 8:00 everyday!dnd off
- disable DnD schedule for current user.Add a default empty list []
to humans
table names dnd
.
When enabled the list would become [start_hour, end_hour]
.
!dnd on
- enable DnD schedule for current user.!dnd off
- disable DnD schedule for current user.!dnd add <week_day_range> <hours_range>
- Add DnD on current user for provided week days and hours range.
!dnd add 1-5 22-14
- DnD from Monday to Friday from 22:00 till 14:00.!dnd add 6-7 0-6
- DnD on Saturday Sunday from 00:00 till 6:00.!dnd list
- List all added DnD's for current user with id
.!dnd del <id>
- Remove DnD with provided id
for current user.-
, first argument needs to be smaller then second (easier to parse later on).on / off
sounds looks better than start / stop
I think ,-)1-2 23-5
Monday, Tuesday from 23:00 till 5:00 - we are starting at Monday 23:00 and stopping at Tuesday 5:00 or starting at Monday 23:00 and stopping at Wednesday 5:00?Add new table dnd_schedule
id - used to removal (auto increment)
user_id - obvious
added_at - datetime of schedule addition, might be useful for cleanup? for example we keep those for 3 months after last user activity?
weekday_start - number of week day we start dnd rule
weekday_end - number of week day we stop dnd rule
hour_start - start of dnd hour
hour_end - end of dnd hour
Poracle is working on id, which is logical, but when changing discord channel name or discord user name stuf can become misleading. Consider adding i.e. a daily sync of name
in order to keep it alligned.
Usually not a problem because 99% of users hate doing Rocket Battles. But with the recent Event, users registered for Rocket Invasions and have no idea how to remove them.
With normal notifications the following commands work:
!untrack everything
or !raid remove everything
, etc.
But for Rocket Invasions,
!invasion remove everything
does not work.
Users have to remove the notifications one by one for it to register correctly.
!invasion remove dark
, !invasion remove ice
, etc.
Hey.
One idea would be to allow users to specify S2 cell ID either globally (with a switch?), or perhaps even per track-rule, in order to decide whether they get notified or not.
Yes, these are the same S2 cells as used by Pokemon Go.
There's a nice Python binding (https://github.com/google/s2geometry/ - this is the "complete" and official one... there's another one which is however mostly unmaintained).
This would also allow people to track in different locations (e.g. work and home... or home + where some friends lives whom one would give access to one's PoGo account).
It would also allow to specify more realist regions of interest (rather than circles)... e.g. a less big square around one's home and then arms along bus or subway routes. Or one could cut of unreachable areas (which are now included in the circle), like e.g. when a river is in between.
An implementation should probably allow to specify a minimum and maximum S2cell level.
Objects in s2geometry allow for simple normalisation of multiple cells (i.e. the four level16 cells of an enclosing level15 cells would be merged).
It's also simple (and fast) to check whether a point (e.g. the pokemon location) is contained in any of the cells.
The cells could be stored as string in the DB (though this would get quite large).
Probably it would in fact make sense to either allow cells per tracking rule, or to allow each user to store multiple areas (which are defined by a list cells) and have those linked to tracking rules.
The reason is simply, that one would probably take longer ways to get some super rare pokemon (and thus one needs a different area).
Cheers.
All encounter_id in logs are currently being truncated/rounded, probably due to a wrong data type :
e.g.:
{"encounter_id":8427357231974403000,"pokemon_id":261,"spawnpoint_id":4931631954051,
I checked in MAD tables and actual encounter_id is 8427357231974403189
, not 8427357231974403000
MariaDB [mad]> select encounter_id from pokemon where encounter_id like '84273572319744%';
+---------------------+
| encounter_id |
+---------------------+
| 8427357231974403189 |
+---------------------+
1 row in set (0.041 sec)
Blocker for some v3 users who don't want to leave telegram behind
Poracle is currently logging a lot of information, but most of the time information logged is completely useless to real troubleshooting. It should log less stuff, but more useful stuff.
Some examples :
{"message":"Wild encounter 7079506970964088000 was sent again too soon, ignoring","level":"debug","timestamp":"2020-12-07T16:27:14.769Z"}
{"message":"Wild encounter 7079506970964088000 was sent again too soon, ignoring","level":"debug","timestamp":"2020-12-07T16:30:36.674Z"}
no idea what was sent again too soon
means and how this could be useful to any troubleshooting. Should be sent only to a debug log when debug is activated in config.
This is a very big amount of messages :
grep -c "was sent again too soon" debugLog*
debugLog1.json:116787
debugLog.json:79099
Console log is currently useless as it doesn't give any information which would let an admin troubleshoot an issue, typically :
Hoothoot appeared and 0 humans cared
This log line should at least contain a timestamp + encounter_id so it can be tracked down to something.
On the opposite, it would be very useful to have a message log (which option to enable/disable it). Ideally a different one for discord and telegram, which would log the whole message sent :
{"message":"Telegram sending message {\"content\":\"***Un Raid 6 contre Blizzaroi Mega à démarré !!!***\\nArène : Calvaire, Aische \\nSe termine à: 16:22:50 \\n\\nAttaque Rapide: Tranch’Herbe 🌿 \\nAttaque Chargée: Éco-Sphère 🌿 \\n \\n\",\"sticker\":\"https://mydomain.com/telegram/monsters/460_935.webp\",\"location\":true,\"webpage_preview\":false} / connection to bbdoc 9999999999","level":"warn","timestamp":"2021-01-09T14:36:10.782Z"}
Other remarks :
discord.json
log would be very useful. It should contain a line per message sent to discord with at least timestamp + encounter_id + discord_id so that an admin can track down a message received or not by a user.In my setup, I don't use "areas" at all, and would like all !track commands to be required to have a distance 'd' paramater or get rejected.
A simple 'Require_Distance' config variable or similar where no areas are in use would be nice.
(There may be other benefits to not executing area checks in performance where they are not required.)
Using SwiftTileServer as my provider, occasionally I get errors like these when "what I assume is" Swift"TileServer can't reverse geocode the address when using !location. PoracleJS throws an error:
error: location command $location 275 High School Rd NE Ste C-4, Bainbridge Island, WA 98110 unhappy:Cannot read property 'latitude' of undefined {"stack":"TypeError: Cannot read property 'latitude' of undefined\n at Object.exports.run (/home/ubuntu/PoracleJS/src/lib/discord/commando/commands/location.js:39:68)"}
and returns nothing to the user. My command stroke is $, btw.
Return X reaction or something to the user showing location errored.
Additionally, maybe there's something I'm missing in the tileset, considering 80% of addresses work. Not sure where the tileserver logs are or how to access them within docker, would need help with that.
Also additionally, maybe be able to look at the return of Swifttileserver's error as a user or in poracle logs.
Currently, errored addresses return nothing to the user.
Users think RocketAlert is down because no user feedback of error.
should show help page
{"level":"error","message":"help command unhappy:fields.flat is not a function","stack":"TypeError: fields.flat is not a function\n at Function.normalizeFields (/home/user/PoracleJS/node_modules/discord.js/src/structures/MessageEmbed.js:450:8)\n at MessageEmbed.setup (/home/user/PoracleJS/node_modules/discord.js/src/structures/MessageEmbed.js:78:91)\n at new MessageEmbed (/home/user/PoracleJS/node_modules/discord.js/src/structures/MessageEmbed.js:18:10)\n at embedLikes.map.e (/home/user/PoracleJS/node_modules/discord.js/src/structures/APIMessage.js:166:40)\n at Array.map ()\n at APIMessage.resolveData (/home/user/PoracleJS/node_modules/discord.js/src/structures/APIMessage.js:166:31)\n at DMChannel.send (/home/user/PoracleJS/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:166:62)\n at Message.reply (/home/user/PoracleJS/node_modules/discord.js/src/structures/Message.js:602:25)\n at Object.exports.run (/home/user/PoracleJS/src/lib/discord/commando/commands/help.js:38:13)\n at process._tickCallback (internal/process/next_tick.js:68:7)","timestamp":"2020-12-03T14:41:59.692Z"}
Please add minimal stats to Poracle, mainly to allow followin-up on the number of messages sent per channel/user and total messages sent to Telegram/Discord.
A very easy and flexible way would be to add a stats table and log all messages sent to it with Datetime, ID, type.
Another way would be to add an horodated messages.log file.
Content of the message is not really needed for stats but additional info could help for troubleshooting purpose (typically the encounter_id).
If a user tracks a distance longer integer than 11 digits, it's unable to store it
it being able to track it
misleading checkmark reaction but no tracking added
trim dat string
!track pikachu d99999999999999999999999999
As title, but how should this work?
Should there be a group bot and a DM bot to avoid any rate limits getting mixed up?
There is an issue with notifications Level5 eggs for Discord users and channels.
Channel/User setup with "area add " and then "!egg level5". Expected to receive notifications when level5 raid egg in to the channel or via direct message.
Admin users are able to setup notifications "!egg level5" and then turn off/on and it continues to work.
Any users/channels that are non-admin that add the area and then "!egg level5" do not receive any notifications. Level 1-4 eggs and raids work without issue for all users.
Users/Channels are in the database correctly and show the same as the admin user so no apparent reason for this happening.
Running MariaDB:10.3 as poracledb and lastest master branch of PoracleJS.
Notifications to Discord with Discord Bot.
As a sqlite user I would like to upgrade to mysql so that I can take advantage of backups and other mysql related tools (eg poracleweb project)
We should really have a naming convention and stick with it.
Provide a new behaviour configuration section for this and future optional behaviour. In the !track command treat it as though the 'individually' flag is set always if this behaviour is enabled. Treat no entry in the config as off, and update the default config file to include the new section.
Track evolutions through PVP
https://pastebin.com/raw/pniBxzcX
We have some old dependencies which we shouldn’t. Enough said
Webhook not posting when DTS contains "color": "{{ivcolor}}",
Possible origin of problem: data.ivcolor refers to function findIvColor(data.iv) witch was present in monster.js file on V3 but is missing on V4/master/develop
PoracleJS/src/controllers/monster.js
Line 164 in b02a11b
Should be an ability to alert on lures
!lure everything
!lure glacial
!lure mossy
!lure magnetic
!lure standard
Would need to support distance and areas
Anything else...?
Option to add custom StaticMap and Nominatim Servers instead of relying on the Poracle World one.
StaticMap could theoretically be set in DTS but setting it globaly in the config is easier
I will implement this feature request myself once i got some time (probably later today)
Provide support for /unregister command from admins in the membership group.
Develop branch is not cheching user roles before sending private message to users.
Removing role keeps users full control of Poracle bot.
Tested on latest develop, with 3 different users and 2 independent bots assigned to 2 diferent Discord servers
Admin able should be able to !park
a user.
At the moment the only way to disable access to a user is to !unregister
the user. But unregistering removes all info linked to that user in all DB tables, meaning that if user gets access to Poracle again next time, he needs to reconfigure all their alarms.
It should be possible to temp disable a user without losing all tracking info so he can get back with the same tracking when enabled again.
when running the command !track pikachu @ROLE only one role should appear when the alert comes out
the role is doubled when an alert comes out
not sure
When using a self-hosted Tileserver, it might be a little slow for users to load the images in embeds. Especially when looking at older messages where the Static Maps aren't cached anymore.
Additionally, it's better to avoid sharing the Tileserver URL with others, since anyone could use it to generate their own tiles / Static Maps (though this shouldn't be too big of a problem for most users)
Since Poracle is a Discord bot, a good solution to these problems is to host Static Maps on Discord's CDN.
It could work as follows:
- Have a config option like "host_channel_id"
- If that option is empty, just continue like we're used to
- If using tileserver and the option is filled:
- Fetch the Discord channel using the ID
- Make a POST request to tileserver.com/staticmap/template using the proper data
- This will return the map image in bytes. Convert this reponse to an image format discord.js accepts
- Send a message to the channel with the image in its attachments
- Read the attachments of the message and use its URL as the {{{staticmap}}} DTS option
Prevent users accidentally specifying both great and ultra in the same track command
Locale settings should be user-based instead of being set for the whole instance.
language is currently defined at the global level, so only way to allow for multiple language is to launch 2 instances, maintain 2 DBs and have 2 different Bots.
"locale": {
"timeformat": "en-gb",
"time": "LTS",
"addressFormat": "{{ streetName}} {{ streetNumber }}:",
"language": "en"
},
Moving language settings at the user level (so in humans
table) would allow to run only one DB and for each user to chose their own preference.
When using multiple discord bots for outbound messages, a restart will cause messages to come from different bots
egg notication is incorrect:
Channel level 5: will get all egg levels notified
Channel level 1-4: will get no egg notifications
Channel level5 (webhook based): will get no egg notification
+-----------------------------------------------------------------------------------------------------------------------------+------+-------+-----------+----------+----------+------+-------+
| id | ping | clean | exclusive | template | distance | team | level |
+-----------------------------------------------------------------------------------------------------------------------------+------+-------+-----------+----------+----------+------+-------+
| 672571841751154719 | "" | 0 | 0 | 1 | 0 | 4 | 5 |
| 673242377632350228 | "" | 0 | 0 | 1 | 0 | 4 | 1 |
| 673242377632350228 | "" | 0 | 0 | 1 | 0 | 4 | 2 |
| 673242377632350228 | "" | 0 | 0 | 1 | 0 | 4 | 3 |
| 673242377632350228 | "" | 0 | 0 | 1 | 0 | 4 | 4 |
| https://discordapp.com/api/webhooks/yyyyyyyyyyyyyyyyyy/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | "" | 0 | 0 | 1 | 0 | 4 | 5 |
Title says it all.
If you use -tracked and look at what invasions you have set, a distance is not shown.
Show you the distance that you have set in the output of command.
When -tracked is used, it does not show you the distance.
only Gender: and Grunt type:
Bug people who know things.
-tracked
Good question.
Not relevant i'm sure.
Would it be possible to add a UID column (auto-incrementing) in all those Poracle tables :
egg
invasion
monsters
quest
raid
weather
I think this would help inserting/updating records without having to rely on passing all fields into a WHERE clause.
Hey.
I've just wanted to do the same what I did for V3 in #252 and #253, i.e. add missing Pokémon and forms and correct typos.
Now first... comparing the pkm names in monsters.json with the list of current official English names:
list.en.txt
gives a number of unexpected differences (e.g. use:
meld <( grep '^ "name": "' monsters.json | sed 's/^ "name": "//; s/",$//' | uniq ) list.en.txt
).
Including:
Nidoran female
vs Nidoran♀
Nidoran male
vs ``Nidoran♂
Nidoran
which maps to the same ID than Nidoran male
Farfetchd
vs Farfetch’d
Mr mime
vs Mr. Mime
Ho oh
vs Ho-Oh
Mime jr
vs Mime Jr.
Porygon z
vs Porygon-Z
Hoopa hoopa
vs Hoopa
Type: null
vs Type: Null
Tapu koko
vs Tapu Koko
Tapu lele
vs Tapu Lele
Tapu bulu
vs Tapu Bulu
Tapu fini
vs Tapu Fini
Melmetal
is missingDoes it even work to have spaces in the names?
I'd like to add the missing stuff did you generated this data from the JSON? Is there some automatic generator or was it done all by hand?
Cheers,
Chris.
When a user adds/removes an area have the option to automatically add/remove a corresponding role. Would help clean up the channel list for people if you have a lot of areas.
Just like user reconciliation, channels could be reconciled and deleted
I'm trying to configure for the first time PoracleJS, but I cannot see any documentation about local.json file.
I'm unable to find a useful documentation about local.json configuration option and properties.
I've disable discord hooking and enable telegram, but I got following error:
error: Can't seem to handle monster: Cannot read property 'toLowerCase' of undefined {"stack":"TypeError: Cannot read property 'toLowerCase' of undefined\n at /opt/PoracleJS/src/controllers/controller.js:134:59\n at Array.map (<anonymous>)\n at Monster.pointInArea (/opt/PoracleJS/src/controllers/controller.js:134:35)\n at Monster.handle (/opt/PoracleJS/src/controllers/monster.js:177:30)\n at Timeout.handleAlarms [as _onTimeout] (/opt/PoracleJS/src/app.js:167:52)\n at listOnTimeout (internal/timers.js:549:17)\n at processTimers (internal/timers.js:492:7)"}
(node:16522) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined
at Timeout.handleAlarms [as _onTimeout] (/opt/PoracleJS/src/app.js:168:12)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:16522) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 136)
debug: Wild encounter 8133570773608321000 was sent again too soon, ignoring
debug: Wild encounter 13800137623495617000 was sent again too soon, ignoring
debug: Wild encounter 13806142494322936000 was sent again too soon, ignoring
Any ideas?
my current config:
{
"server": {
"host": "127.0.0.1",
"port": "4201",
"ipWhitelist": [],
"ipBlacklist": []
},
"general": {
"environment": "production",
"alertMinimumTime": 120,
"imgUrl": "https://raw.githubusercontent.com/nileplumb/PkmnShuffleMap/master/PMSF_icons_large/",
"locale": "en",
"weatherChangeAlert": true
},
"logger": {
"level": "**debug**",
"logSize": 25
},
"database": {
"client": "sqlite",
"conn": {
"host": "127.0.0.1",
"database": "poracle",
"user": "poracleuser",
"password": "poraclepassword",
"port": 3306
}
},
"locale": {
"timeformat": "en-gb",
"time": "LTS",
"addressFormat": "{{ streetName}} {{ streetNumber }}:",
"language": "en"
},
"discord": {
"enabled": **false**,
"unknownResponse": false,
"invite": "",
"token": [],
"channels": [
"533927791096233984"
],
"userRole": [
"roleId1",
"358207117951369217"
],
"admins": [
"222742859059560458"
],
"prefix": "!",
"limitSec": 30,
"limitAmount": 20,
"ivColors": [
"#9D9D9D",
"#FFFFFF",
"#1EFF00",
"#0070DD",
"#A335EE",
"#FF8000"
]
},
"telegram": {
"enabled": **true**,
"token": "**<BOT TOKEN ID>**",
"admins": [
"telegram admin id"
],
"channels": [
"**@channel1name**"
]
},
"geocoding": {
"provider": "poracle",
"staticProvider": "poracle",
"geocodingKey": [
"Your Google Geocoding Key if you Use google as provider"
],
"staticKey": [
"Your MapQuest or Google Key"
],
"width": 320,
"height": 200,
"zoom": 15,
"spriteHeight": 20,
"spriteWidth": 20,
"scale": 2,
"type": "klokantech-basic"
}
}
On /start being issued to the bot directly, if user is a member of a valid group proceed with registration
Weather alerts are sometimes duplicated (not sure of conditions)
error: Can't seem to handle monster: Cannot read property 'toLowerCase' of undefined {"stack":"TypeError: Cannot read property 'toLowerCase' of undefined\n at /root/PoracleJS/src/controllers/controller.js:134:59\n at Array.map (<anonymous>)\n at Monster.pointInArea (/root/PoracleJS/src/controllers/controller.js:134:35)\n at Monster.handle
What the hell does that mean to anyone anyway? :-)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.