Commit 4a1fa1481beff9691f8280d23fee0032240524d6

  • avatar
  • arvind
  • Fri Jan 24 19:11:18 IST 2014
Adding capability to send sms
       -Using smscountry api to send out messages to users whose
       recordings have been posted.
sms.py
(12 / 4)
  
11import logger
22import argparse
33import datetime
4import requests
5import smsConf as conf
46
57parser = argparse.ArgumentParser(description="""Send sms to users whose post are published.
68 Start and end date default to present day.
1919
2020
2121posts = logger.Logger('lb_postings')
22users = posts.lt.query.with_entities(posts.lt.user).filter(posts.lt.status == 3, posts.lt.posted.between(t1, t2), posts.lt.sms_sent == False)
22users = posts.lt.query.with_entities(posts.lt.user, posts.lt.id).filter(posts.lt.status == 3, posts.lt.posted.between(t1, t2), posts.lt.sms_sent == False)
2323users_list = []
24id_list = []
2425if users.count() > 0:
2526 for user in users:
26 users_list.append(user.user)
27 print users_list
27 sendSMS('91'+user.user, 'Hi, your recording has been successfully posted at http://cgnetswara.org/index.php?id='+user.id))
2828else:
29 print "No posts posted."
29 return False
30
31
32def sendSMS(number, message):
33 data = {'user': conf.username, 'passwd': conf.passwd, 'message': message, 'mobilenumber':number, 'mtype':'N', 'DR':'Y'}
34 sms = requests.get(conf.url, params=data)
35 return sms