Code from AWS
This commit is contained in:
commit
6a891e1275
|
|
@ -0,0 +1,58 @@
|
||||||
|
|
||||||
|
const AWS = require('aws-sdk');
|
||||||
|
|
||||||
|
AWS.config.update({region: 'us-east-1'});
|
||||||
|
|
||||||
|
const knex = require('knex')({
|
||||||
|
client: 'mysql',
|
||||||
|
connection: {
|
||||||
|
host: 'nzoth-whispers.cnr1c5jzuhe8.us-east-1.rds.amazonaws.com',
|
||||||
|
user: 'lambda_user',
|
||||||
|
password: 'AppleADay',
|
||||||
|
database: 'nzoth'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const whispers = require('./whispers.json');
|
||||||
|
|
||||||
|
const snsService = new AWS.SNS({apiVersion: '2010-03-31'});
|
||||||
|
|
||||||
|
const getRandomWhisper = () => {
|
||||||
|
const randomIndex = Math.floor(Math.random() * (whispers.length - 1));
|
||||||
|
return whispers[randomIndex];
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendWhisper = PhoneNumber => {
|
||||||
|
|
||||||
|
// TODO : Include opt-out logic
|
||||||
|
|
||||||
|
const Message = getRandomWhisper();
|
||||||
|
|
||||||
|
console.log(`Sending "${Message}" to "${PhoneNumber}"`);
|
||||||
|
|
||||||
|
return snsService.publish({
|
||||||
|
Message: Message,
|
||||||
|
PhoneNumber: PhoneNumber
|
||||||
|
}).promise()
|
||||||
|
.catch(err => console.error(`Error sending sms: ${err}`));
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.handler = async (event) => {
|
||||||
|
|
||||||
|
const phoneNumbers = await knex
|
||||||
|
.select().from('phone_numbers').where('is_deleted', 0)
|
||||||
|
.catch(err => console.error(`Error getting phone_numbers: ${err}`));
|
||||||
|
|
||||||
|
if (!phoneNumbers) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const inFlightMessages = phoneNumbers
|
||||||
|
.map(r => r.phone_number)
|
||||||
|
.map( sendWhisper );
|
||||||
|
|
||||||
|
await Promise.all(inFlightMessages).catch(err => console.error(err));
|
||||||
|
|
||||||
|
console.log('Wrapping up');
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "lambda",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"knex": "^0.21.5",
|
||||||
|
"mysql": "^2.18.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
[
|
||||||
|
"N'Zoth whispers: Six seats at the high table. Six mouths that hunger. One will consume all others.",
|
||||||
|
"N'Zoth whispers: She is not the last, but the first. Drown her and you will see.",
|
||||||
|
"N'Zoth whispers: The veil wanes. His crown will open the way.",
|
||||||
|
"N'Zoth whispers: I alone can save you from what is to come.",
|
||||||
|
"N'Zoth whispers: It grows hungrier... bolder. Alas, your eyes are closed.",
|
||||||
|
"N'Zoth whispers: When the arrow finds its mark, the last fetter will fall away.",
|
||||||
|
"N'Zoth whispers: The Light has struck a bargain with the enemy of all.",
|
||||||
|
"N'Zoth whispers: The fall of night reveals her true face. She will bring only ruin.",
|
||||||
|
"N'Zoth whispers: He gave himself to the deep places. He gave himself to me.",
|
||||||
|
"N'Zoth whispers: With every choice, you become more my servant.",
|
||||||
|
"N'Zoth whispers: At last... embrace the truth of shadow.",
|
||||||
|
"N'Zoth whispers: Yes... you draw closer... ever closer.",
|
||||||
|
"N'Zoth whispers: Ahh... you think you know power.",
|
||||||
|
"N'Zoth whispers: The storm holds strength... but there is a price to be paid.",
|
||||||
|
"N'Zoth whispers: Harness your fury... make your hatred a weapon.",
|
||||||
|
"N'Zoth whispers: Children... the depths are my domain.",
|
||||||
|
"N'Zoth whispers: Let the tides draw you into my dream...",
|
||||||
|
"N'Zoth whispers: Deeper, ever deeper...",
|
||||||
|
"N'Zoth whispers: Patience... patience. They may yet prove worthy to receive my gift. I will taste their dreams... their flesh.",
|
||||||
|
"C'Thun whispers: Death is close...",
|
||||||
|
"C'Thun whispers: You are already dead.",
|
||||||
|
"C'Thun whispers: Your courage will fail.",
|
||||||
|
"C'Thun whispers: Your friends will abandon you.",
|
||||||
|
"C'Thun whispers: You will betray your friends.",
|
||||||
|
"C'Thun whispers: You will die.",
|
||||||
|
"C'Thun whispers: You are weak.",
|
||||||
|
"C'Thun whispers: Your heart will explode.",
|
||||||
|
"Yogg-Sarron whispers: They are coming for you...",
|
||||||
|
"Yogg-Sarron whispers: Give in to your fear...",
|
||||||
|
"Yogg-Sarron whispers: Kill them all... before they kill you...",
|
||||||
|
"Yogg-Sarron whispers: They have turned against you... now, take your revenge...",
|
||||||
|
"Yogg-Sarron whispers: It WAS your fault...",
|
||||||
|
"Yogg-Sarron whispers: Tell yourself again that these are not truly your friends...",
|
||||||
|
"Yogg-Sarron whispers: You are a pawn of forces unseen...",
|
||||||
|
"Yogg-Sarron whispers: There is no escape... not in this life... not in the next...",
|
||||||
|
"Yogg-Sarron whispers: Trust is your weakness...",
|
||||||
|
"Yogg-Sarron whispers: Hope is an illusion...",
|
||||||
|
"Yogg-Sarron whispers: All that you know will fade...",
|
||||||
|
"Yogg-Sarron whispers: You will be alone in the end...",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: At the bottom of the ocean even light must die.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: Even death may die.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: The stars sweep chill currents that make men shiver in the dark.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: You will all be alone in the end.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: Look around. They will all betray you. Flee screaming into the black forest.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: In the land of Ny'alotha there is only sleep.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: In the sleeping city of Ny'alotha walk only mad things.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: Ny'alotha is a city of old, terrible, unnumbered crimes.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: The drowned god's heart is black ice.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: The fish know all the secrets. They know the cold. They know the dark.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: You resist. You cling to your life as if it actually matters. You will learn.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: In the sunken city, he lays dreaming.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: The silent, sleeping, staring houses in the backwoods always dream. It would be merciful to tear them down.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: There is no sharp distinction between the real and the unreal.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: There is a little lamb lost in dark woods.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: All places, all things have souls. All souls can be devoured.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: What can change the nature of a man?",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: Do you dream while you sleep or is it an escape from the horrors of reality?",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: Y'knath k'th'rygg k'yi mrr'ungha gr'mula.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: The void sucks at your soul. It is content to feast slowly.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: It is standing right behind you. Do not move. Do not breathe.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: Have you had the dream again? A black goat with seven eyes that watches from the outside.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: Open me! Open me! Open me! Then only will you know peace.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: The tortured spirits of your ancestors cling to you, screaming in silence. Apparently they are quite numerous.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: The giant rook watches from the dead trees. Nothing breathes beneath his shadow.",
|
||||||
|
"Puzzle Box of Yogg-Saron whispers: Beneath the shadow of the darkened spire, there is no light, no mercy, only void, and the chaos within."
|
||||||
|
]
|
||||||
Loading…
Reference in New Issue