forked from cycz/jdBuyMask
-
Notifications
You must be signed in to change notification settings - Fork 8
/
message.py
29 lines (25 loc) · 946 Bytes
/
message.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
# -*- encoding=utf8 -*-
from jdEmail import sendMail
from wechat_ftqq import sendWechat
class message(object):
"""消息推送类"""
def __init__(self, messageType, sc_key, mail):
if messageType == '2':
if not sc_key:
raise Exception('sc_key can not be empty')
self.sc_key = sc_key
elif messageType == '1':
if not mail:
raise Exception('mail can not be empty')
self.mail = mail
self.messageType = messageType
def send(self, desp='', isOrder=False):
desp = str(desp)
if isOrder:
msg = desp + ' 类型口罩,已经下单了。24小时内付款'
else:
msg = desp + ' 类型口罩,下单失败了,快去抢购!'
if self.messageType == '1':
sendMail(self.mail, msg)
if self.messageType == '2':
sendWechat(sc_key=self.sc_key, desp=msg)