record_msg.py 897 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter service
  5. name:record_msg.py 处理消息数据
  6. author:rabin
  7. key:msg/type_key/farm_id/uid
  8. """
  9. import time
  10. import json
  11. from demeter.core import *
  12. class Record_msg(object):
  13. def handle(self, config, value):
  14. model = Demeter.model('msg_type')
  15. model.key = config['type']
  16. msg_type = model.select(type='fetchone')
  17. if msg_type:
  18. data = value.split('||')
  19. model = Demeter.model('msg')
  20. model.farm_id = config['parent']
  21. model.uid = config['child']
  22. model.type_id = config['type']
  23. model.content = data[0]
  24. model.link = data[1]
  25. if not data[2]:
  26. data[2] = msg_type['push']
  27. model.push = data[2]
  28. if 'sms' in model.push:
  29. self.sendSms(model)
  30. if 'weixin' in model.push:
  31. self.sendWeixin(model)
  32. id = model.insert()
  33. def sendSms(self, model):
  34. return
  35. def sendWeixin(self, model):
  36. return