Add country code to SMS messages

This commit is contained in:
Christopher Cookman 2023-09-01 12:04:43 -06:00
parent cb5c373e46
commit 7051a0b841
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
3 changed files with 17 additions and 6 deletions

View file

@ -1,5 +1,6 @@
// a simple express server that takes any URL and console logs it
const config = require('./config.json');
const phone = require("phone").phone;
const express = require('express');
const axios = require('axios');
const Discord = require('discord.js');
@ -70,13 +71,13 @@ app.post('/sms', async (req, res) => {
hook.send({
content: out['text'],
files: out['images'],
username: "MMS",
username: `MMS [${phone(`+${data.From}`).countryIso3}]`,
avatarURL: encodeURI(`https://tiley.herokuapp.com/avatar/${cnam.replaceAll(" ", "")}/${cnam.replaceAll(" ", "")}.png?s=500`)
})
modhook.send({
content: out['text'],
files: out['images'],
username: `MMS from ${cnam} (${data.From})`,
username: `MMS from ${cnam} (${data.From}) [${phone(`+${data.From}`).countryIso3}]`,
avatarURL: encodeURI(`https://tiley.herokuapp.com/avatar/${cnam.replaceAll(" ", "")}/${cnam.replaceAll(" ", "")}.png?s=500`)
})
} else { // It's an SMS
@ -84,12 +85,12 @@ app.post('/sms', async (req, res) => {
data.Message = decodeURIComponent(data.Message);
hook.send({
content: data.Message,
username: "SMS",
username: `SMS [${phone(`+${data.From}`).countryIso3}]`,
avatarURL: encodeURI(`https://tiley.herokuapp.com/avatar/${cnam.replaceAll(" ", "")}/${cnam.replaceAll(" ", "")}.png?s=500`)
})
modhook.send({
content: data.Message,
username: `SMS from ${cnam} (${data.From})`,
username: `SMS from ${cnam} (${data.From}) [${phone(`+${data.From}`).countryIso3}]`,
avatarURL: encodeURI(`https://tiley.herokuapp.com/avatar/${cnam.replaceAll(" ", "")}/${cnam.replaceAll(" ", "")}.png?s=500`)
})
}

11
package-lock.json generated
View file

@ -13,7 +13,8 @@
"discord.js": "^14.13.0",
"express": "^4.18.2",
"ffmpeg": "^0.0.4",
"ffmpeg-static": "^5.2.0"
"ffmpeg-static": "^5.2.0",
"phone": "^3.1.40"
}
},
"node_modules/@derhuerst/http-basic": {
@ -833,6 +834,14 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
"node_modules/phone": {
"version": "3.1.40",
"resolved": "https://registry.npmjs.org/phone/-/phone-3.1.40.tgz",
"integrity": "sha512-RyQgv8Xl8a43LFBLrYnlS2rTOFFg5Se6DNTG2OXHZlWqC7cHcD/KA1irHjJToeQOoCVZg63pYIlXqG4cuOj/vg==",
"engines": {
"node": ">=12"
}
},
"node_modules/progress": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",

View file

@ -13,6 +13,7 @@
"discord.js": "^14.13.0",
"express": "^4.18.2",
"ffmpeg": "^0.0.4",
"ffmpeg-static": "^5.2.0"
"ffmpeg-static": "^5.2.0",
"phone": "^3.1.40"
}
}