#!/bin/bash ################################################################################ # Author: Fred (support@qo-op.com) # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ source ./init.sh source ./functions.sh log "${c_yellow}X sms_NEW.sh ($1=phone, $2=uid)$c_" PHONE="$1" MEMBERUID="$2" # Initialise PHONE, PIN, PUBKEY, UNIT sms_INIT_ACCOUNT "$PHONE" if [[ "$MEMBERUID" != "" && "$MEMBERUID" != "N" && "$MEMBERUID" != "D" && "$MEMBERUID" != "NOUV" ]]; then # UID RECEIVED in SMS VIRDEST=$MEMBERUID MEMRIB=$(sms_uid2key "$MEMBERUID" "$PHONE" "$PIN") [[ $MEMRIB == "" ]] && exit 1 MEMBER="$MEMBERUID" fi sms_INIT_ACCOUNT "$PHONE" "NOSMS" # Check account amount countvalues=($(check_account)) log "$(declare -p countvalues)" AMOUNTG1=${countvalues[0]} AMOUNT=${countvalues[1]} UNIT=${countvalues[2]} mess="[G1sms+] Id: $UIDNA $PIN Solde: $AMOUNT $UNIT (DAB: $DABID) " sms_SEND "$PHONE" "$mess" sleep 2 sms_SEND "$PHONE" "$PUBKEY" [[ $MEMRIB != "" ]] && sms_SEND "$PHONE" "Compte Atttaché: $MEMBER $MAIL $MEMRIB" # Add contact to database add_contact $PHONE $MEMBERUID && log "${c_green}Contact has been added to database$c_" || log "${c_red}Contact can't be added to database$c_" log "${c_yellow}END sms_NEW.sh$c_" log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~" exit