-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from urbanriskmap/dev
Merge dev to form next release
- Loading branch information
Showing
19 changed files
with
422 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,4 @@ env.yml | |
bin/ | ||
.nyc_output/ | ||
private/ | ||
.env | ||
.env-dev | ||
.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Add a webhook | ||
// npx babel-node commands/add-welcome-message.js | ||
import config from '../src/config'; | ||
import request from 'request'; | ||
|
||
const ENV = 'production' | ||
|
||
const run = function(){ | ||
console.log('running'); | ||
const oauth = { | ||
consumer_key: config.TWITTER_CONSUMER_KEY, | ||
consumer_secret: config.TWITTER_CONSUMER_SECRET, | ||
token: config.TWITTER_TOKEN, | ||
token_secret: config.TWITTER_TOKEN_SECRET, | ||
} | ||
|
||
console.log(oauth); | ||
|
||
const opts = { | ||
url: config.TWITTER_ENDPOINT + 'direct_messages/welcome_messages/rules/new.json', | ||
oauth: oauth, | ||
json: true, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
body: { | ||
"welcome_message_rule" : { | ||
"welcome_message_id": '<INSERT RULE ID HERE>', | ||
}, | ||
}, | ||
} | ||
request.post(opts, function(err, response, body){ | ||
console.log('returned') | ||
console.log(err); | ||
console.log(body); | ||
}); | ||
} | ||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Add a webhook | ||
// npx babel-node commands/add-welcome-message.js | ||
import config from '../src/config'; | ||
import buttons from '../src/lib/buttons.json'; | ||
import request from 'request'; | ||
|
||
const ENV = 'production' | ||
|
||
const run = function(){ | ||
console.log('running'); | ||
const oauth = { | ||
consumer_key: config.TWITTER_CONSUMER_KEY, | ||
consumer_secret: config.TWITTER_CONSUMER_SECRET, | ||
token: config.TWITTER_TOKEN, | ||
token_secret: config.TWITTER_TOKEN_SECRET, | ||
} | ||
|
||
console.log(oauth); | ||
|
||
const opts = { | ||
url: config.TWITTER_ENDPOINT + 'direct_messages/welcome_messages/new', | ||
oauth: oauth, | ||
json: true, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
body: { | ||
"welcome_message" : { | ||
"name": "simple_welcome-message 03", | ||
"message_data": { | ||
"text": buttons[config.DEFAULT_LANGUAGE].text.welcome, | ||
"quick_reply": { | ||
"type": "options", | ||
"options": [ | ||
{ | ||
"label": buttons[config.DEFAULT_LANGUAGE].text.start, | ||
"metadata": "start", | ||
}, | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
request.post(opts, function(err, response, body){ | ||
console.log('returned') | ||
console.log(err); | ||
console.log(body); | ||
}); | ||
} | ||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Delete a subscription | ||
// npx babel-node commands/delete-subscription.js | ||
import config from '../src/config'; | ||
import request from 'request'; | ||
|
||
const ENV = 'production' | ||
|
||
const run = function(){ | ||
console.log('running'); | ||
const oauth = { | ||
consumer_key: config.TWITTER_CONSUMER_KEY, | ||
consumer_secret: config.TWITTER_CONSUMER_SECRET, | ||
token: config.TWITTER_TOKEN, | ||
token_secret: config.TWITTER_TOKEN_SECRET, | ||
} | ||
|
||
console.log(oauth); | ||
|
||
const opts = { | ||
url: config.TWITTER_ENDPOINT + 'account_activity/all/' + ENV + '/subscriptions.json', | ||
oauth: oauth, | ||
json: true, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
body: {} | ||
} | ||
|
||
request.delete(opts, function(err, response, body){ | ||
console.log('returned') | ||
console.log(err); | ||
console.log(body); | ||
}); | ||
} | ||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Delete a webhook message rule | ||
// npx babel-node commands/delete-welcome-message-rule.js | ||
import config from '../src/config'; | ||
import request from 'request'; | ||
|
||
const ENV = 'production' | ||
|
||
const run = function(){ | ||
console.log('running'); | ||
const oauth = { | ||
consumer_key: config.TWITTER_CONSUMER_KEY, | ||
consumer_secret: config.TWITTER_CONSUMER_SECRET, | ||
token: config.TWITTER_TOKEN, | ||
token_secret: config.TWITTER_TOKEN_SECRET, | ||
} | ||
|
||
console.log(oauth); | ||
|
||
const opts = { | ||
url: config.TWITTER_ENDPOINT + 'direct_messages/welcome_messages/rules/destroy.json?id=<INSERT RULE ID HERE>', | ||
oauth: oauth, | ||
json: true, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
} | ||
request.delete(opts, function(err, response, body){ | ||
console.log('returned') | ||
console.log(err); | ||
console.log(body); | ||
}); | ||
} | ||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Add a subscription | ||
// npx babel-node commands/delete-subscription.js | ||
import config from '../src/config'; | ||
import request from 'request'; | ||
|
||
const ENV = 'production' | ||
|
||
const run = function(){ | ||
console.log('running'); | ||
const oauth = { | ||
consumer_key: config.TWITTER_CONSUMER_KEY, | ||
consumer_secret: config.TWITTER_CONSUMER_SECRET, | ||
token: config.TWITTER_TOKEN, | ||
token_secret: config.TWITTER_TOKEN_SECRET, | ||
} | ||
|
||
console.log(oauth); | ||
|
||
const opts = { | ||
url: config.TWITTER_ENDPOINT + 'account_activity/all/' + ENV + '/subscriptions.json', | ||
oauth: oauth, | ||
json: true, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
body: {} | ||
} | ||
|
||
request.get(opts, function(err, response, body){ | ||
console.log('returned') | ||
console.log(response.statusCode); | ||
console.log(err); | ||
console.log(body); | ||
}); | ||
} | ||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Add a webhook | ||
// npx babel-node commands/add-welcome-message.js | ||
import config from '../src/config'; | ||
import request from 'request'; | ||
|
||
const ENV = 'production' | ||
|
||
const run = function(){ | ||
console.log('running'); | ||
const oauth = { | ||
consumer_key: config.TWITTER_CONSUMER_KEY, | ||
consumer_secret: config.TWITTER_CONSUMER_SECRET, | ||
token: config.TWITTER_TOKEN, | ||
token_secret: config.TWITTER_TOKEN_SECRET, | ||
} | ||
|
||
console.log(oauth); | ||
|
||
const opts = { | ||
url: config.TWITTER_ENDPOINT + 'direct_messages/welcome_messages/rules/list', | ||
oauth: oauth, | ||
json: true, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
} | ||
request.get(opts, function(err, response, body){ | ||
console.log('returned') | ||
console.log(err); | ||
console.log(body); | ||
}); | ||
} | ||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import request from 'request'; | ||
|
||
// Define global | ||
let DEFAULT_LANGUAGE = 'en'; | ||
|
||
/** | ||
* Class for getting Twitter user's locale | ||
* @class Locale | ||
* @param {Object} config - module configuration (config.js) | ||
*/ | ||
export default class Locale { | ||
/** | ||
* constructor for class Locale | ||
* @param {Object} config - module configuration (config.js) | ||
*/ | ||
constructor(config) { | ||
this.config = config; | ||
this.request = request; | ||
|
||
// Update the global with the config | ||
DEFAULT_LANGUAGE = this.config.DEFAULT_LANGUAGE; | ||
} | ||
|
||
/** | ||
* Get a user's locale by user ID | ||
* @method get | ||
* @param {String} userId - Twitter user ID | ||
* @return {Promise} - response | ||
*/ | ||
get(userId) { | ||
return new Promise((resolve, reject) => { | ||
const oauth = { | ||
consumer_key: this.config.TWITTER_CONSUMER_KEY, | ||
consumer_secret: this.config.TWITTER_CONSUMER_SECRET, | ||
token: this.config.TWITTER_TOKEN, | ||
token_secret: this.config.TWITTER_TOKEN_SECRET, | ||
}; | ||
const opts = { | ||
url: this.config.TWITTER_ENDPOINT + | ||
'users/show.json?include_entities=false&user_id=' + | ||
String(userId), | ||
oauth: oauth, | ||
json: true, | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
}; | ||
|
||
request.get(opts, function(err, response, body) { | ||
if (err) { | ||
console.log('Error getting user locale. ' + | ||
err.message); | ||
resolve(DEFAULT_LANGUAGE); // Acess the global default | ||
} else { | ||
resolve(body.lang); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"en": { | ||
"texts": { | ||
"default": "RiskMap bot helps you report flooding in realtime. In life-threatening situations call 911.", | ||
"card": "RiskMap bot helps you report flooding in realtime. In life-threatening situations call 911.", | ||
"thanks": "Thank you for your report. Click to see your report on the map." | ||
} | ||
}, | ||
"es": { | ||
"texts": { | ||
"default": "[ES] RiskMap bot helps you report flooding in realtime. In life-threatening situations call 911.", | ||
"card": "[ES] RiskMap bot helps you report flooding in realtime. In life-threatening situations call 911.", | ||
"thanks": "[ES] Thank you for your report. Click to see your report on the map." | ||
} | ||
} | ||
} |
Oops, something went wrong.