A script to monitor a raids, quests, nests, and pokemon table in a using a monocle Postgres database and webhook changes to one or many discord channels.
Raid Boss Feed example:
Nest Feed example:
Quest Feed example:
Pokemon Feed example:
Possible feeds:
- Install Node.js (https://nodejs.org/en/download/
ver 8.4+
) - Navigate to PGWebhooks folder.
- Install the following npm modules (npm install ):
- discord.js
- pg
- pg-pubsub
- moment
- pm2
- Set Configs
- In files/webhooks_config.example.json, add your DB info, json directories for quests/rewards (PMSF included by default) and webhook IDs/Tokens. Rename as webhooks_config.json.
- No changes are necessary to pgWebhooks.js.
- Create the Notification and Trigger in your Postgres Database
RUN THESE EXACTLY AS IS:
CREATE OR REPLACE FUNCTION notify_event() RETURNS TRIGGER AS $$
DECLARE
data json;
notification json;
BEGIN
IF (TG_OP = 'DELETE') THEN
data = row_to_json(OLD);
ELSE
data = row_to_json(NEW);
END IF;
notification = json_build_object(
'table',TG_TABLE_NAME,
'action', TG_OP,
'data', data);
PERFORM pg_notify('events',notification::text);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
For Quests:
CREATE TRIGGER research_notify_event
AFTER INSERT OR UPDATE OR DELETE ON pokestops
FOR EACH ROW EXECUTE PROCEDURE notify_event();
For Raids:
CREATE TRIGGER raids_notify_event
AFTER INSERT OR UPDATE OR DELETE ON raids
FOR EACH ROW EXECUTE PROCEDURE notify_event();
For Pokemon:
CREATE TRIGGER raids_notify_event
AFTER INSERT OR UPDATE OR DELETE ON sightings
FOR EACH ROW EXECUTE PROCEDURE notify_event();
Fort Nests:
CREATE TRIGGER raids_notify_event
AFTER INSERT OR UPDATE OR DELETE ON nests
FOR EACH ROW EXECUTE PROCEDURE notify_event();
- Run the bot using pm2 or node.
- pm2 docs can be found at http://pm2.keymetrics.io/