#!/bin/bash

GVACCT="mundyclan2@gmail.com"
GVPASS="voodoo64"

# SMS Message Blaster (c) Copyright 2012, Ward Mundy & Associates LLC. All Rights Reserved.
#
#             SMS Message Blaster is licensed under the GPL2 license
#
#  For a copy of license, visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
#  For additional information, contact us: http://pbxinaflash.com/about/comment.php


# ----------- INSTRUCTIONS ------------------------------

# This script sends an SMS messsage stored in smsmsg.txt
# to a list of recipients stored in smslist.txt. No error
# checking is provided. pygooglevoice is required to send.
# Insert your Google Voice account credentials above.
# smsmsg.txt should be the plain text message to be sent.
# The plain text message should be limited to 160 characters.
# smslist.txt is the list of recipients for this SMS message.
# Each line of smslist.txt must contain a 10-digit number.
# Optionally, you may add a space after the phone number
# and include a name associated with that phone number.
# These name entries are not used in the message blasting.
# They simply make it easier for you to maintain your list.


# ----------- Don't make code changes below here --------

SMSLIST="smslist.txt"
SMSMSG=`cat smsmsg.txt`

index=0

while read -a ACCOUNT
 do
 if [ -n "${ACCOUNT[0]}" ]
 then
  if [ "${ACCOUNT[0]:0:1}" != "#" ]
  then
   NUM2CALL[$index]="${ACCOUNT[0]}"
   index=$(($index+1))
  fi
 fi
 done < $SMSLIST

echo "$index SMS messages to process:"

for SMSNUM in "${NUM2CALL[@]}"
do
 echo "Sending SMS message to: $SMSNUM"
 gvoice -e $GVACCT -p $GVPASS send_sms $SMSNUM "$SMSMSG"
done

