DetectController.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
  5. @AUTHOR: ASJRD018
  6. @NAME: AnsjerFormal
  7. @software: PyCharm
  8. @DATE: 2019/1/14 15:57
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: DetectController.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. import os
  15. import time
  16. import apns2
  17. import jpush as jpush
  18. import oss2
  19. from django.http import JsonResponse
  20. from django.views.generic.base import View
  21. from pyfcm import FCMNotification
  22. from AnsjerPush.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, DETECT_PUSH_DOMAIN, JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE
  23. from Model.models import Equipment_Info, UidPushModel, SysMsgModel
  24. from Object.ETkObject import ETkObject
  25. from Object.RedisObject import RedisObject
  26. from Object.UidTokenObject import UidTokenObject
  27. from Service.CommonService import CommonService
  28. '''
  29. http://push.dvema.com/notify/push?etk=Y2lTRXhMTjBWS01sWlpURTVJU0ZWTlJ6RXhNVUU9T3o=&n_time=1526845794&channel=1&event_type=704&is_st=0
  30. http://push.dvema.com/deviceShadow/generateUTK?username=debug_user&password=debug_password&uid=VVDHCVBYDKFMJRWA111A
  31. '''
  32. # 移动侦测接口
  33. class NotificationView(View):
  34. def get(self, request, *args, **kwargs):
  35. request.encoding = 'utf-8'
  36. return self.validation(request.GET)
  37. def post(self, request, *args, **kwargs):
  38. request.encoding = 'utf-8'
  39. return self.validation(request.POST)
  40. def validation(self, request_dict):
  41. uidToken = request_dict.get('uidToken', None)
  42. etk = request_dict.get('etk', None)
  43. channel = request_dict.get('channel', '1')
  44. n_time = request_dict.get('n_time', None)
  45. event_type = request_dict.get('event_type', None)
  46. is_st = request_dict.get('is_st', None)
  47. # print("aaa")
  48. # return JsonResponse(0,safe=False)
  49. if not all([channel, n_time]):
  50. return JsonResponse(status=200, data={
  51. 'code': 444,
  52. 'msg': 'param is wrong'})
  53. if etk:
  54. eto = ETkObject(etk)
  55. uid = eto.uid
  56. if len(uid) != 20:
  57. return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
  58. else:
  59. utko = UidTokenObject(uidToken)
  60. uid = utko.UID
  61. pkey = '{uid}_{channel}_ptl'.format(uid=uid, channel=channel)
  62. # ykey = 'MUJ887NLR8K8GBM9111A_redis_qs'.format(uid=uid)
  63. ykey = '{uid}_redis_qs'.format(uid=uid)
  64. dkey = '{uid}_{channel}_{event_type}_flag'.format(uid=uid, event_type=event_type, channel=channel)
  65. # 判断redisObj.get_data(key=pkey):不为空
  66. redisObj = RedisObject(db=6)
  67. have_ykey = redisObj.get_data(key=ykey) # uid_set 数据库缓存
  68. have_pkey = redisObj.get_data(key=pkey) # 一分钟限制key
  69. have_dkey = redisObj.get_data(key=dkey) # 推送类型限制
  70. # 一分钟外,推送开启状态
  71. detect_med_type = 0 # 0推送旧机制 1存库不推送,2推送存库
  72. if have_pkey:
  73. res_data = {'code': 0, 'msg': 'success!'}
  74. return JsonResponse(status=200, data=res_data)
  75. # 数据库读取数据
  76. if have_ykey:
  77. redis_list = eval(redisObj.get_data(key=ykey))
  78. else:
  79. # 从数据库查询出来
  80. uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid,uid_set__detect_status=1). \
  81. values('token_val', 'app_type', 'appBundleId',
  82. 'push_type', 'userID_id', 'userID__NickName',
  83. 'lang', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group')
  84. # 新建一个list接收数据
  85. redis_list = []
  86. # 把数据库数据追加进redis_list
  87. for qs in uid_push_qs:
  88. redis_list.append(qs)
  89. # 修改redis数据,并设置过期时间为10分钟
  90. redisObj.set_data(key=ykey, val=str(redis_list), expire=600)
  91. if not redis_list:
  92. res_data = {'code': 404, 'msg': 'error !'}
  93. return JsonResponse(status=200, data=res_data)
  94. if not redis_list:
  95. print("没有redi_list")
  96. res_data = {'code': 0, 'msg': 'success!'}
  97. return JsonResponse(status=200, data=res_data)
  98. is_sys_msg = self.is_sys_msg(int(event_type))
  99. nickname = redis_list[0]['uid_set__nickname']
  100. detect_interval = redis_list[0]['uid_set__detect_interval']
  101. detect_group = redis_list[0]['uid_set__detect_group']
  102. now_time = int(time.time())
  103. if not nickname:
  104. nickname = uid
  105. if detect_group:
  106. if have_dkey:
  107. detect_med_type = 1
  108. else:
  109. detect_med_type = 2
  110. # detect_group=0允许全部推送的时候
  111. if detect_group == '0':
  112. redisObj.set_data(key=dkey, val=1, expire=detect_interval)
  113. else:
  114. detect_group_list = detect_group.split(',')
  115. if event_type in detect_group_list:
  116. if detect_interval < 60:
  117. detect_interval = 60
  118. redisObj.set_data(key=dkey, val=1, expire=detect_interval)
  119. redisObj.set_data(key=pkey, val=1, expire=60)
  120. # 旧模式并且没有pkey,重新创建一个
  121. if not detect_group and not have_pkey:
  122. # 设置推送时间为60秒一次
  123. redisObj.set_data(key=pkey, val=1, expire=60)
  124. auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
  125. bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
  126. kwag_args = {
  127. 'uid': uid,
  128. 'channel': channel,
  129. 'event_type': event_type,
  130. 'n_time': n_time,
  131. # 'appBundleId': appBundleId,
  132. # 'token_val': token_val,
  133. # 'msg_title': msg_title,
  134. # 'msg_text': msg_text
  135. }
  136. eq_list = []
  137. sys_msg_list = []
  138. userID_ids = []
  139. for up in redis_list:
  140. push_type = up['push_type']
  141. appBundleId = up['appBundleId']
  142. token_val = up['token_val']
  143. lang = up['lang']
  144. tz = up['tz']
  145. # 发送标题
  146. msg_title = self.get_msg_title(appBundleId=appBundleId, nickname=nickname)
  147. # 发送内容
  148. msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
  149. event_type=event_type)
  150. kwag_args['appBundleId'] = appBundleId
  151. kwag_args['token_val'] = token_val
  152. kwag_args['msg_title'] = msg_title
  153. kwag_args['msg_text'] = msg_text
  154. #推送
  155. if detect_med_type == 2 or detect_med_type == 0:
  156. if push_type == 0: # ios apns
  157. self.do_apns(**kwag_args)
  158. elif push_type == 1: # android gcm
  159. self.do_fcm(**kwag_args)
  160. elif push_type == 2: # android jpush
  161. self.do_jpush(**kwag_args)
  162. # 以下是存库
  163. userID_id = up["userID_id"]
  164. int_is_st = int(is_st)
  165. if userID_id not in userID_ids:
  166. eq_list.append(Equipment_Info(
  167. userID_id=userID_id,
  168. eventTime=n_time,
  169. eventType=event_type,
  170. devUid=uid,
  171. devNickName=nickname,
  172. Channel=channel,
  173. alarm='Motion \tChannel:{channel}'.format(channel=channel),
  174. is_st=int_is_st,
  175. receiveTime=n_time,
  176. addTime=now_time
  177. ))
  178. if is_sys_msg:
  179. sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
  180. event_type=event_type, is_sys=1)
  181. sys_msg_list.append(SysMsgModel(
  182. userID_id=userID_id,
  183. msg=sys_msg_text,
  184. addTime=now_time,
  185. updTime=now_time,
  186. uid=uid,
  187. eventType=event_type))
  188. userID_ids.append(userID_id)
  189. if is_sys_msg:
  190. SysMsgModel.objects.bulk_create(sys_msg_list)
  191. Equipment_Info.objects.bulk_create(eq_list)
  192. if is_st == '0' or is_st == '2':
  193. print("is_st=0or2")
  194. return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
  195. elif is_st == '1':
  196. print("is_st=1")
  197. # Endpoint以杭州为例,其它Region请按实际情况填写。
  198. obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
  199. # 设置此签名URL在60秒内有效。
  200. url = bucket.sign_url('PUT', obj, 7200)
  201. res_data = {'code': 0, 'img_push': url, 'msg': 'success'}
  202. return JsonResponse(status=200, data=res_data)
  203. elif is_st == '3':
  204. print("is_st=3")
  205. # 人形检测带动图
  206. # Endpoint以杭州为例,其它Region请按实际情况填写。
  207. img_url_list = []
  208. for i in range(int(is_st)):
  209. obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
  210. format(uid=uid, channel=channel, filename=n_time, st=i)
  211. # 设置此签名URL在60秒内有效。
  212. url = bucket.sign_url('PUT', obj, 7200)
  213. img_url_list.append(url)
  214. res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success'}
  215. return JsonResponse(status=200, data=res_data)
  216. def get_msg_title(self, appBundleId, nickname):
  217. package_title_config = {
  218. 'com.ansjer.customizedd_a': 'DVS',
  219. 'com.ansjer.zccloud_a': 'ZosiSmart',
  220. 'com.ansjer.zccloud_ab': '周视',
  221. 'com.ansjer.adcloud_a': 'ADCloud',
  222. 'com.ansjer.adcloud_ab': 'ADCloud',
  223. 'com.ansjer.accloud_a': 'ACCloud',
  224. 'com.ansjer.loocamccloud_a': 'Loocam',
  225. 'com.ansjer.loocamdcloud_a': 'Anlapus',
  226. 'com.ansjer.customizedb_a': 'COCOONHD',
  227. 'com.ansjer.customizeda_a': 'Guardian365',
  228. 'com.ansjer.customizedc_a': 'PatrolSecure',
  229. }
  230. if appBundleId in package_title_config.keys():
  231. return package_title_config[appBundleId] + '(' + nickname + ')'
  232. else:
  233. return nickname
  234. def is_sys_msg(self, event_type):
  235. event_type_list = [702, 703, 704]
  236. if event_type in event_type_list:
  237. return True
  238. return False
  239. def get_msg_text(self, channel, n_time, lang, tz, event_type, is_sys=0):
  240. n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz,lang=lang)
  241. etype = int(event_type)
  242. if lang == 'cn':
  243. if etype == 704:
  244. msg_type = '电量过低'
  245. elif etype == 702:
  246. msg_type = '摄像头休眠'
  247. elif etype == 703:
  248. msg_type = '摄像头唤醒'
  249. else:
  250. msg_type = ''
  251. if is_sys:
  252. send_text = '{msg_type} 通道:{channel}'.format(msg_type=msg_type, channel=channel)
  253. else:
  254. send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
  255. # send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
  256. else:
  257. if etype == 704:
  258. msg_type = 'Low battery'
  259. elif etype == 702:
  260. msg_type = 'Camera sleep'
  261. elif etype == 703:
  262. msg_type = 'Camera wake'
  263. else:
  264. msg_type = ''
  265. if is_sys:
  266. send_text = '{msg_type} channel:{channel}'. \
  267. format(msg_type=msg_type, channel=channel)
  268. else:
  269. send_text = '{msg_type} channel:{channel} date:{date}'. \
  270. format(msg_type=msg_type, channel=channel, date=n_date)
  271. return send_text
  272. def do_jpush(self, uid, channel, appBundleId, token_val, event_type, n_time,
  273. msg_title, msg_text):
  274. app_key = JPUSH_CONFIG[appBundleId]['Key']
  275. master_secret = JPUSH_CONFIG[appBundleId]['Secret']
  276. # 此处换成各自的app_key和master_secre
  277. _jpush = jpush.JPush(app_key, master_secret)
  278. push = _jpush.create_push()
  279. # if you set the logging level to "DEBUG",it will show the debug logging.
  280. # _jpush.set_logging("DEBUG")
  281. # push.audience = jpush.all_
  282. push.audience = jpush.registration_id(token_val)
  283. push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
  284. "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
  285. android = jpush.android(alert=msg_text, priority=1, style=1, alert_type=7,
  286. big_text=msg_text, title=msg_title,
  287. extras=push_data)
  288. push.notification = jpush.notification(android=android)
  289. push.platform = jpush.all_
  290. try:
  291. res = push.send()
  292. print(res)
  293. except Exception as e:
  294. print("jpush fail")
  295. print("Exception")
  296. print(repr(e))
  297. return
  298. else:
  299. print("jpush success")
  300. return
  301. def do_fcm(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title, msg_text):
  302. try:
  303. serverKey = FCM_CONFIG[appBundleId]
  304. except Exception as e:
  305. return
  306. push_service = FCMNotification(api_key=serverKey)
  307. data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
  308. "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
  309. result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
  310. message_body=msg_text, data_message=data,
  311. extra_kwargs={
  312. 'default_vibrate_timings': True,
  313. 'default_sound': True,
  314. 'default_light_settings': True
  315. })
  316. print('fcm push ing')
  317. print(result)
  318. return
  319. def do_apns(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title,
  320. msg_text):
  321. try:
  322. cli = apns2.APNSClient(mode=APNS_MODE,
  323. client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
  324. push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
  325. "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
  326. alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
  327. payload = apns2.Payload(alert=alert, custom=push_data)
  328. n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
  329. res = cli.push(n=n, device_token=token_val, topic=appBundleId)
  330. print(res.status_code)
  331. if res.status_code == 200:
  332. print('apns push success')
  333. return
  334. else:
  335. print('apns push fail')
  336. print(res.reason)
  337. return
  338. except Exception as e:
  339. print(repr(e))
  340. return
  341. # http://test.dvema.com/detect/add?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJQMldOR0pSRDJFSEE1RVU5MTExQSJ9.xOCI5lerk8JOs5OcAzunrKCfCrtuPIZ3AnkMmnd-bPY&n_time=1526845794&channel=1&event_type=51&is_st=0
  342. # 移动侦测接口
  343. class PushNotificationView(View):
  344. def get(self, request, *args, **kwargs):
  345. request.encoding = 'utf-8'
  346. # operation = kwargs.get('operation')
  347. return self.validation(request.GET)
  348. def post(self, request, *args, **kwargs):
  349. request.encoding = 'utf-8'
  350. # operation = kwargs.get('operation')
  351. return self.validation(request.POST)
  352. def validation(self, request_dict):
  353. etk = request_dict.get('etk', None)
  354. channel = request_dict.get('channel', '1')
  355. n_time = request_dict.get('n_time', None)
  356. event_type = request_dict.get('event_type', None)
  357. is_st = request_dict.get('is_st', None)
  358. eto = ETkObject(etk)
  359. uid = eto.uid
  360. if len(uid) == 20:
  361. redisObj = RedisObject(db=6)
  362. # pkey = '{uid}_{channel}_ptl'.format(uid=uid, channel=channel)
  363. pkey = '{uid}_ptl'.format(uid=uid)
  364. ykey = '{uid}_redis_qs'.format(uid=uid)
  365. if redisObj.get_data(key=pkey):
  366. res_data = {'code': 0, 'msg': 'success,!'}
  367. return JsonResponse(status=200, data=res_data)
  368. else:
  369. redisObj.set_data(key=pkey, val=1, expire=60)
  370. ##############
  371. redis_data = redisObj.get_data(key=ykey)
  372. if redis_data:
  373. redis_list = eval(redis_data)
  374. else:
  375. # 设置推送时间为60秒一次
  376. redisObj.set_data(key=pkey, val=1, expire=60)
  377. print("从数据库查到数据")
  378. # 从数据库查询出来
  379. uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1). \
  380. values('token_val', 'app_type', 'appBundleId',
  381. 'push_type', 'userID_id', 'lang',
  382. 'tz', 'uid_set__nickname')
  383. # 新建一个list接收数据
  384. redis_list = []
  385. # 把数据库数据追加进redis_list
  386. for qs in uid_push_qs:
  387. redis_list.append(qs)
  388. # 修改redis数据,并设置过期时间为10分钟
  389. if redis_list:
  390. redisObj.set_data(key=ykey, val=str(redis_list), expire=600)
  391. auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
  392. bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
  393. self.do_bulk_create_info(redis_list, n_time, channel, event_type, is_st, uid)
  394. if is_st == '0' or is_st == '2':
  395. return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
  396. elif is_st == '1':
  397. # Endpoint以杭州为例,其它Region请按实际情况填写。
  398. obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
  399. # 设置此签名URL在60秒内有效。
  400. url = bucket.sign_url('PUT', obj, 7200)
  401. res_data = {'code': 0, 'img_push': url, 'msg': 'success'}
  402. return JsonResponse(status=200, data=res_data)
  403. elif is_st == '3':
  404. # 人形检测带动图
  405. img_url_list = []
  406. for i in range(int(is_st)):
  407. obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
  408. format(uid=uid, channel=channel, filename=n_time, st=i)
  409. # 设置此签名URL在60秒内有效。
  410. url = bucket.sign_url('PUT', obj, 7200)
  411. img_url_list.append(url)
  412. res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success'}
  413. return JsonResponse(status=200, data=res_data)
  414. else:
  415. return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
  416. else:
  417. return JsonResponse(status=200, data={'code': 404, 'msg': 'wrong etk'})
  418. def do_bulk_create_info(self, uaqs, n_time, channel, event_type, is_st, uid):
  419. now_time = int(time.time())
  420. # 设备昵称
  421. userID_ids = []
  422. sys_msg_list = []
  423. is_sys_msg = self.is_sys_msg(int(event_type))
  424. is_st = int(is_st)
  425. eq_list = []
  426. nickname = uaqs[0]['uid_set__nickname']
  427. if not nickname:
  428. nickname = uid
  429. for ua in uaqs:
  430. lang = ua['lang']
  431. tz = ua['tz']
  432. userID_id = ua["userID_id"]
  433. if userID_id not in userID_ids:
  434. eq_list.append(Equipment_Info(
  435. userID_id=userID_id,
  436. eventTime=n_time,
  437. eventType=event_type,
  438. devUid=uid,
  439. devNickName=nickname,
  440. Channel=channel,
  441. alarm='Motion \tChannel:{channel}'.format(channel=channel),
  442. is_st=is_st,
  443. receiveTime=n_time,
  444. addTime=now_time
  445. ))
  446. if is_sys_msg:
  447. sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
  448. event_type=event_type, is_sys=1)
  449. sys_msg_list.append(SysMsgModel(
  450. userID_id=userID_id,
  451. msg=sys_msg_text,
  452. addTime=now_time,
  453. updTime=now_time,
  454. uid=uid,
  455. eventType=event_type))
  456. if eq_list:
  457. print('eq_list')
  458. Equipment_Info.objects.bulk_create(eq_list)
  459. if is_sys_msg:
  460. print('sys_msg')
  461. SysMsgModel.objects.bulk_create(sys_msg_list)
  462. return True
  463. def is_sys_msg(self, event_type):
  464. event_type_list = [702, 703, 704]
  465. if event_type in event_type_list:
  466. return True
  467. return False
  468. def get_msg_text(self, channel, n_time, lang, tz, event_type, is_sys=0):
  469. n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz)
  470. etype = int(event_type)
  471. if lang == 'cn':
  472. if etype == 704:
  473. msg_type = '电量过低'
  474. elif etype == 702:
  475. msg_type = '摄像头休眠'
  476. elif etype == 703:
  477. msg_type = '摄像头唤醒'
  478. else:
  479. msg_type = ''
  480. if is_sys:
  481. send_text = '{msg_type} 通道:{channel}'.format(msg_type=msg_type, channel=channel)
  482. else:
  483. send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
  484. else:
  485. if etype == 704:
  486. msg_type = 'Low battery'
  487. elif etype == 702:
  488. msg_type = 'Camera sleep'
  489. elif etype == 703:
  490. msg_type = 'Camera wake'
  491. else:
  492. msg_type = ''
  493. if is_sys:
  494. send_text = '{msg_type} channel:{channel}'. \
  495. format(msg_type=msg_type, channel=channel)
  496. else:
  497. send_text = '{msg_type} channel:{channel} date:{date}'. \
  498. format(msg_type=msg_type, channel=channel, date=n_date)
  499. return send_text