verify numbers with pn

master
noneofyourbusiness 4 years ago committed by Stacy Harper
parent e444553ae4
commit 3599be95f4
No known key found for this signature in database
GPG Key ID: 5BAC92328B7C5D65
  1. 17
      scripts/core/sxmo_contactmenu.sh
  2. 1
      scripts/core/sxmo_contacts.sh
  3. 2
      scripts/modem/sxmo_modemcall.sh
  4. 23
      scripts/modem/sxmo_modemmonitor.sh

@ -4,14 +4,19 @@
. "$(dirname "$0")/sxmo_common.sh"
valid_number() {
number="$(echo "$1" | sed "s/^0\([0-9]\{9\}\)$/${DEFAULT_NUMBER_PREFIX:-0}\1/")"
if pn valid "$1"; then
echo "$1"
return
fi
if echo "$number" | grep -q "^+[0-9]\{11\}$"; then
echo "$number"
else
notify-send "\"$number\" is not a valid phone number"
notify-send "Valid format is \"+[0-9]{11}\""
REFORMATTED="$(pn find ${DEFAULT_COUNTRY:+-c "$DEFAULT_COUNTRY"} "$1")"
if pn valid "$REFORMATTED"; then
echo "$REFORMATTED"
return
fi
notify-send "\""$1"\" is not a valid phone number"
exit
}
newcontact() {

@ -18,7 +18,6 @@ LOGFILE="$XDG_DATA_HOME"/sxmo/modem/modemlog.tsv
prepare_contacts_list() {
cut -f3 |
sed "s/^0\([0-9]\{9\}\)$/${DEFAULT_NUMBER_PREFIX:-0}\1/" |
tac |
awk '!($0 in a){a[$0]; print}' |
sed '/^[[:space:]]*$/d' |

@ -53,7 +53,7 @@ vid_to_number() {
}
number_to_contactname() {
NUMBER="$(echo "$1" | sed "s/^0\([0-9]\{9\}\)$/${DEFAULT_NUMBER_PREFIX:-0}\1/")"
NUMBER="$1"
CONTACT=$(sxmo_contacts.sh --all |
grep "^$NUMBER:" |
cut -d':' -f 2 |

@ -35,6 +35,21 @@ modem_n() {
err "Couldn't find modem - is your modem enabled? Disabling modem monitor"
}
cleanupnumber() {
if pn valid "$1"; then
echo "$1"
return
fi
REFORMATTED="$(pn find ${DEFAULT_COUNTRY:+-c "$DEFAULT_COUNTRY"} "$1")"
if [ -n "$REFORMATTED" ]; then
echo "$REFORMATTED"
return
fi
echo "$1"
}
lookupnumberfromcallid() {
VOICECALLID=$1
mmcli -m "$(modem_n)" --voice-list-calls -o "$VOICECALLID" -K |
@ -47,16 +62,15 @@ lookupcontactname() {
if [ "$1" = "--" ]; then
echo "Unknown number"
else
NUMBER="$(echo "$1" | sed "s/^0\([0-9]\{9\}\)$/${DEFAULT_NUMBER_PREFIX:-0}\1/")"
CONTACT=$(sxmo_contacts.sh --all |
grep "^$NUMBER:" |
grep "^$1:" |
cut -d':' -f 2 |
sed 's/^[ \t]*//;s/[ \t]*$//' #strip leading/trailing whitespace
)
if [ -n "$CONTACT" ]; then
echo "$CONTACT"
else
echo "Unknown ($NUMBER)"
echo "Unknown ($1)"
fi
fi
}
@ -70,6 +84,7 @@ checkforfinishedcalls() {
cut -d'/' -f2
); do
FINISHEDNUMBER="$(lookupnumberfromcallid "$FINISHEDCALLID")"
FINISHEDNUMBER="$(cleanupnumber "$FINISHEDNUMBER")"
mmcli -m "$(modem_n)" --voice-delete-call "$FINISHEDCALLID"
rm -f "$CACHEDIR/${FINISHEDCALLID}.monitoredcall"
@ -142,6 +157,7 @@ checkforincomingcalls() {
# Determine the incoming phone number
echo "sxmo_modemmonitor: Incoming Call:">&2
INCOMINGNUMBER=$(lookupnumberfromcallid "$VOICECALLID")
INCOMINGNUMBER="$(cleanupnumber "$INCOMINGNUMBER")"
CONTACTNAME=$(lookupcontactname "$INCOMINGNUMBER")
xset dpms force on
@ -181,6 +197,7 @@ checkfornewtexts() {
grep sms.content.number |
sed -E 's/^sms\.content\.number\s+:\s+//'
)"
NUM="$(cleanupnumber "$NUM")"
TIME="$(echo "$TEXTDATA" | grep sms.properties.timestamp | sed -E 's/^sms\.properties\.timestamp\s+:\s+//')"
mkdir -p "$LOGDIR/$NUM"

Loading…
Cancel
Save