-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwxBox.py
59 lines (47 loc) · 2.06 KB
/
wxBox.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import itchat
from itchat.content import *
from get_shop_Url import get_url
class wxBox:
def __init__(self):
itchat.auto_login(hotReload=True)
self.wxBox= itchat
def run(self,block=True):
user_info = itchat.search_friends()
self.notifySelf('Login successfully as %s' % user_info['NickName'])
@itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING])
def text_reply(msg):
if( (msg.User is None) or (msg.User["UserName"]!=msg['FromUserName'])):return
if(msg.type=='Text'):
get_url(msg)
@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])
def download_files(msg):
msg.download(msg.fileName)
typeSymbol = {
PICTURE: 'img',
VIDEO: 'vid', }.get(msg.type, 'fil')
msg.user.send('你好 我现在休息 我会记录您的消息,您看可以吗')
return '@%s@%s' % (typeSymbol, msg.fileName)
@itchat.msg_register(FRIENDS)
def add_friend(msg):
msg.user.verify()
msg.user.send('Nice to meet you!')
@itchat.msg_register(TEXT, isGroupChat=True)
def text_reply(msg):
if(msg.User["UserName"]!=msg['FromUserName']):return
get_url(msg)
if msg.isAt:
# msg.user.send(u'@%s\u2005I received: %s' % (msg.actualNickName, msg.text))
msg.user.send(u'@%s\u2005: %s' % (msg.actualNickName, '我还休息,看到后回复您'))
self.wxBox.run(block)
def notifySelf(self,text):
friend= self.wxBox.search_friends(name='那以前是海')[0]
self.wxBox.send(text,toUserName=friend.UserName)
def notifyAll(self,text):
friends = self.get_friends()
for friend in friends:
self.wxBox.send(text,toUserName=friend.UserName)
def get_friends(self):
return self.wxBox.get_friends(update=True)
if __name__ == "__main__":
wx = wxBox()
wx.run()