Пример #1
0
def main():
	voice = Voice()
	voice.login()

	while 1:
		print "Starting loop\n" ### 
		for message in voice.inbox().messages:
			# Get text
			msg = message['messageText']
			phoneNumber = message['phoneNumber']
			
			# Pass to appropriate handler
			keyword = msg.split(" ")[0].lower()
			print "Keyword: %s\n\n"%keyword ###
			if keyword in handlers:
				replies = handlers[keyword](phoneNumber, msg)
			else:
				replies = {phoneNumber:"Command not found. Try these: %s"%(str(handlers.keys()))}			

			print "Replies: %s\n\n"%replies ###
			for phoneNum in replies:
				voice.send_sms(phoneNum, replies[phoneNum])	

			message.delete()
		time.sleep(1)
Пример #2
0
 def convoid(self, send="", pas="", id=""):  # take url args send, pas, and id
     html = []
     voice = Voice()
     voice.login(send, pas)
     voice.inbox()  # load google voice inbox
     messages = []
     for msg in extractConvo(voice.inbox.html, id):
         msgs = u"%s" % msg["text"]  # encode text as Unicode
         msgs = msgs.replace("\n", " ")  # replace new lines with spaces
         fr = str(msg["from"])  # get the sender's name
         total = ""
         total = fr + " " + msgs + "\n"  # create the total string
         messages.append(total)
     voice.logout()
     json.dumps(None)
     return json.dumps(messages)  # return info as JSON
Пример #3
0
 def getmsgs(self, send="", pas=""):  # take args send and pas
     html = []
     voice = Voice()
     voice.login(send, pas)
     voice.inbox()  # load google voice inbox
     messages = []
     ids = []
     last = ""
     inbox = settings.FEEDS[0]
     for message in getattr(voice, inbox)().messages:
         ids.append(message.items()[7][1])
     for id in ids:
         all = extractConvo(voice.inbox.html, id)
         lengthAll = len(all)
         for group in all[0 : lengthAll - 1]:
             messages.append([group[u"text"], group[u"from"]])
         messages.append(ids)
     voice.logout()
     json.dumps(None)
     return json.dumps(messages)  # return this info as JSON
Пример #4
0
	exit(0)
try:
	voice.login(email,password)
except:
	print ('Error! Login failed. ')
	exit(0)

try:
	command = argv[3]
except:
	print ('Error! Please provide a phone number or FOLDER. ')
	voice.logout()
	exit(0)

if command == "Inbox" :
	folder = voice.inbox().messages
	foundmsg = [ msg for msg in folder]
elif command == "Messages" :
	folder = voice.sms().messages
	foundmsg = [ msg for msg in folder]
elif command == "All" :
	voice.all()
	folder = voice.all.folder
	foundmsg = [ msg for msg in folder.messages]
elif command == "Spam" :	
	voice.spam()
	folder = voice.spam.folder
	foundmsg = [ msg for msg in folder.messages]
elif command == "Trash" :
	voice.trash()
	folder = voice.trash.folder
Пример #5
0
from googlevoice import Voice
import sys
from bs4 import BeautifulSoup

voice=Voice() # Create a Voice object
voice.login()
voice.inbox() # Get recent unread messages
htmlsms=voice.inbox.html  # Parse the messages into a HTML file

msgitems = [] # accumulate message items here
#	Extract all conversations by searching for a DIV with an ID at top level.
tree = BeautifulSoup(htmlsms)			# parse HTML into tree
conversations = tree.findAll("div",attrs={"id" : True},recursive=False)
for conversation in conversations :
    #	For each conversation, extract each row, which is one SMS message.
    rows = conversation.findAll(attrs={"class" : "gc-message-sms-row"})
    for row in rows :							# for all rows
        #	For each row, which is one message, extract all the fields.
        msgitem = {"id" : conversation["id"]}		# tag this message with conversation ID
        spans = row.findAll("span",attrs={"class" : True}, recursive=False)
        for span in spans : # for all spans in row
            cl = span["class"][0].replace('gc-message-sms-', '')
            msgitem[cl] = (" ".join(span.findAll(text=True))).strip()	# put text in dict
        msgitems.append(msgitem)					# add msg dictionary to list

for msg in msgitems:
    if msg['from'] != 'Me:':
        print "from: " + msg['from']
        print "text: " + msg['text']
        print "time: " + msg['time']
        print "------------------------------------"
Пример #6
0
	ACTION = argv[4]
except:
	print ('Error! Please provide a ACTION and Message ID. ')
	voice.logout()
	exit(0)
try:
	ID = json.loads(argv[5])
except:
	print ('Error! Please provide a Message ID. ')
	voice.logout()
	exit(0)

counter = 0
try:
	if msgfolder == "Inbox" :
		msglen = len(voice.inbox().messages)
		for message in voice.inbox().messages:
			counter = doactions(counter, ACTION, message.id , ID)
			if (msglen == counter) :
				break
	elif msgfolder == "Voicemail" :
		msglen = len(voice.voicemail().messages)
		for message in voice.voicemail().messages:
			counter = doactions(counter, ACTION, message.id , ID)
			if (msglen == counter) :
				break
	elif msgfolder == "Recorded" :
		msglen = len(voice.recorded().messages)
		for message in voice.recorded().messages: 
			counter = doactions(counter, ACTION, message.id , ID)
			if (msglen == counter) :
Пример #7
0
try:
	command = argv[3]
except:
	print ('Error! Please provide a FOLDER. ')
	voice.logout()
	exit(0)
	
try:
	ID = argv[4]
except:
	print ('Error! Please provide a Message ID. ')
	voice.logout()
	exit(0)

if command == "Inbox" :
	voice.inbox()
	allmessages = extractdata(voice.inbox.html)
elif command == "Voicemail" :
	voice.voicemail()
	allmessages = extractdata(voice.voicemail.html)
elif command == "Recorded" :
	voice.recorded()
	allmessages = extractdata(voice.recorded.html)
elif command == "Messages" :
	voice.sms()
	allmessages = extractdata(voice.sms.html)
elif command == "All" :
	voice.all()
	allmessages = extractdata(voice.all.html)
elif command == "Spam" :
	voice.spam()
Пример #8
0
from googlevoice import Voice
import sys
from bs4 import BeautifulSoup

voice = Voice()  # Create a Voice object
voice.login()
voice.inbox()  # Get recent unread messages
htmlsms = voice.inbox.html  # Parse the messages into a HTML file

msgitems = []  # accumulate message items here
#	Extract all conversations by searching for a DIV with an ID at top level.
tree = BeautifulSoup(htmlsms)  # parse HTML into tree
conversations = tree.findAll("div", attrs={"id": True}, recursive=False)
for conversation in conversations:
    #	For each conversation, extract each row, which is one SMS message.
    rows = conversation.findAll(attrs={"class": "gc-message-sms-row"})
    for row in rows:  # for all rows
        #	For each row, which is one message, extract all the fields.
        msgitem = {
            "id": conversation["id"]
        }  # tag this message with conversation ID
        spans = row.findAll("span", attrs={"class": True}, recursive=False)
        for span in spans:  # for all spans in row
            cl = span["class"][0].replace('gc-message-sms-', '')
            msgitem[cl] = (" ".join(
                span.findAll(text=True))).strip()  # put text in dict
        msgitems.append(msgitem)  # add msg dictionary to list

for msg in msgitems:
    if msg['from'] != 'Me:':
        print "from: " + msg['from']