|
|
|
@ -17,7 +17,7 @@ import { dirname } from 'path';
|
|
|
|
|
|
|
|
|
|
// Load settings from config.json
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
|
|
|
const __dirname = dirname(__filename);
|
|
|
|
|
const __dirname = dirname(__filename);
|
|
|
|
|
let rawdata = fs.readFileSync(__dirname + '/config.json');
|
|
|
|
|
let settings = JSON.parse(rawdata);
|
|
|
|
|
console.log(__dirname + "/config.json loaded.");
|
|
|
|
@ -217,6 +217,22 @@ client.login("m.login.password", {"user": settings.matrixuser, "password": setti
|
|
|
|
|
if (client.getUserId() == event.event.sender) {
|
|
|
|
|
return; // skip own messages to prevent loop
|
|
|
|
|
}
|
|
|
|
|
if (event.event.content.body.startsWith("!sms")) {
|
|
|
|
|
// capture command to start room for new number
|
|
|
|
|
const matches = event.event.content.body.match(/([1-9]?[0-9]{10})/g);
|
|
|
|
|
if (matches.length == 1) {
|
|
|
|
|
var tel = matches[0];
|
|
|
|
|
if (tel.length == 10) {
|
|
|
|
|
// make it the full number
|
|
|
|
|
tel = "1" + tel;
|
|
|
|
|
}
|
|
|
|
|
logger.info("Got request to start new SMS conversation with " + tel + " from " + event.event.sender + ".");
|
|
|
|
|
createOrJoinSMSRoom(tel, function () {
|
|
|
|
|
return;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//sendMatrix(room.roomId, "echo " + event.event.content.body);
|
|
|
|
|
//console.log(room);
|
|
|
|
|
const matches = room.name.match(/([1-9][0-9]+)/g);
|
|
|
|
|