My personal twitter weather bot
Basic features:
Set the dierctory path where logs will be stored.
Paths are relative to index.js
.
"log": {
"logDir": "logs"
}
The forecast area is set config.weather.openWeatherMap.location
using one of these combinations.
q: "{city name},{country code}"
id: {city id}
lat: {lat}
lon: {lon}
zip: "{zip code},{country code}"
set config.weather.openWeatherMap.key
to the openWeatherMap api key
Example
"weather":{
"openWeatherMap": {
"location": {
"id": 4381982
},
"key": "API KEY"
}
}
config.twitter
contains keys generated from the twitter developer account.
"twitter": {
"consumer_key": "CONSUMER KEY",
"consumer_secret": "CONSUMER SECRET",
"access_token_key": "ACCESS TOKEN KEY",
"access_token_secret": "ACCESS TOKENM SECRET"
}
Alerts are sent out at midnight, 6:00, noon, and 18:00.
Alert requests must contain an email, app name, app version, and a website in the header. These are set in config.weather.alerts.app
weather.alerts.params
will contain get parameters to send to api.weather.gov/alerts. The NWS has a request testing tool here under the "Specification" tab.
Example:
"weather": {
"alerts": {
"disabled": false,
"app": {
"contact": "yourEmail@example.com",
"name": "AppName",
"version": "0.1",
"website": "www.yourWebsite.com"
},
"params": {
"active": true,
"area": "MO",
"status": "actual"
}
}
}
Filters are in the form:
{
"restriction":"FILTER TYPE",
"path": "PATH TO VALUE",
"value": "VALUE FOR FILTERING",
"keep": true
}
where
Available filter types:
Filters go in an array at config.weather.alerts.filters.
Example:
Keep all alerts where "Boone;" or "Boone, MO" is used to describe the area and discard all alerts that have been replaced by another alert.
"weather": {
"alerts": {
...
"filters": [
{
"restriction": "matches",
"path": "properties.areaDesc",
"value": "Boone;|Boone, MO;",
"keep": true
},
{
"restriction": "has",
"path": "properties.replacedBy",
"keep": false
}
]
}
}
Extra messages are appended at the end of every forecast tweet. They give additional weather information and are picked at random.
Extra messages require coordiantes to work.
config.extra.coordinates.elevation
is the elevation in meters
config.extra.coordinates.long
is the longitude west(west is negative, east is positive)
config.extra.coordinates.lat
is the north latitude(north is positive, south is negative)
Example:
"extra":{
"coordinates": {
"elevation": 231,
"long": -92.3341,
"lat": 38.9517
},
...
}
The avaialable message types are
data/jokes.json
's "general" arrayThe probability of each type of message showing up is set by a weight. The probability of a message type showing up is its weight / sum of all weights.
Setting all weights to 0 and having extras enabled causes an error.
Example:
The sum of all the weights is 100. Jokes have 1/100 chance of showing up. Moon phase messages have a 15/100 chance of showing up.
"extra":{
...
"probabilities":{
"joke": 1,
"tutorial": 9,
"lunar": 15,
"season": 5,
"sunrise": 15,
"beaufort": 10,
"records": 0,
"cloudiness": 10,
"humidity": 10,
"precipitation": 15,
"pressure": 10
}
}
Extras can be disabled with:
"extra":{
"disabled": true,
...
}
config.twitter.localStationHandle
can be set to a local weather station's twitter handle to retweet all their tweets every hour on the 30 minute mark.
Example:
"twitter": {
...
"localStationHandle": "NWSStLouis"
}