用户:codemao_666_create查看:0 回复:2 评论:0 创建时间:2019-06-08T09:03:44
#只能在本地的python运行(海龟编辑器不能用)
from os import system
def pip(com,name):
try:
cmd=('pip '+(com+' '))+name
system(cmd)
except:
print('error:'+cmd)
pip('install','pillow')
pip('install','itchat')
import itchat
import time
from itchat.content import *
from re import *
reply='我现在有事,一会再回复\n'
@itchat.msg_register(TEXT,isFriendChat=True,isGroupChat=False, isMpChat=False)
def tuling_reply(msg):
return_msg=('['+time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))+']'
return_msg=return_msg+reply
from_u=itchat.search_friends(userName=msg['FromUserName'])
return_msg=(((return_msg+'已收到来自:')+from_u['NickName'])+'的消息:')+msg['Content']
return_msg_=(((return_msg+'已收到来自:')+from_u['RemarkName'] or from_u['NickName'])+'的消息:')+msg['Content']
itchat.send_msg(msg=return_msg_,toUserName='filehelper')
return return_msg
@itchat.msg_register([TEXT,SHARING],isFriendChat=False,isGroupChat=True, isMpChat=False)
def gc_reply(msg):
if msg['isAt']==True:
return_msg=('['+time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))+']'
return_msg=return_msg+reply
from_u=(itchat.search_chatrooms(userName=msg['FromUserName'])['NickName']+'的')+msg['ActualNickName']
from_u_2=(itchat.search_chatrooms(userName=msg['FromUserName'])['RemarkName'] or itchat.search_chatrooms(userName=msg['FromUserName'])['NickName']+'的')+msg['ActualNickName']
return_msg_2=(((return_msg+'已收到来自:')+from_u_2)+'的消息:')+msg['Content']
return_msg=(((return_msg+'已收到来自:')+from_u)+'的消息:')+msg['Content']
itchat.send_msg(msg=return_msg_2,toUserName='filehelper')
return_msg=(('@'+msg['ActualNickName'])+' ')+return_msg
return return_msg
@itchat.msg_register(SHARING,isFriendChat=True,isGroupChat=False, isMpChat=False)
def tulinga_reply(msg):
return_msg=('['+time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))+']'
return_msg=return_msg+reply
from_u=itchat.search_friends(userName=msg['FromUserName'])
return_msg=(((return_msg+'已收到来自:')+from_u['NickName'])+'的消息:')+findall(r'http.+</url>',msg['Content'])[0][:-6]
return_msg_=(((return_msg+'已收到来自:')+from_u['RemarkName'] or from_u['NickName'])+'的消息:')+findall(r'http.+</url>',msg['Content'])[0][:-6]
itchat.send_msg(msg=return_msg_,toUserName='filehelper')
return return_msg
itchat.auto_login(hotReload=True)
# itchat.auto_login(enableCmdQR=True)这个只能生成一行行二维码,不能生成图片
itchat.run()