-
Notifications
You must be signed in to change notification settings - Fork 4
/
gvactions.py
151 lines (145 loc) · 4.08 KB
/
gvactions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python
from sys import exit, argv
from googlevoice import Voice
import json
def doactions(count, gvaction, msgID, getID) :
if ((gvaction == "Deleted") and (msgID in getID)) :
message.delete()
count = count + 1
elif ((gvaction == "unDeleted") and (msgID in getID)) :
message.delete(0)
count = count + 1
elif ((gvaction == "unArchived") and (msgID in getID)) :
message.archive(0)
count = count + 1
elif ((gvaction == "Archived") and (msgID in getID)) :
message.archive()
count = count + 1
elif ((gvaction == "markUnread") and (msgID in getID)) :
message.mark(0)
count = count + 1
elif ((gvaction == "markRead") and (msgID in getID)) :
message.mark()
count = count + 1
elif ((gvaction == "unStarred") and (msgID in getID)) :
message.star(0)
count = count + 1
elif ((gvaction == "Starred") and (msgID in getID)) :
message.star()
count = count + 1
elif ((gvaction == "unBlocked") and (msgID in getID)) :
message.block(0)
count = count + 1
elif ((gvaction == "Blocked") and (msgID in getID)) :
message.block()
count = count + 1
elif ((gvaction == "unNoted") and (msgID in getID)) :
message.deleteNote()
count = count + 1
return count
voice = Voice()
try:
email = argv[1]
except:
print ('Error! Please provide Email Account. ')
exit(0)
try:
password = argv[2]
except:
print ('Error! Please provide Passsword. ')
exit(0)
try:
voice.login(email,password)
except:
print ('Error! Login failed. ')
exit(0)
try:
msgfolder = argv[3]
except:
print ('Error! Please provide a Message Folder an ACTION and Message ID. ')
voice.logout()
exit(0)
try:
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) :
break
elif msgfolder == "Messages" :
msglen = len(voice.sms().messages)
for message in voice.sms().messages:
counter = doactions(counter, ACTION, message.id , ID)
if (msglen == counter) :
break
elif msgfolder == "All" :
voice.all()
folder = voice.all.folder
msglen = len(folder.messages)
for message in folder.messages:
counter = doactions(counter, ACTION, message.id , ID)
if (msglen == counter) :
break
elif msgfolder == "Placed" :
msglen = len(voice.placed().messages)
for message in voice.placed().messages:
counter = doactions(counter, ACTION, message.id , ID)
if (msglen == counter) :
break
elif msgfolder == "Received" :
msglen = len(voice.received().messages)
for message in voice.received().messages:
counter = doactions(counter, ACTION, message.id , ID)
if (msglen == counter) :
break
elif msgfolder == "Spam" :
voice.spam()
folder = voice.spam.folder
msglen = len(folder.messages)
for message in folder.messages:
counter = doactions(counter, ACTION, message.id , ID)
if (msglen == counter) :
break
elif msgfolder == "Trash" :
voice.trash()
folder = voice.trash.folder
msglen = len(folder.messages)
for message in folder.messages:
counter = doactions(counter, ACTION, message.id , ID)
if (msglen == counter) :
break
elif msgfolder == "Missed" :
msglen = len(voice.missed().messages)
for message in voice.missed().messages:
counter = doactions(counter, ACTION, message.id , ID)
if (msglen == counter) :
break
except:
print ("Error! With" + msgfolder +", " + ACTION + " and " + ID + "Message ID's.")
print ACTION + " " + str(counter) + " Messages."
voice.logout()