-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_sms.py
70 lines (54 loc) · 2.22 KB
/
send_sms.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from twilio.rest import Client
from twilio.twiml.voice_response import VoiceResponse
from flask import Flask, Response, send_from_directory
from flask import request
app = Flask(__name__)
ACCOUNT_SID = 'ACcefa2306ccdba981522a00c621e602ab'
AUTH_TOKEN = 'ba3216346af36cf72ad0fb48e45e5b8e'
PHONE = '+971556383129'
CUSTOMER = '+41794477448'
JOB_REQUEST = """لقد وجدنا فرصة عمل تناسبك!
المكان: منطقة كوجاتيبي، شارع مختار بيك، بناء رقم ١-٢٠١ / اسطنبول، تركيا
Kocatepe Mahallesi, Şht. Muhtar Bey Cd. No:1, 201 Beyoğlu/İstanbul, Turkey
الوقت: الأحد ١٦-٤-٢٠١٧
الثمن: ٣٠ ليرة
للمزيد من المعلومات أرسل 1
للرفض أرسل 2"""
JOB_DETAILS = """التفاصيل:
إصلاح مغسلة ماء ليست تعمل جيدا، لا يخرج منها ماء أبدا ويصعب تحريك مقبضها.
للتأكيد أرسل 1
للرفض أرسل 2"""
JOB_CONFIRMATION = "السيد محمد في انتظارك!"
CUSTOMER_CONFIRM = "Sizin için yetenekli bir tesisatçı bulduk! Adı Amro ve bugün ev saat 14'de evinde olacak."
client = Client(ACCOUNT_SID, AUTH_TOKEN)
STATE = "PROPOSING"
@app.route("/", methods=["GET"])
def hello():
return send_from_directory("/", "index.html")
@app.route("/send")
def send_sms():
global client
global STATE
print 'Sending a message...'
new_message = client.messages.create(to=PHONE, from_='+19143025185', body=JOB_REQUEST)
STATE = "PROPOSING"
return "Thank you!"
@app.route("/receive_sms")
def receive_sms():
global STATE
if STATE == "PROPOSING":
new_message = client.messages.create(to=PHONE, from_='+19143025185', body=JOB_DETAILS)
STATE = "DETAILS"
elif STATE == "DETAILS":
new_message_1 = client.messages.create(to=PHONE, from_='+19143025185', body=JOB_CONFIRMATION)
new_message_2 = client.messages.create(to=CUSTOMER, from_='+19143025185', body=CUSTOMER_CONFIRM)
STATE = "OK"
else:
new_message_1 = client.messages.create(to=PHONE, from_='+19143025185', body='لقد تم التحقق من العملية بنجاح!')
STATE = "PROPOSING"
return "OK!"
if __name__ == "__main__":
app.run()