-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtestingsession.py
More file actions
78 lines (60 loc) · 1.87 KB
/
testingsession.py
File metadata and controls
78 lines (60 loc) · 1.87 KB
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
from cred import *
from mainn import *
from dbase import *
from flask_session import Session
path = 'UserDetails.db'
conn = sqlite3.connect(path, check_same_thread=False)
c = conn.cursor()
# Twilio connection
client = Client(account_sid, auth_token)
# Flask connection
app = Flask(__name__)
app.config['SESSION_TYPE'] = 'filesystem'
app.config['SECRET_KEY'] = 'dljkjwdo2knds'
Session(app)
#sslify = SSLify(app)
# Bot connection
bot = telebot.TeleBot(API_TOKEN, threaded=False)
bot.remove_webhook()
bot.set_webhook(url=callurl)
# Some variables
# userid = None
# chat_id = None
# Process webhook calls
@app.route('/', methods=['GET', 'POST'])
def webhook():
if flask.request.headers.get('content-type') == 'application/json':
json_string = flask.request.get_data().decode('utf-8')
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return ''
else:
print("error")
flask.abort(403)
# Handle '/start'
@bot.message_handler(commands=['start'])
def send_welcome(message):
send = bot.send_message(message.chat.id, "what is your name")
bot.register_next_step_handler(send, function2)
def function2(message):
name = message.text
userid = message.from_user.id
chat_id = userid
session['userid'] = f'{userid}'
session['chat_id'] = f'{chat_id}'
phonenumber = fetch_phonenumber(userid)
print(phonenumber)
call = client.calls.create(url=(callurl + '/abc'),
to='+13109612827',
from_='+19108124952')
print(call.sid)
@app.route("/abc", methods=['GET', 'POST'])
def abc():
userid3 = session.get('userid', None)
chatid4 = session.get('userid', None)
print(userid3)
resp = VoiceResponse()
resp.say(f"Your user id is {userid3}")
return str(resp)
if __name__ == '__main__':
app.run(debug=True)