Skip to content

A js 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.

Notifications You must be signed in to change notification settings

PartTimeJS/Postgres-Raid-Webhooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 

Repository files navigation

THIS REPO IS NO LONGER MAINTAINED AS OF 6-DEC-2018

Postgres DB Webhooks

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:

REQUIREMENTS:

  1. Install Node.js (https://nodejs.org/en/download/ ver 8.4+)
  2. Navigate to PGWebhooks folder.
  3. Install the following npm modules (npm install ):
    • discord.js
    • pg
    • pg-pubsub
    • moment
    • pm2
  4. 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.
  5. 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();
  1. Run the bot using pm2 or node.

About

A js 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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published