Add country code to SMS messages
This commit is contained in:
parent
cb5c373e46
commit
7051a0b841
9
index.js
9
index.js
|
@ -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
11
package-lock.json
generated
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue