-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathviewscopy.py
More file actions
executable file
·1013 lines (774 loc) · 34.4 KB
/
viewscopy.py
File metadata and controls
executable file
·1013 lines (774 loc) · 34.4 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from django.shortcuts import render
from django.http import HttpResponse
import urllib2
from django.views import generic
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
import json
import requests
from reportlab.pdfgen import canvas
from reportlab.lib import colors
from reportlab.platypus import Image
from django.http import HttpResponse
import urllib2
from django.utils.decorators import method_decorator
import json
import requests
from chatbot.models import event,resume_input
# Create your views here.
sender_id = 'ba'
VERIFY_TOKEN = '7thseptember2016'
PAGE_ACCESS_TOKEN = 'EAAJz4ZB0zviUBAGrx1T1dvrS2dT4tMlZCam9JcTcWOZBWutdyFQLHpIXVbIszjMi3Ive6yWK30Qo9orezqF5nLcaVJYaAEnDMGtF7xJzgz28xFyk0KOmjmu5PMQHj06FOElFiZCj5HXcdOlHTLrzmYvthplc3IhMfizoi6YvwgZDZD'
API_token = '85b82a55e643435fb11b903effdb9b3b'
def userdeatils(fbid):
url = 'https://graph.facebook.com/v2.6/' + fbid + '?fields=first_name,last_name,profile_pic,locale,timezone,gender&access_token=' + PAGE_ACCESS_TOKEN
resp = requests.get(url=url)
data =json.loads(resp.text)
return data
def post_facebook_message(fbid,message_text):
post_message_url = 'https://graph.facebook.com/v2.6/me/messages?access_token=%s'%PAGE_ACCESS_TOKEN
# response_msg = json.dumps({"recipient":{"id":fbid}, "message":{"text":message_text}})
# status = requests.post(post_message_url, headers={"Content-Type": "application/json"},data=response_msg)
# print status.json()
if message_text == 'templates':
response_msg = cards(fbid)
elif message_text == 'selection' :
response_msg = selectcard(fbid)
elif message_text == 'resume download':
response_msg = card_resume(fbid)
elif message_text == 'blah':
response_msg = quickreplies(fbid)
else:
response_msg = json.dumps({"recipient":{"id":fbid}, "message":{"text":message_text}})
requests.post(post_message_url,
headers={"Content-Type": "application/json"},
data=response_msg)
#for card resume
def card_resume(fbid):
response_object = {
"recipient": {
"id": fbid
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "RESUME",
"subtitle": "Don,t wait just click",
"item_url": "https://myresumemaker.herokuapp.com/resume/%s"%(fbid),
"item_url": "https://myresumemaker.herokuapp.com/resume/%s"%(fbid),
"image_url": "https://placeholdit.imgix.net/~text?txtsize=50&txt=Download%20Resume&w=400&h=500",
"buttons": [{
"type": "web_url",
"url": "https://myresumemaker.herokuapp.com/resume/%s"%(fbid),
"title": "DOWNLOAD"
}, {
"type": "element_share"
}]
}]
}
}
}
}
return json.dumps(response_object)
def cards(fbid):
response_object = {
"recipient": {
"id": fbid
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "party theme",
"subtitle": "party,fests,weddings,birthdays etc",
"item_url": "https://myresumemaker.herokuapp.com/temp1/%s"%(fbid),
"image_url": "https://scontent-sit4-1.xx.fbcdn.net/v/l/t35.0-12/14800069_1785774908361060_98733447_o.png?oh=5e3268cb388a25f6d84cb2c27b3c757f&oe=580A723E",
"buttons": [{
"type": "web_url",
"url": "https://myresumemaker.herokuapp.com/temp1/%s"%(fbid),
"title": "Open your website in this theme"
}, {
"type": "element_share"
}],
}, {
"title": "hackathon theme",
"subtitle": "all tech competitions them",
"item_url": "https://myresumemaker.herokuapp.com/temp2/%s"%(fbid),
"image_url": "https://scontent-sit4-1.xx.fbcdn.net/v/t35.0-12/14795941_1785774938361057_1017427262_o.png?oh=6809b9c14ee2646703a8047da8b2c479&oe=580A89BA",
"buttons": [{
"type": "web_url",
"url": "https://myresumemaker.herokuapp.com/temp2/%s"%(fbid),
"title": "Open your website in this theme"
}, {
"type": "element_share"
}]
}]
}
}
}
}
return json.dumps(response_object)
#select card function
def selectcard(fbid):
response_object ={
"recipient":{
"id":fbid
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"elements":[
{
"title":"Resume",
"image_url":"https://placeholdit.imgix.net/~text?txtsize=70&txt=Resume&w=450&h=500",
"subtitle":"Make a resume",
"buttons":[
{
"type":"postback",
"title":"Resume",
"payload":"RESUME"
}
]
},
{
"title":"Event Website",
"image_url":"https://placeholdit.imgix.net/~text?txtsize=70&txt=Event%20Website&w=450&h=500",
"subtitle":"Make an Event website",
"buttons":[
{
"type":"postback",
"title":"event-website",
"payload":"EVENT"
}
]
}
]
}
}
}
}
return json.dumps(response_object)
#for quick replies
def quickreplies(fbid):
response_object = {
"recipient":{
"id":fbid
},
"message":{
"text":"Pick a field:",
"quick_replies":[
{
"content_type":"text",
"title":"event name",
"payload":"NAME"
},
{
"content_type":"text",
"title":"Contact Number",
"payload":"number"
},
{
"content_type":"text",
"title":"Tagline",
"payload":"tagline"
},
{
"content_type":"text",
"title":"Green",
"payload":"test2"
},
{
"content_type":"text",
"title":"Green",
"payload":"test2"
},
{
"content_type":"text",
"title":"Green",
"payload":"test2"
},
{
"content_type":"text",
"title":"Green",
"payload":"test2"
},
]
}
}
return json.dumps(response_object)
class MyChatBotView(generic.View):
def get (self, request, *args, **kwargs):
if self.request.GET['hub.verify_token'] == VERIFY_TOKEN:
return HttpResponse(self.request.GET['hub.challenge'])
else:
return HttpResponse('Oops invalid token')
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return generic.View.dispatch(self, request, *args, **kwargs)
def post(self, request, *args, **kwargs):
global sender_id
incoming_message= json.loads(self.request.body.decode('utf-8'))
print incoming_message
for entry in incoming_message['entry']:
for message in entry['messaging']:
print message
try:
sender_id = message['sender']['id']
message_text = message['message']['text']
p = event.objects.get_or_create(fbid =sender_id)[0]
pp = resume_input.objects.get_or_create(fbid =sender_id)[0]
a= userdeatils(sender_id)
name = '%s %s'%(a['first_name'],a['last_name'])
if message_text.lower() in 'hi,hello,hey,supp'.split(','):
print 'hihihihihihihihihih'+ sender_id
post_facebook_message(sender_id,'Hey , ' + name +', This is a automated chatting software it will ask u your details about your resume or event website and in the end voila u will get ypur own e-resume pdf resume or a website of your event. Lets get started by selecting what u want to make today ')
post_facebook_message(sender_id,'selection')
elif p.state =='1':
p.name = message_text
p.save()
print 'hihihihihihihihihih'+ sender_id
# post_facebook_message(sender_id,'great ,Now Please tell me your contact phone number to be displayed on the page ')
post_facebook_message(sender_id,'blah')
elif p.state =='2':
p.contact = message_text
p.save()
# post_facebook_message(sender_id,'okay, now tell me your tagline for the event ')
post_facebook_message(sender_id,'blah')
elif p.state =='3':
p.tagline = message_text
p.save()
post_facebook_message(sender_id,'blah')
elif p.state =='4':
p.datestart = message_text
p.state='5'
p.save()
post_facebook_message(sender_id,'okay, now tell me your end date for the event dd/mm/yy format ')
elif p.state =='5':
p.dateend = message_text
p.state='6'
p.save()
post_facebook_message(sender_id,' Now, Please tell me your organiser name to be displayed on the page ')
elif p.state =='6':
p.oname = message_text
p.state='7'
p.save()
post_facebook_message(sender_id,'Now , Please tell me your conatct email id to be displayed on the page ')
elif p.state =='7':
p.emailid = message_text
p.state='8'
p.save()
post_facebook_message(sender_id,'Now , Please tell if u have any twitter id if yes send its link otherwise just send no ')
elif p.state =='8':
p.twitterlink = message_text
p.state='9'
p.save()
post_facebook_message(sender_id,'Now , Please tell if u have any fabeook page if yes send its link otherwise just send no ')
elif p.state =='9':
p.fblink = message_text
p.state='10'
p.save()
post_facebook_message(sender_id,'Now , send me description of the event ')
elif p.state =='10':
p.description = message_text
p.state='11'
p.save()
post_facebook_message(sender_id,'if u have a logo please send its link if not just send no ')
elif p.state =='11':
p.logolink = message_text
p.state='12'
p.save()
post_facebook_message(sender_id,'Now , send me location of the event in one line seperated by commas ')
elif p.state =='12':
p.location = message_text
p.state='13'
p.save()
post_facebook_message(sender_id,'send me the details of the 1st sub event ')
elif p.state =='13':
p.sub1 = message_text
p.state='14'
p.save()
post_facebook_message(sender_id,' send me the details of the 2st sub event ')
elif p.state =='14':
p.sub2 = message_text
p.state='15'
p.save()
post_facebook_message(sender_id,' send me the details of the 3st sub event ')
elif p.state =='15':
p.sub3 = message_text
p.state='16'
p.save()
post_facebook_message(sender_id,' send me the details of the 4st sub event ')
print 'hi hi hi hi hi hi ' + sender_id
print 'hi hi hi hi hi hi ' + sender_id
print 'hi hi hi hi hi hi ' + sender_id
print 'hi hi hi hi hi hi ' + sender_id
print 'hi hi hi hi hi hi ' + sender_id
elif p.state =='16':
p.sub4 = message_text
p.state='17'
p.save()
print sender_id
post_facebook_message(sender_id,' please select one of the templates given below ')
post_facebook_message(sender_id,'templates')
elif pp.state =='1':
pp.emailid = message_text
pp.state='3'
pp.save()
post_facebook_message(sender_id,'Your date of birth')
elif pp.state =='3':
pp.dob = message_text
pp.state='4'
pp.save()
post_facebook_message(sender_id,'Great ,Now Please tell me your contact PHONE NUMBER to be displayed on the resume ')
elif pp.state =='4':
pp.contact = message_text
pp.state='5'
pp.save()
post_facebook_message(sender_id,'Great ,Now Please provide me your LinkedIn id')
elif pp.state =='5':
pp.LinkedIn = message_text
pp.state='6'
pp.save()
post_facebook_message(sender_id,'Now your city of residence')
elif pp.state =='6':
pp.city = message_text
pp.state='7'
pp.save()
post_facebook_message(sender_id,'okay, now your Summary or Objective. KEY POINTS to be included are 1)Start with your professional title 2)Add two or three achievements , Your professional tittle and a line describing you ')
elif pp.state =='7':
pp.objective_line1 = message_text
pp.state='8'
pp.save()
post_facebook_message(sender_id,'Okay, your achievements if any')
elif pp.state =='8':
pp.objective_achievements = message_text
pp.state='9'
pp.save()
post_facebook_message(sender_id,'Great , now tell me your educational qualification include your year of passing , institute name,first')
elif pp.state =='9':
pp.educational_qualifications_1 = message_text
pp.state ='10'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state=='10':
for i in range(1):
if message_text == 'no':
pp.state = '12'
pp.save()
post_facebook_message(sender_id,'')
else :
pp.educational_qualifications_2 = message_text
pp.state = '11'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state=='11':
for i in range(1):
if message_text == 'no':
pp.state = '12'
pp.save()
post_facebook_message(sender_id,'COOL,type no to continue')
else :
pp.educational_qualifications_3 = message_text
pp.state = '12'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state =='12':
if message_text=='no' :
pp.state ='13'
pp.save()
post_facebook_message(sender_id,'Great , now tell me your skills in your field,first')
else:
pp.educational_qualifications_4 = message_text
pp.state ='13'
pp.save()
post_facebook_message(sender_id,'Great , now tell me your skills in your field,first')
elif pp.state =='13':
pp.skills_1 = message_text
pp.state ='15'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state=='15':
for i in range(1):
if message_text == 'no':
pp.state = '17'
pp.save()
post_facebook_message(sender_id,'COOL,type no to continue')
else :
pp.skills_2 = message_text
pp.state = '16'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state=='16':
for i in range(1):
if message_text == 'no':
pp.state = '17'
pp.save()
post_facebook_message(sender_id,'COOL,type no to continue')
else :
pp.skills_3 = message_text
pp.state = '17'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state =='17':
if message_text=='no':
pp.state ='18'
pp.save()
post_facebook_message(sender_id,'Great , now tell me your experience,first')
else:
pp.skills_4 = message_text
pp.state ='18'
pp.save()
post_facebook_message(sender_id,'Great , now tell me your experience,first')
elif pp.state =='18':
pp.experience_1 = message_text
pp.state ='20'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state=='20':
for i in range(1):
if message_text == 'no':
pp.state = '22'
pp.save()
post_facebook_message(sender_id,'COOL,type no to continue')
else :
pp.experience_2 = message_text
pp.state = '21'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state=='21':
for i in range(1):
if message_text == 'no':
pp.state = '22'
pp.save()
post_facebook_message(sender_id,'COOL,type no to continue')
else :
pp.experience_3 = message_text
pp.state = '22'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state =='22':
if message_text == 'no':
pp.state ='23'
pp.save()
post_facebook_message(sender_id,'Great , now tell me your hobbies,first')
else:
pp.experience_4 = message_text
pp.state ='23'
pp.save()
post_facebook_message(sender_id,'Great , now tell me your hobbies,first')
elif pp.state =='23':
pp.hobbies_1 = message_text
pp.state ='25'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state=='25':
for i in range(1):
if message_text == 'no':
pp.state = '28'
pp.save()
post_facebook_message(sender_id,'COOL,type no to continue')
else :
pp.hobbies_2 = message_text
pp.state = '26'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state=='26':
for i in range(1):
if message_text == 'no':
pp.state = '28'
pp.save()
post_facebook_message(sender_id,'COOL,type no to continue')
else :
pp.hobbies_3 = message_text
pp.state = '27'
pp.save()
post_facebook_message(sender_id,'Any more? if no simply type no')
elif pp.state =='27':
if message_text == 'no':
pp.state ='28'
pp.save()
post_facebook_message(sender_id,'name')
else:
pp.experience_4 = message_text
pp.state ='28'
pp.save()
post_facebook_message(sender_id,'name')
elif pp.state =='28':
pp.name = message_text
pp.save()
post_facebook_message(sender_id,' you are done with providing the detail, now click the link that will automatically download a pdf name mycv.pdf')
post_facebook_message(sender_id,'resume download')
else:
post_facebook_message(sender_id,'please, say ,hey ,hi ,hello ,supp to start a conversation')
except Exception as e:
print e
pass
try:
if 'postback' in message:
handle_postback(message['sender']['id'],message['postback']['payload'])
return HttpResponse()
else:
pass
except Exception as e:
print e
pass
return HttpResponse()
def resume(request,id):
# Create the HttpResponse object with the appropriate PDF headers.
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="mycv.pdf"'
# Create the PDF object, using the response object as its "file."
p = canvas.Canvas(response)
pp = resume_input.objects.get_or_create(fbid=id)[0]
#print dir(p)
# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
p.setFont("Helvetica", 20)
p.drawString(230,820, pp.name)
p.setFont("Helvetica", 8)
p.drawString(230,810,pp.emailid)
p.drawString(230,800,pp.contact)
p.drawString(230,790,pp.dob)
p.drawString(230,780,pp.LinkedIn)
p.drawString(230,770,pp.city)
p.setFont("Helvetica", 13)
p.drawString(0,750,"Objective")
p.setStrokeColor(colors.red)
p.line(0,745,500,745)
p.setFont("Helvetica", 9)
p.drawString(20,735,pp.objective_line1)
p.drawString(20,725,pp.objective_achievements)
p.setFont("Helvetica", 13)
p.drawString(0,705,"Educational Qualifications ")
p.setStrokeColor(colors.red)
p.line(0,700,500,700)
p.setFont("Helvetica", 9)
p.drawString(20,690,pp.educational_qualifications_1)
p.drawString(20,680,pp.educational_qualifications_2)
p.drawString(20,670,pp.educational_qualifications_3)
p.drawString(20,660,pp.educational_qualifications_4)
p.drawString(0,640,"Experience")
p.setStrokeColor(colors.red)
p.line(0,635,500,635)
p.setFont("Helvetica", 9)
p.drawString(20,625,pp.experience_1)
p.drawString(20,625,pp.experience_1)
p.drawString(20,605,pp.experience_1)
p.drawString(20,595,pp.experience_1)
p.setFont("Helvetica", 13)
p.drawString(0,575,"Skills")
p.setStrokeColor(colors.red)
p.line(0,570,500,570)
p.setFont("Helvetica", 9)
p.drawString(20,560,pp.skills_1)
p.drawString(20,550,pp.skills_2)
p.drawString(20,540,pp.skills_3)
p.drawString(20,530,pp.skills_4)
p.setFont("Helvetica", 13)
p.drawString(0,510,"Hobbies")
p.setStrokeColor(colors.red)
p.line(0,505,500,505)
p.setFont("Helvetica", 9)
p.drawString(20,495,pp.hobbies_1)
p.drawString(20,485,pp.hobbies_2)
p.drawString(20,475,pp.hobbies_3)
p.drawString(20,465,pp.hobbies_4)
p.showPage()
p.save()
return response
def index(request):
set_menu()
handle_postback('fbid','MENU_WHY')
greeting_text()
greeting_button()
context_dict = {}
context_dict['fbid'] = sender_id
return render(request,'chatbot/index.html', context_dict)
def eventweb(request,id):
#fbid = '1047867078643788'
p = event.objects.get_or_create(fbid =id)[0]
name = p.name
location = p.location
logolink = p.logolink
description = p.description
fblink = p.fblink
emailid = p.emailid
oname = p.oname
dateend = p.dateend
datestart = p.datestart
contact = p.contact
tagline = p.tagline
twitterlink = p.twitterlink
sub1 = p.sub1
sub2 = p.sub2
sub3 = p.sub3
sub4 = p.sub4
context_dict = {}
context_dict['eventname'] = name
context_dict['location'] = location
context_dict['logolink'] = logolink
context_dict['description'] = description
context_dict['fblink'] = fblink
context_dict['emailid'] = emailid
context_dict['organisername'] = oname
context_dict['dateend'] = dateend
context_dict['datestart'] = datestart
context_dict['contact'] = contact
context_dict['tagline'] = tagline
context_dict['twitterlink'] = twitterlink
context_dict['sub1'] = sub1
context_dict['sub2'] = sub2
context_dict['sub3'] = sub3
context_dict['sub4'] = sub4
return render(request,'chatbot/temp1.html',context_dict)
def eventweb2(request,id):
#fbid = '1047867078643788'
p = event.objects.get_or_create(fbid = id)[0]
name = p.name
location = p.location
logolink = p.logolink
description = p.description
fblink = p.fblink
emailid = p.emailid
oname = p.oname
dateend = p.dateend
datestart = p.datestart
contact = p.contact
tagline = p.tagline
twitterlink = p.twitterlink
sub1 = p.sub1
sub2 = p.sub2
sub3 = p.sub3
sub4 = p.sub4
context_dict = {}
context_dict['eventname'] = name
context_dict['location'] = location
context_dict['logolink'] = logolink
context_dict['description'] = description
context_dict['fblink'] = fblink
context_dict['emailid'] = emailid
context_dict['organisername'] = oname
context_dict['dateend'] = dateend
context_dict['datestart'] = datestart
context_dict['contact'] = contact
context_dict['tagline'] = tagline
context_dict['twitterlink'] = twitterlink
context_dict['sub1'] = sub1
context_dict['sub2'] = sub2
context_dict['sub3'] = sub3
context_dict['sub4'] = sub4
return render(request,'chatbot/temp2.html',context_dict)
def eventreg(request):
context_dict = {}
return render(request,'chatbot/shop.html',context_dict)
def set_menu():
post_message_url = 'https://graph.facebook.com/v2.6/me/thread_settings?access_token=%s'%PAGE_ACCESS_TOKEN
response_object = {
"setting_type" : "call_to_actions",
"thread_state" : "existing_thread",
"call_to_actions":[
{
"type":"postback",
"title":"Your event website",
"payload":"MENU_OUTPUT"
},
{
"type":"postback",
"title":"Our website",
"payload":"MENU_LINK"
},
{
"type":"postback",
"title":"Why Master Event",
"payload":"MENU_WHY"
}
]
}
menu_object = json.dumps(response_object)
status = requests.post(post_message_url,
headers = {"Content-Type": "application/json"},
data = menu_object)
def greeting_text():
post_message_url = 'https://graph.facebook.com/v2.6/me/thread_settings?access_token=%s'%PAGE_ACCESS_TOKEN
response_object = {
"setting_type":"greeting",
"greeting":{
"text":"make your resume in seconds"
}
}
menu_object = json.dumps(response_object)
status = requests.post(post_message_url,
headers = {"Content-Type": "application/json"},
data = menu_object)
def greeting_button():
post_message_url = 'https://graph.facebook.com/v2.6/me/thread_settings?access_token=%s'%PAGE_ACCESS_TOKEN
response_object = {
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"payload":"STARTING"
}
]
}
menu_object = json.dumps(response_object)
status = requests.post(post_message_url,
headers = {"Content-Type": "application/json"},
data = menu_object)
def handle_postback(fbid,payload):
post_message_url = 'https://graph.facebook.com/v2.6/me/messages?access_token=%s'%PAGE_ACCESS_TOKEN
output_text = 'Payload Recieved: ' + payload
if payload == 'MENU_WHY':
return post_facebook_message(fbid,'Your vision our creativity')
elif payload == 'MENU_LINK':
return post_facebook_message(fbid,'Master-Event.github.io')
elif payload == 'MENU_OUTPUT':
return post_facebook_message(fbid,'https://myresumemaker.herokuapp.com/temp2')
elif payload == "EVENT" :
p = event.objects.get_or_create(fbid =fbid)[0]
# p.state = '1'
p.greetings = 'TRUE'
pp = resume_input.objects.get_or_create(fbid =fbid)[0]
pp.state = '0'
p.save()
pp.save()
return post_facebook_message(sender_id,'blah')
elif payload == "RESUME" :
p = event.objects.get_or_create(fbid =fbid)[0]
p.state = '0'
pp = resume_input.objects.get_or_create(fbid =fbid)[0]
pp.state = '1'
pp.greetings = 'TRUE'
pp.save()
p.save()
return post_facebook_message(fbid,'Please tell me your email id ')
elif payload == "NAME":
p = event.objects.get_or_create(fbid =fbid)[0]
p.state = '1'
pp = resume_input.objects.get_or_create(fbid =fbid)[0]
pp.state = '0'
pp.greetings = 'TRUE'
pp.save()
p.save()
return post_facebook_message(fbid,'go ahead and type')
elif payload == "number":
p = event.objects.get_or_create(fbid =fbid)[0]
p.state = '2'
p.save()
return post_facebook_message(fbid,'go ahead and type')
elif payload == "tagline":