forked from ershad/Snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smsTrigger.py
76 lines (64 loc) · 2.33 KB
/
smsTrigger.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
#!/usr/bin/env python
#
# smsTrigger.py
# Author: Ershad K <[email protected]>
import gammu
import time
import os
def checkAndStart(str1, str2):
if str1 == "start" or str1 == "Start" or str1 == "START":
num = str2[:4]
num += '---'
num += str2[-3:]
os.system("pkill -9 eog") #Killing eog that displayed an image
# with number in full screen mode
os.system("clear")
os.system("figlet -f banner Thank you,")
print
print
numspaced = ""
for i in num:
numspaced += i + " "
print
print
os.system("figlet -f big %s -w 500" % numspaced)
print "\n\nThe presentation will start in 5 seconds!\n\n\n"
time.sleep(5)
os.system("ooimpress -show Presentation.odp")
exit(0)
sm = gammu.StateMachine()
sm.ReadConfig()
print "Init: GSM Device (Connecting..)"
sm.Init()
print "Success: GSM Device Connected!"
while True:
# print "Started new cycle!"
status = sm.GetSMSStatus()
remain = status['SIMUsed'] + status['PhoneUsed'] + status['TemplatesUsed']
sms = []
start = True
count = 0
timecount = time.time()
command = ""
number = ""
try:
while remain > 0:
if start:
cursms = sm.GetNextSMS(Start = True, Folder = 0)
command = cursms[0]['Text']
number = cursms[0]['Number'][-10:]
checkAndStart(command, number)
start = False
else:
cursms = sm.GetNextSMS(Location = cursms[0]['Location'], Folder = 0)
command = cursms[0]['Text']
number = cursms[0]['Number'][-10:]
checkAndStart(command, number)
try:
remain = remain - len(cursms)
sms.append(cursms)
except:
pass
except gammu.ERR_EMPTY:
pass
time.sleep(1)