def test_send_notifications(cls): if config.NOTIFICATION_BY_VOICE_CODE: # 语音通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_VOICE_CODE).flush() Notification.voice_code( config.NOTIFICATION_VOICE_CODE_PHONE, '张三', OrderLog. MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT. format('北京', '深圳'))
def test_send_notifications(cls): if Config().NOTIFICATION_BY_VOICE_CODE: # 语音通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_VOICE_CODE).flush() Notification.voice_code( Config().NOTIFICATION_VOICE_CODE_PHONE, '张三', OrderLog. MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT. format('北京', '深圳')) if Config().EMAIL_ENABLED: # 语音通知 CommonLog.add_quick_log(CommonLog.MESSAGE_TEST_SEND_EMAIL).flush() Notification.send_email(Config().EMAIL_RECEIVER, '测试发送邮件', 'By py12306')
def send_notification(self): num = 0 # 通知次数 sustain_time = self.notification_sustain_time while sustain_time: # TODO 后面直接查询有没有待支付的订单就可以 num += 1 if Config().NOTIFICATION_BY_VOICE_CODE: # 语音通知 OrderLog.add_quick_log(OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_START_SEND.format(num)) Notification.voice_code(Config().NOTIFICATION_VOICE_CODE_PHONE, self.user_ins.get_name(), OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT.format( self.query_ins.left_station, self.query_ins.arrive_station)) sustain_time -= self.notification_interval sleep(self.notification_interval) OrderLog.add_quick_log(OrderLog.MESSAGE_JOB_CLOSED)
def send_notification(self): num = 0 # 通知次数 sustain_time = self.notification_sustain_time if Config().EMAIL_ENABLED: # 邮件通知 Notification.send_email(Config().EMAIL_RECEIVER, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT.format(self.order_id)) while sustain_time: # TODO 后面直接查询有没有待支付的订单就可以 num += 1 if Config().NOTIFICATION_BY_VOICE_CODE: # 语音通知 OrderLog.add_quick_log(OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_START_SEND.format(num)) Notification.voice_code(Config().NOTIFICATION_VOICE_CODE_PHONE, self.user_ins.get_name(), OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT.format( self.query_ins.left_station, self.query_ins.arrive_station)) else: break sustain_time -= self.notification_interval sleep(self.notification_interval) OrderLog.add_quick_log(OrderLog.MESSAGE_JOB_CLOSED).flush()
def test_send_notifications(cls): if Config().NOTIFICATION_BY_VOICE_CODE: # 语音通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_VOICE_CODE).flush() Notification.voice_code( Config().NOTIFICATION_VOICE_CODE_PHONE, '张三', OrderLog. MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT. format('北京', '深圳')) if Config().EMAIL_ENABLED: # 语音通知 CommonLog.add_quick_log(CommonLog.MESSAGE_TEST_SEND_EMAIL).flush() Notification.send_email(Config().EMAIL_RECEIVER, '测试发送邮件', 'By py12306') if Config().DINGTALK_ENABLED: # 钉钉通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_DINGTALK).flush() Notification.dingtalk_webhook('测试发送信息') if Config().TELEGRAM_ENABLED: # Telegram通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_TELEGRAM).flush() Notification.send_to_telegram('测试发送信息')
def send_notification(self): num = 0 # 通知次数 sustain_time = self.notification_sustain_time if Config().EMAIL_ENABLED: # 邮件通知 Notification.send_email( Config().EMAIL_RECEIVER, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT. format(self.order_id)) if Config().DINGTALK_ENABLED: # 钉钉通知 Notification.dingtalk_webhook( OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT. format(self.order_id)) if Config().TELEGRAM_ENABLED: # Telegram推送 Notification.send_to_telegram( OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT. format(self.order_id)) if Config().SERVERCHAN_ENABLED: # ServerChan通知 Notification.server_chan( Config().SERVERCHAN_KEY, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT. format(self.order_id)) if Config().PUSHBEAR_ENABLED: # PushBear通知 Notification.push_bear( Config().PUSHBEAR_KEY, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT. format(self.order_id)) while sustain_time: # TODO 后面直接查询有没有待支付的订单就可以 num += 1 if Config().NOTIFICATION_BY_VOICE_CODE: # 语音通知 OrderLog.add_quick_log( OrderLog. MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_START_SEND .format(num)) Notification.voice_code( Config().NOTIFICATION_VOICE_CODE_PHONE, self.user_ins.get_name(), OrderLog. MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT. format(self.query_ins.left_station, self.query_ins.arrive_station)) else: break sustain_time -= self.notification_interval sleep(self.notification_interval) OrderLog.add_quick_log(OrderLog.MESSAGE_JOB_CLOSED).flush()
def test_send_notifications(cls): if Config().NOTIFICATION_BY_VOICE_CODE: # 语音通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_VOICE_CODE).flush() if Config().NOTIFICATION_VOICE_CODE_TYPE == 'dingxin': voice_content = { 'left_station': '广州', 'arrive_station': '深圳', 'set_type': '硬座', 'orderno': 'E123542' } else: voice_content = OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT.format( '北京', '深圳') Notification.voice_code(Config().NOTIFICATION_VOICE_CODE_PHONE, '张三', voice_content) if Config().EMAIL_ENABLED: # 邮件通知 CommonLog.add_quick_log(CommonLog.MESSAGE_TEST_SEND_EMAIL).flush() Notification.send_email(Config().EMAIL_RECEIVER, '测试发送邮件', 'By py12306') if Config().DINGTALK_ENABLED: # 钉钉通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_DINGTALK).flush() Notification.dingtalk_webhook('测试发送信息') if Config().TELEGRAM_ENABLED: # Telegram通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_TELEGRAM).flush() Notification.send_to_telegram('测试发送信息') if Config().SERVERCHAN_ENABLED: # ServerChan通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_SERVER_CHAN).flush() Notification.server_chan(Config().SERVERCHAN_KEY, '测试发送消息', 'By py12306') if Config().PUSHBEAR_ENABLED: # PushBear通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_PUSH_BEAR).flush() Notification.push_bear(Config().PUSHBEAR_KEY, '测试发送消息', 'By py12306') if Config().BARK_ENABLED: # Bark通知 CommonLog.add_quick_log( CommonLog.MESSAGE_TEST_SEND_PUSH_BARK).flush() Notification.push_bark('测试发送信息')
def send_notification(self): # num = 0 # 通知次数 # sustain_time = self.notification_sustain_time info_message = OrderLog.get_order_success_notification_info( self.query_ins) normal_message = OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_EMAIL_CONTENT.format( self.order_id, self.user_ins.user_name) if Config().EMAIL_ENABLED: # 邮件通知 Notification.send_email( Config().EMAIL_RECEIVER, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE, normal_message + info_message) if Config().DINGTALK_ENABLED: # 钉钉通知 Notification.dingtalk_webhook(normal_message + info_message) if Config().TELEGRAM_ENABLED: # Telegram推送 Notification.send_to_telegram(normal_message + info_message) if Config().SERVERCHAN_ENABLED: # ServerChan通知 Notification.server_chan( Config().SERVERCHAN_KEY, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE, normal_message + info_message) if Config().PUSHBEAR_ENABLED: # PushBear通知 Notification.push_bear( Config().PUSHBEAR_KEY, OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_TITLE, normal_message + info_message) if Config().NOTIFICATION_BY_VOICE_CODE: # 语音通知 if Config().NOTIFICATION_VOICE_CODE_TYPE == 'dingxin': voice_info = { 'left_station': self.query_ins.left_station, 'arrive_station': self.query_ins.arrive_station, 'set_type': self.query_ins.current_seat_name, 'orderno': self.order_id } else: voice_info = OrderLog.MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_CONTENT.format( self.query_ins.left_station, self.query_ins.arrive_station) OrderLog.add_quick_log( OrderLog. MESSAGE_ORDER_SUCCESS_NOTIFICATION_OF_VOICE_CODE_START_SEND) Notification.voice_code(Config().NOTIFICATION_VOICE_CODE_PHONE, self.user_ins.get_name(), voice_info) # 取消循环发送通知 # while sustain_time: # TODO 后面直接查询有没有待支付的订单就可以 # num += 1 # else: # break # sustain_time -= self.notification_interval # sleep(self.notification_interval) OrderLog.add_quick_log(OrderLog.MESSAGE_JOB_CLOSED).flush() return True