-
Notifications
You must be signed in to change notification settings - Fork 6
/
confirm.py
44 lines (34 loc) · 1.52 KB
/
confirm.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
#!/usr/bin/env python2
# -*- coding:utf-8 -*-
import json
from web import db
from dbms.models import Intent
from facebook import utils
from translations.user import user_gettext
from facebook.api import FacebookApi
from events import PrayerEvent
def confirm_praying_for_intention():
query_prayers = Intent.query.filter( Intent.commiter_id > 0, Intent.confirmed == 0 ).all();
for prayer in query_prayers:
if prayer.commiter_id != None and prayer.commiter_id != "":
options = [ {
'title': user_gettext( prayer.commiter_id, u"Yes" ),
'payload': PrayerEvent.payload(PrayerEvent.DID_PRAY, prayer.id, prayer.user_id)
},
{
'title': user_gettext( prayer.commiter_id, u"No" ),
'payload': PrayerEvent.payload(PrayerEvent.DONT_CONFIRM_PRAY, prayer.id, prayer.user_id)
} ]
response_message = utils.response_buttons(
user_gettext( prayer.commiter_id, u"Did You pray in below request ?\n%(value)s", value=prayer.description ),
options
)
response = json.dumps({
'recipient': { 'id' : prayer.commiter_id },
'message': response_message
})
api = FacebookApi();
api.post("/me/messages", response);
#print "\n";
if __name__ == '__main__':
confirm_praying_for_intention()