I DID A THING
This commit is contained in:
commit
fdbd809920
132
.gitignore
vendored
Normal file
132
.gitignore
vendored
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
||||||
|
config.json*
|
||||||
|
!config.json.default
|
6
config.json.default
Normal file
6
config.json.default
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"bulkvs": {
|
||||||
|
"id": ""
|
||||||
|
},
|
||||||
|
"webhook": ""
|
||||||
|
}
|
76
index.js
Normal file
76
index.js
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
// a simple express server that takes any URL and console logs it
|
||||||
|
const config = require('./config.json');
|
||||||
|
const express = require('express');
|
||||||
|
const axios = require('axios');
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
const ffmpeg = require("ffmpeg");
|
||||||
|
const hook = new Discord.WebhookClient({ url: config.webhook }, {
|
||||||
|
allowedMentions: {
|
||||||
|
parse: []
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const fs = require('fs');
|
||||||
|
const app = express();
|
||||||
|
const port = 3000;
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
app.post('/sms', async (req, res) => {
|
||||||
|
data = req.body;
|
||||||
|
// Get the CNAM record for the number
|
||||||
|
cnam = data.From;
|
||||||
|
await axios.get(`https://cnam.bulkvs.com/?id=${config.bulkvs.id}&did=${data.From}&format=json`, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
}).then(function (response) {
|
||||||
|
cnam = response.data.name;
|
||||||
|
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
if (data.MediaURLs) { // It's an MMS
|
||||||
|
out = {
|
||||||
|
"text": "",
|
||||||
|
"images": []
|
||||||
|
};
|
||||||
|
// Check if theres any text files in MediaURLs
|
||||||
|
// wrap the for loop in an async function so we can use await
|
||||||
|
await (async () => {
|
||||||
|
for (let i = 0; i < data.MediaURLs.length; i++) {
|
||||||
|
if (data.MediaURLs[i].includes(".txt")) {
|
||||||
|
// Get the text file
|
||||||
|
await axios.get(data.MediaURLs[i]).then(function (response) {
|
||||||
|
response.data = response.data.replaceAll("=\n", "");
|
||||||
|
response.data = response.data.replaceAll("=\r\n", "");
|
||||||
|
response.data = response.data.replaceAll("=\r", "");
|
||||||
|
out["text"] = response.data;
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
})
|
||||||
|
} // Check for jpg and jpeg files
|
||||||
|
else if (data.MediaURLs[i].includes(".jpg") || data.MediaURLs[i].includes(".jpeg") || data.MediaURLs[i].includes(".png") || data.MediaURLs[i].includes(".gif")) {
|
||||||
|
// get file name from URL
|
||||||
|
filename = data.MediaURLs[i].split("/").pop();
|
||||||
|
out['images'].push({ name: filename, attachment: data.MediaURLs[i] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
hook.send({
|
||||||
|
content: out['text'],
|
||||||
|
files: out['images'],
|
||||||
|
username: cnam
|
||||||
|
})
|
||||||
|
} else { // It's an SMS
|
||||||
|
data.Message = data.Message.replaceAll("+", " ");
|
||||||
|
data.Message = decodeURIComponent(data.Message);
|
||||||
|
hook.send({
|
||||||
|
content: data.Message,
|
||||||
|
username: cnam
|
||||||
|
})
|
||||||
|
}
|
||||||
|
res.send("OK");
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log(`Listening on port ${port}`);
|
||||||
|
});
|
1119
package-lock.json
generated
Normal file
1119
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
18
package.json
Normal file
18
package.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "bulkvs-discord-sms",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^1.4.0",
|
||||||
|
"discord.js": "^14.13.0",
|
||||||
|
"express": "^4.18.2",
|
||||||
|
"ffmpeg": "^0.0.4",
|
||||||
|
"ffmpeg-static": "^5.2.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue