Skip to content

botfactoryit/terremotibot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TerremotiBot

GitHub release License

🎯 Source code of the Italian bot TerremotiBot, available on Telegram

Configuration

A config.json file should be placed in the config directory. The template for the configuration file is example.config.json.

Key Required Explanation
telegram.token Yes The Telegram Bot API bot token
telegram.serverPort Yes The port used for the HTTP webhook server
db.connectionString Yes MongoDB connection string
ingv.pollingInterval Yes Interval for INGV server polling
ingv.broadcastThreshold Yes Magnitude threshold value. Earthquakes with a magnitude above this value will be notified to all chats in the database. To disable broadcast notifications, set the value to an high number (like 10)
social.enabled Yes Enable or disable the feature that publishes earthquakes to social networks
social.threshold No Social publish threshold value
social.facebook.accessToken No Generate a permanent access token for the page you want to publish to. See Facebook docs or StackOverflow
social.facebook.pageId No The ID of the page you want to publish the post to
social.twitter.* No Twitter keys
geonames.username Yes Username for the GeoNames service, used for reverse geocoding
mapbox.token Yes Mapbox token for generating the maps for the notifications

How to run it

npm ci
npm run dev

Run with Docker

You can run the application locally with Docker. This Docker Compose configuration brings up a MongoDB instance, and the base image already includes all the required dependencies (currently Node.js and GraphicsMagick).

docker compose -f docker-compose.dev.yml up --build

You can also run MongoDB in a separate shell:

docker compose -f docker-compose.dev.yml up mongo

And then run the actual bot:

docker compose -f docker-compose.dev.yml up --build bot

Run tests with Docker

You can run tests locally with Docker. This brings up a MongoDB instance used for running tests. After they are completed, stop Compose pressing CTRL+C (once).

docker compose -f docker-compose.tests.yml up --build