Some weird message makes it crash

This commit is contained in:
Skylar Ittner 2023-09-05 21:14:48 -06:00
parent dcc8f7a610
commit ad7eb83c66

View File

@ -491,7 +491,7 @@ client.login("m.login.password", {"user": settings.matrixuser, "password": setti
if (client.getUserId() == event.getSender()) {
return; // skip own messages to prevent loop
}
if (event.getContent() == null || typeof event.getContent().body == "undefined") {
if (event.getContent() == null || typeof event.getContent().body == "undefined" || event.getContent().body == null) {
// Apparently this can happen?
return;
}
@ -499,6 +499,9 @@ client.login("m.login.password", {"user": settings.matrixuser, "password": setti
if (event.getContent().body.toLowerCase().startsWith("!sms")) {
// capture command to start room for new number
const matches = event.getContent().body.match(/([1-9]?[0-9]{10})/g);
if (matches == null) {
return;
}
if (matches.length == 1 || matches.length == 2) {
var tel = matches[0];
var ournumber = settings.smsfrom;