Пример #1
0
 def send_msg(self, target, content, sender=None, first=False, **kwargs):
     logger.info("Sending message to " + target)
     roomid = wxRoomNicks[target]
     if sender is not None:
         itchat.send(msg="[{}] {}".format(sender,content), toUserName=roomid)
     else:
         itchat.send(content, toUserName=roomid)
Пример #2
0
def  main():
	#登陆微信
	itchat.auto_login(hotReload=True)
	user_content = itchat.search_friends(name=u'雨一直下')
	userName = user_content[0]['UserName']
	itchat.send(getWeather(000),toUserName = userName)#
	itchat.send(getWeather(000),toUserName = userName)#
Пример #3
0
def information(msg):
    #这里如果这里的msg['Content']中包含消息撤回和id,就执行下面的语句
    if '撤回了一条消息' in msg['Content']:
        old_msg_id = re.search(r"\<msgid\>(.*?)\<\/msgid\>", msg['Content']).group(1)  #在返回的content查找撤回的消息的id
        old_msg = msg_information.get(old_msg_id)  #得到消息
        #print (old_msg)

    if len(old_msg_id)<11: #如果发送的是表情包
        itchat.send_file(face_bug,toUserName='******')
    else: #发送撤回的提示给文件助手
        msg_body = "告诉你一个秘密~" + "\n" \
            + old_msg.get('msg_from') + " 撤回了 " + old_msg.get("msg_type") + " 消息" + "\n" \
            + old_msg.get('msg_time_rec') + "\n" \
            + "撤回了什么 ⇣" + "\n" \
            + r"" + old_msg.get('msg_content')
      #如果是分享的文件被撤回了,那么就将分享的url加在msg_body中发送给文件助手
    if old_msg['msg_type'] == "Sharing":
        msg_body += "\n就是这个链接➣ " + old_msg.get('msg_share_url')
 
    # 将撤回消息发送到文件助手
    itchat.send_msg(msg_body, toUserName='******')
    # 有文件的话也要将文件发送回去
    if old_msg["msg_type"] == "Picture" \
          or old_msg["msg_type"] == "Recording" \
          or old_msg["msg_type"] == "Video" \
          or old_msg["msg_type"] == "Attachment":
        file = '@fil@%s' % (old_msg['msg_content'])
        itchat.send(msg=file, toUserName='******')
        os.remove(old_msg['msg_content'])
    
    # 删除字典旧消息
    msg_information.pop(old_msg_id)
Пример #4
0
def text_reply(msg):
    import shutil
    if not msg['Text'][:3].find("参选")==-1:
        return canxuan(msg['Text'][3:])
    print(msg["Text"])
    live=dieorlive()
    print(live)
    if live==1:
        return ""
    if not msg['Text'].find("7654312")==-1:
        paiming(msg['Text'][8:])
    if not msg['Text'].find('123001116')==-1:
        admin(msg['Text'][10:])
    print(msg['Text'])
    print(msg['FromUserName'])
    if msg['FromUserName'] == filehelper:
        msg['FromUserName'] = "******"
    ret = info(msg["Text"],msg['FromUserName'])
    if ret=="":
        try:
            shutil.copyfile("pic/"+msg['Text']+".jpg", "t.png")
            itchat.send('@img@%s' % 't.png', toUserName=str(msg['FromUserName']))
            os.remove("t.png")
            return miaoshu(msg['Text'])
        except:
            pass
    return ret
Пример #5
0
def task():
  chatroomList = itchat.get_chatrooms(False);
  for m in chatroomList:
    NickName = m['NickName'].encode('utf-8')
    if NickName == u'测试'.encode('utf-8'):
      text = u'可以定时发送了'.encode('utf-8')
      itchat.send(text, m['UserName'])
Пример #6
0
def SaveMsg(msg):
    if not os.path.exists('.\\Revocation\\'):
        os.mkdir('.\\Revocation\\')
#    if re.search(r'\<replacemsg\>\<\!\[CDATA\[.*撤回了一条消息\]\]\>\<\/replacemsg\>', msg['Content']):
    if re.search(r'revokemsg', msg['Content']):
        old_msg_id = re.search('\<msgid\>(.*?)\<\/msgid\>', msg['Content']).group(1)
        old_msg = next((msg for msg in msg_list if msg['msg_id'] == old_msg_id),None)
        if old_msg:
            msg_send = u"您的好友:" \
                       + old_msg.get('msg_from', None) \
                       + u"  在 [" + old_msg.get('msg_time_touser', None) \
                       + u"], 撤回了一条 [" + old_msg['msg_type'] \
                       + u"] 消息, 内容如下:" \
                       + old_msg.get('msg_content', None)
            if old_msg['msg_type'] == "Sharing":
                msg_send += r", 链接: " + old_msg.get('msg_url', None)
            elif old_msg['msg_type'] == 'Picture' \
                    or old_msg['msg_type'] == 'Recording' \
                    or old_msg['msg_type'] == 'Video' \
                    or old_msg['msg_type'] == 'Attachment':
                msg_send += u", 存储在当前目录下Revocation文件夹中"
                shutil.move(old_msg['msg_content'], '.\\Revocation\\')
            print(msg_send)
            itchat.send(msg_send, toUserName='******')

            msg_list.remove(old_msg)
            print('msg_list saved is ')
            print(msg_list)
Пример #7
0
 def card_reply(msg):
     print msg
     print msg['RecommendInfo']
     info = msg['RecommendInfo']
     wechat_number = u'微信号暂时不可得' if info['Alias'] == None or info['Alias'] == "" else info['Alias']
     for destination in destinations(msg):
         itchat.send( u'%s共享了一个名片:\n昵称:%s\n微信号:%s' % (msg['ActualDisplayName'], info['NickName'], wechat_number), destination)
Пример #8
0
def handler_receive_msg(msg):  # 处理收到的消息
    message = msg['Text']
    toName = msg['ToUserName']
    #owner = msg['User']['PYQuanPin']
    # 临时保存截屏图片地址
    #path = 'C:\Users\wqw\Desktop\fig\temp.jpg'
    path = 'tmp.jpg'
    reply = json.dumps(msg, ensure_ascii=False)
    reply = '你发了:%s'%message
    #{"MsgId": "9212371634710588729", "FromUserName": "******", "ToUserName": "******", "MsgType": 1, "Content": "你", "Status": 3, "ImgStatus": 1, "CreateTime": 1541315145, "VoiceLength": 0, "PlayLength": 0, "FileName": "", "FileSize": "", "MediaId": "", "Url": "", "AppMsgType": 0, "StatusNotifyCode": 0, "StatusNotifyUserName": "", "RecommendInfo": {"UserName": "", "NickName": "", "QQNum": 0, "Province": "", "City": "", "Content": "", "Signature": "", "Alias": "", "Scene": 0, "VerifyFlag": 0, "AttrStatus": 0, "Sex": 0, "Ticket": "", "OpCode": 0}, "ForwardFlag": 0, "AppInfo": {"AppID": "", "Type": 0}, "HasProductId": 0, "Ticket": "", "ImgHeight": 0, "ImgWidth": 0, "SubMsgType": 0, "NewMsgId": 9212371634710588729, "OriContent": "", "EncryFileName": "", "User": {"MemberList": [], "UserName": "******", "City": "海淀", "DisplayName": "", "PYQuanPin": "wangqiwen", "RemarkPYInitial": "", "Province": "北京", "KeyWord": "wqw", "RemarkName": "", "PYInitial": "WQW", "EncryChatRoomId": "", "Alias": "", "Signature": "自律更自由", "NickName": "王奇文", "RemarkPYQuanPin": "", "HeadImgUrl": "/cgi-bin/mmwebwx-bin/webwxgeticon?seq=661826231&username=@ad238825281702d637159eab5f24f89e&skey=@crypt_15c532e6_ba943df756f74fb80686ff7d62c8c677", "UniFriend": 0, "Sex": 1, "AppAccountFlag": 0, "VerifyFlag": 0, "ChatRoomId": 0, "HideInputBarFlag": 0, "AttrStatus": 33656871, "SnsFlag": 17, "MemberCount": 0, "OwnerUin": 0, "ContactFlag": 3, "Uin": 965715160, "StarFriend": 0, "Statues": 0, "WebWxPluginSwitch": 0, "HeadImgFlag": 1, "IsOwner": 0}, "Type": "Text", "Text": "你"}
    #if toName in ('@ad238825281702d637159eab5f24f89e', "filehelper" ):
    if toName == "filehelper":
        if message == "cap":  # 拍照
            #  要使用摄像头,需要使用cv2.VideoCapture(0)创建VideoCapture对象,
            # 参数:0指的是摄像头的编号。如果你电脑上有两个摄像头的话,访问第2个摄像头就可以传入1
            cap = cv2.VideoCapture(0)
            ret, img = cap.read()  # 获取一帧
            cv2.imwrite("temp.jpg", img)
            itchat.send('@img@%s' % u'temp.jpg', toName)
            cap.release()  # 释放资源
        if message[0:3] == "cmd":  # 处理cmd命令
            os.system(message.strip(message[0:4]))
        if message == "pc":  # 截图
            im = ImageGrab.grab()  # 实现截屏功能
            im.save(path, 'JPEG')  # 设置保存路径和图片格式
            itchat.send_image(path, toName)
    # 微信表情符对照表:https://www.cnblogs.com/xuange306/p/7098236.html
    emoji = [')', 'B', 'X', 'Z', 'Q', 'T', 'L', 'g', '|', '<','>', '~', '’(', '$', '!','O', 'P', '+','*']

    robots = ['/::%s'%(i) for i in emoji]
    reply = get_response(msg['Text'])+random.choice(robots)
    res = '收到%s的消息[%s], 回复:[%s]'%(toName, message, reply)
    print(sys.stderr, res)
    return reply or defaultReply
Пример #9
0
def group_text_reply(msg):
    # 当然如果只想针对@你的人才回复,可以设置if msg['isAt']:
    item = group_id(u'过过过!') # 根demo据自己的需求设置
    print item
    print msg['FromUserName']
    print msg['ToUserName']
    itchat.send(u'%s' % tuling(msg['Text']), item)
Пример #10
0
def group_text_reply(msg):
    # 当然如果只想针对@你的人才回复,可以设置if msg['isAt']:
    item = group_id(u'过过过!') # 根demo据自己的需求设置
    print msg['FromUserName']
    if msg['FromUserName'] == '@11432fd6aacd8741a1afb4f8f5262c8bf86bb32979b41a5898061f536000be6c' :
        print msg['ToUserName']
        itchat.send(u'%s' % tuling(msg['Text']), item)
Пример #11
0
 def download_files(msg):
     fileDir = '%s%s' % (msg['Type'], int(time.time()))
     if msg['Type'] == 'Gif': fileDir += '.gif'
     msg['Text'](fileDir)
     for destination in destinations(msg):
         itchat.send('@%s@%s' % ('img' if msg['Type'] == 'Picture' or msg['Type'] == 'Gif' else 'fil', fileDir), destination)
         itchat.send('%s by %s' % (msg['Type'], ''), destination)
Пример #12
0
Файл: run.py Проект: xzjs/ItChat
 def text_reply(msg):
     # itchat.send('%s: %s' % (msg['Type'], msg['Text']), msg['FromUserName'])
     str = ''
     if msg['Content'] == 'report':
         str = rA.get_sentence()
     if msg['Content'] == 'liu':
         str = rA.liu()
     itchat.send(str, msg['FromUserName'])
Пример #13
0
 def add_friend(msg):
     itchat.add_friend(**msg['Text']);
     itchat.get_contract();
     itchat.send(u'我是小书童,终于等到愿意改变的你,从今天开始你就是我的主人了,有什么吩咐尽快说!', msg['RecommendInfo']['UserName']);
     time.sleep(5);
     itchat.send(u'主人,为了能陪你完成读书的计划,偶们需要完成一个小任务获得共读的资格和电子书资源。将小的发的图片分享到朋友圈然后截图发给小的。然后我们就可以一起去群里完成每日的读书计划,群内每天都有小的发的领读。小的一直会伴你读书,陪你成长!', msg['RecommendInfo']['UserName']);
     # itchat.send_image('@[email protected]' ,  msg['RecommendInfo']['UserName']);
     return '@[email protected]';
Пример #14
0
 def text_reply(msg):
     url = ''
     if msg['Url']: url = ' - ' + htmlParser.unescape(msg['Url'])
     for destination in destinations(msg):
         if url == '':
             itchat.send('%s: \n%s%s' % (msg['ActualDisplayName'], msg['Text'], url), destination)
         else:
             itchat.send('%s共享了一个链接: \n%s%s'.decode('utf-8', 'replace') % (msg['ActualDisplayName'], msg['Text'], url), destination)
Пример #15
0
def text_reply(msg):
    if msg['Text'] == '讲个笑话':
        i = random.randrange(0, len(all_jokes))
        #print(all_jokes[i], '@482f24ba78542b322e073d17293df80c')
        #itchat.send(all_jokes[i], '@482f24ba78542b322e073d17293df80c')
        print(all_jokes[i], msg['FromUserName'])
        itchat.send(all_jokes[i], msg['FromUserName'])
        return
Пример #16
0
def clockFunc():
    account=itchat.search_friends('杨雨婷')
    userName = account[0]['UserName']
    morningTime = 3600 * 3 - 900
    time.sleep(morningTime)
    print('haha')
    itchat.send("哈哈哈,我又来啦~~~,起床啦起床啦!", toUserName=userName)
    print(account)
Пример #17
0
def push_wechat(name, real_price, real_percent, type):
    name='wwwei'
    itchat.auto_login(hotReload=True)
    account=itchat.get_friends(name)
    for i in account:
        if i['PYQuanPin']==name:
            toName=i['UserName']
    content=name+' ' + str(real_price)+' '+ str(real_percent)+' percent '+ type
    itchat.send(content,toUserName=toName)
Пример #18
0
 def get_pic(msg):
     #print itchat.get_userinfo()
     if msg.get('Type', '') == 'Text':
         txt = msg['Text']
         is_birthday = (txt.isdigit() and len(txt)==8)
         if( is_birthday ):
             return '@[email protected]'
         else:
             itchat.send(u'格式错误。请输入你的出生日期,如: 20150908', msg['FromUserName'])
Пример #19
0
def group_action(msg):
	if msg['isAt']:
		print('U are @ting by %s, saying %s '%(msg['ActualNickName'],msg['Content']))
		itchat.send(u'多谢@我!等下回复你~ %s' % msg['ActualNickName'],toUserName=msg['ActualNickName'])
	elif msg['Type'] == TEXT:
		try:
			print('G# %s is saying %s '%(msg['ActualNickName'],msg['Content']))
		except UnicodeEncodeError:
			print 'G# Receiving unaceptable image format.'
Пример #20
0
 def download_files(msg):
     dict = {'Picture': "图片", "Gif": "表情", "Recording": "录音", "Video": "小视频", "Attachment": "文件"}
     fileDir = './storage/%s%s' % (msg['Type'], int(time.time()))
     if msg['Type'] == 'Gif': fileDir += '.gif'
     msg['Text'](fileDir)
     for destination in destinations(msg):
         itchat.send('%s发送了%s'.decode('utf-8', 'replace') % (msg['ActualDisplayName'], dict[msg['Type']].decode('utf-8', 'replace')), destination)
         print itchat.send('@%s@%s' % ('img' if msg['Type'] == 'Picture' or msg['Type'] == 'Gif' else 'fil', fileDir),
                     destination)
Пример #21
0
 def send_photo(self, target, photo_data, sender=None):
     ft = imghdr.what('', photo_data)
     if ft is None:
         return
     filename = "image." + ft
     data_io = io.BytesIO(photo_data)
     roomid = wxRoomNicks[target]
     if sender is not None:
         itchat.send(msg="{} sent a photo...".format(sender), toUserName=roomid)
     itchat.send_image(fileDir=filename, toUserName=roomid, file_=data_io)
Пример #22
0
def text_reply(msg):
    if u'作者' in msg['Text'] or u'主人' in msg['Text']:
        return u'你可以在这里了解他:https://github.com/littlecodersh'
    elif u'源代码' in msg['Text'] or u'获取文件' in msg['Text']:
        itchat.send('@[email protected]', msg['FromUserName'])
        return u'这就是现在机器人后台的代码,是不是很简单呢?'
    elif u'获取图片' in msg['Text']:
        itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture
    else:
        return get_response(msg['Text']) or u'收到:' + msg['Text']
Пример #23
0
def send_msg():
    global count
    itchat.send(ask_questions[count], toUserName=itchat.search_mps(name="会飞的小树杈")[0]['UserName'])
    global str_result
    str_result += ask_questions[count]
    count += 1
    if count < len(ask_questions):
        Timer(random.randint(20, 40), send_msg).start()
    else:
        print(str_result)
Пример #24
0
 def SendMsg(self,Msg,UserName):
     '''
     向指定用户发送指定数据
     :param Msg:
     :param UserName:
     :return:
     '''
     username = self.GetUserName(UserName)
     if(username):
         itchat.send(Msg, username)
     else:
         print(u"指定用户[%s]不在你的好友列表"%(username))
Пример #25
0
 def GetUserName(self, Comment):
     '''
     通过备注获取到用户的UserName
     :return:
     '''
     userDict =  itchat.search_friends(name=Comment)
     if(userDict):
         return userDict[0]['UserName']
     else:
         my = userDict['UserName']
         itchat.send(u"向用户[%s]发送失败,请检查是否存在该好友!"%(Comment), my)
         return None
Пример #26
0
def print_content(msg):
	global AutoReplay
	user=msg['User']
	name=''
	try:
		name=user['RemarkName']
		print name
		print user['NickName']
	except:
		print "error"
	res=GetResponse(msg['Text'])
	itchat.send(u'自动回复关闭', 'filehelper')
	return res
def tick():
    users = itchat.search_friends(name=u'七七') # 找到你女朋友的名称
    userName = users[0]['UserName']
    meetDate = dt.date(2012,4,22)  # 这是你跟你女朋友相识的日期
    now = dt.datetime.now()     # 现在的时间
    nowDate = dt.date.today()  # 今天的日期
    passDates = (nowDate-meetDate).days # 你跟你女朋友认识的天数
    itchat.send(u'今天是我们在一起第%d天,%s, 亲亲小媳妇'%(passDates,random.sample(greetList,1)[0]),toUserName=userName) # 发送问候语给女朋友
#     itchat.send(u'就问你服不服,%s'%(random.sample(greetList,1)[0]),toUserName=userName) 
    nextTickTime = now + dt.timedelta(days=1)
#     nextTickTime = now + dt.timedelta(seconds=2)
    nextTickTime = nextTickTime.strftime("%Y-%m-%d 00:00:00") 
    my_scheduler(nextTickTime) # 设定一个新的定时任务,明天零点准时问候
Пример #28
0
 def download_files(msg):
     dict = {'Picture': u"图片", "Gif": u"表情", "Recording": u"录音", "Video": u"小视频", "Attachment": u"文件"}
     fileDir = './storage/%s%s' % (msg['Type'], int(time.time()))
     flag = True
     if msg['Type'] == 'Gif': fileDir += '.gif'
     msg['Text'](fileDir)
     for destination in destinations(msg):
         itchat.send(u'%s发送了%s' % (msg['ActualDisplayName'], dict[msg['Type']]), destination)
         if not itchat.send('@%s@%s' % ('img' if msg['Type'] == 'Picture' or msg['Type'] == 'Gif' else 'fil', fileDir), destination):
             flag = False
     if not flag:
         for destination in destinations(msg):
             itchat.send(u'[暂不支持的官方表情]', destination)
Пример #29
0
def send_news():
    try:
        # 登陆你的微信账号,会弹出网页二维码,扫描即可
        itchat.auto_login(hotReload=True)
        # 获取你对应的好友备注,这里的小明我只是举个例子
        # 改成你最心爱的人的名字。
        my_friend = itchat.search_friends(name=u'小明')
        # 获取对应名称的一串数字
        XiaoMing = my_friend[0]["UserName"]
        # 获取金山字典的内容
        message1 = str(get_news()[0])
        content = str(get_news()[1][17:])
        message2 = str(content)
        message3 = "来自你最爱的人"
        # 发送消息
        itchat.send(message1, toUserName=XiaoMing)
        itchat.send(message2, toUserName=XiaoMing)
        itchat.send(message3, toUserName=XiaoMing)
        # 每86400秒(1天),发送1次,
        # 不用linux的定时任务是因为每次登陆都需要扫描二维码登陆,
        # 很麻烦的一件事,就让他一直挂着吧
        # t = time(86400, send_news())
        # t.start()
    except:
        message4 = u"今天最爱你的人出现了 bug /(ㄒoㄒ)/~~"
        itchat.send(message4, toUserName=XiaoMing)
Пример #30
0
def xyz_reply(msg):
    group_list = [u'我是渣渣辉', u'我是轱天乐', u'探挽懒月']
    group_name = []
    for group in group_list:
        chat = itchat.search_chatrooms(name=group)
        if len(chat) > 0:
            group_name.append(chat[0]['UserName'])
    # 过滤小宇宙新闻
    result = xyz_compile.search(msg['Content'])

    if result is not None:
        if result.group() is not None:
            for group in group_name:
                itchat.send('%s' % (msg['Content']), toUserName=group)
Пример #31
0
        html_parse = BeautifulSoup(pageSource, 'lxml')
        html = html_parse.findAll("div", {"class": "item no-picture"})
    except:
        print('没网了')
    finally:
        driver.close()
        driver.quit()
        return html


def getNews(html):
    news = str(datetime.datetime.now().date()) + '早报:\n\n'
    for i in range(len(html)):
        news += str(
            i +
            1) + '、' + html[i].a.next + '\n' + html[i].a.attrs['href'] + '\n\n'
    return news


url = 'https://news.baidu.com/internet'
html = getLinks(url)
news = getNews(html)
print('信息采集成功')

itchat.login()
friends = itchat.get_friends(update=True)[0:]
users = itchat.search_friends('徐才权')
userName = users[0]['UserName']
itchat.send(news, toUserName=userName)
#groups  = itchat.get_chatrooms(update=True)
Пример #32
0
    if re.search('2\+', msg['Text']):
        try:
            target_H = re.search('\+(\d*)', msg['Text'])
            Heigh = (int)(target_H.group(1))
            reply = insert_mysql_targetH(Heigh)
            return reply

        except Exception as e:
            #		raise e
            error = '设置发生错误'
            return error

    if re.search('3\+', msg['Text']):
        try:
            LED_S = re.search('\+(\d*)', msg['Text'])
            LedStatus = (int)(LED_S.group(1))
            reply = insert_mysql_LedStatus(LedStatus)
            return reply

        except Exception as e:
            #		raise e
            error = '设置发生错误'
            return error


itchat.auto_login(enableCmdQR=2)

itchat.send("Hello,FileHelper", toUserName='******')

itchat.run()
Пример #33
0
#coding=utf8
import itchat
from Lib.InteractMusicApi import interact_select_song, close_music

HELP_MSG = '''\
欢迎使用微信网易云音乐
帮助: 显示帮助
关闭: 关闭歌曲
歌名: 按照引导播放音乐\
'''


@itchat.msg_register('Text')
def music_player(msg):
    if msg['ToUserName'] != 'filehelper': return
    if msg['Text'] == u'关闭':
        close_music()
        return '音乐已关闭'
    if msg['Text'] == u'帮助':
        return HELP_MSG
    else:
        return interact_select_song(msg['Text'])


itchat.auto_login(True, enableCmdQR=True)
itchat.send(HELP_MSG)
itchat.run()
Пример #34
0
def text_reply(msg):
    msg_content = str(msg['Content'])
    msg_text = str(msg['Text'])
    to_user_name = msg['ToUserName']  # 我发消息的时候,toUserName为群
    from_user_name = msg['FromUserName']  # 别人发消息的时候,fromUserName为群
    actual_nick_name = msg['ActualNickName']
    if msg_content == '召唤机器人' or msg_content == '呼叫机器人':
        print("开始发送机器人skills 给" + actual_nick_name + ",来自" + from_user_name)
        itchat.send(
            u'@' + actual_nick_name + "\n回复[ ]中的内容等待回应\n" + "\n".join(skills),
            from_user_name)

    fun_reply = mix_fun(msg_content)
    if fun_reply != 'null':
        return fun_reply

    if msg_content == '平台币':
        itchat.send(u'%s' % get_pingtaicoin(), from_user_name)
    # 币圈群发货币代码获取行情h
    query_type = "现货"
    if msg_content.__contains__("季度") or msg_content.__contains__("合约"):
        query_type = "交割合约"
        msg_content = msg_content.replace("季度", "").replace("合约", "")
    if instrument_ids.keys().__contains__(msg_content):
        itchat.send(
            u'%s' % get_ticket(instrument_ids[msg_content], query_type),
            from_user_name)
    if msg_content.__contains__("-USDT"):
        itchat.send(u'%s' % get_ticket(msg_content, query_type),
                    from_user_name)

    if msg_content.__contains__('我要助力') or msg_content.__contains__('助力编号'):
        itchat.send(u'@小猪 发助力编号,小猪帮你助力..', from_user_name)
    if msg_content.strip().isdigit() and len(msg_content.strip()) == 8:
        zhuli_res = zhuliOne(msg_content.strip())
        if zhuli_res == '' or len(zhuli_res.strip()) == 0:
            zhuli_res = '成功'
        itchat.send(
            u'@' + msg['ActualNickName'] + ' 助力结果:' + zhuli_res +
            ',回助我:70144761', from_user_name)
    if msg_content == 'begin':  ## 自己输入
        list = zhuli()
        list2 = [str(i) for i in list]  # ['a','b','x','y']
        itchat.send(u'%s' % "\n".join(list2), to_user_name)
Пример #35
0
import itchat

#itchat.auto_login(hotReload=True)
itchat.auto_login(enableCmdQR=2)
itchat.send('Hello, filehelper', toUserName='******')
Пример #36
0
def send_stuff2():
    itchat.send("测试 at {}".format(time.asctime()), friend_user_name)
    print('发送成功..\n')
Пример #37
0
def logout():
    itchat.send('自动回复终止', 'filehelper')
Пример #38
0
def login_start():
    itchat.send(f'{robot_name}:开始工作啦!', 'filehelper')
Пример #39
0
    message = msg['Text']
    fromName = msg['FromUserName']
    toName = msg['ToUserName']

    if toName == "filehelper":
        if message == "cap":
            cap = cv2.VideoCapture(0)
            ret, img = cap.read()
            cv2.imwrite("weixinTemp.jpg", img)
            itchat.send('@img@%s' % u'weixinTemp.jpg', 'filehelper')
            cap.release()
        if message[0:3] == "cmd":
            os.system(message.strip(message[0:4]))
        if message == "ast":
            flag = 1
            itchat.send("消息助手已开启", "filehelper")
        if message == "astc":
            flag = 0
            itchat.send("消息助手已关闭", "filehelper")
    elif flag == 1:
        itchat.send(sendMsg, fromName)
        myfile.write(message)
        myfile.write("\n")
        myfile.flush()


if __name__ == '__main__':
    itchat.auto_login()
    itchat.send(usageMsg, "filehelper")
    itchat.run()
Пример #40
0
def send_msg(msg):
    # use itchat API
    msg = msg.decode('utf-8')
    itchat.send(msg, userName)
Пример #41
0
def send2groups(message, remarkNames):
    for remarkName in remarkNames:
        group = itchat.search_chatrooms(name=remarkName)[0]
        userName = group['UserName']
        itchat.send(message, toUserName=userName)
Пример #42
0
def send_move_save():
    users = itchat.search_friends(name = 'filehelper')
    '''userName = users[0]['UserName']'''
    itchat.send("He left, we are safe!", toUserName = '******')
    print('Success')
Пример #43
0
def send_move_danger():
    users = itchat.search_friends(name = 'filehelper')
    '''userName = users[0]['UserName']'''
    itchat.send("Someone is in the room!", toUserName = '******')
    itchat.send_image("breaker.jpg", toUserName = '******')
    print('Success')
Пример #44
0
def text_reply(msg):
    user_input = msg['Text']
    payload={"user_input":user_input}
    response = requests.get(bot_api,params=payload).json()["response"]
    itchat.send(response, msg['FromUserName'])
Пример #45
0
def send_stuff():
    itchat.send(u"测试2 - cute dog", friend_user_name)
    itchat.send_image(
        "/Users/aaronyu/Downloads/adorable-animal-animal-photography-1663421.jpg",
        friend_user_name)
    print('发送成功..\n')
Пример #46
0
def other_reply(msg):
    itchat.send(('那我祝您狗年大吉大利'), msg['FromUserName'])
Пример #47
0
dataset = itchat.get_friends(update=True)[1:]

# dataset选择部分列,
data = [{'NickName':item['NickName'], 'RemarkName':item['RemarkName'], 'UserName':item['UserName']} for item in dataset]

#转换为dataframe
df_all = pd.DataFrame()
for i in range(len(data)):
    df = pd.DataFrame([data[i]],index=[data[i]['NickName']])
    df_all =df_all.append(df)
    
#群发消息
while True:
    usernames=[]
    while len(usernames)==0:
        remarknmae_pre = input('请输入群发成员前缀:')
        df = df_all[df_all["RemarkName"].str.find(remarknmae_pre, start=0, end=None)>=0]
        usernames = df['UserName'].tolist()
    print('群发人数共{}人:'.format(len(usernames)),df['RemarkName'].values.tolist(),'\n')
    message = input('请输入群发内容:')
    print('\n')
    confirm =input('是否确认发送(y/n):')

    if confirm != 'y':
        print('\n','再来一次','\n')
        continue
    else: 
        for username in usernames: 
            itchat.send(message,toUserName = username)
        print('\n','发送成功!')
  
Пример #48
0
def text_reply(msg):
    match = re.search('年', msg['TEXT']).span()
    if match:
        itchat.send(('那我祝您狗年大吉大利'), msg['FromUserName'])
Пример #49
0
def get_friend(msg):
    if msg['ToUserName'] != 'filehelper': return
    friendStatus = get_friend_status(msg['RecommendInfo'])
    itchat.send(friendStatus, 'filehelper')
Пример #50
0
def SendMessage(name, message):
    target = itchat.search_friends(nickName=name)
    userName = target[0]['UserName']
    itchat.send(msg=message, toUserName=userName)
Пример #51
0
def get_friend_status(friend):
    ownAccount = itchat.get_friends(update=True)[0]
    if friend['UserName'] == ownAccount['UserName']:
        return u'检测到本人账号。'
    elif itchat.search_friends(userName=friend['UserName']) is None:
        return u'该用户不在你的好友列表中。'
    else:
        chatroom = CHATROOM or get_chatroom()
        if chatroom is None: return CHATROOM_MSG
        r = itchat.add_member_into_chatroom(chatroom['UserName'], [friend])
        print(r)
        if r['BaseResponse']['ErrMsg'] == u'请求成功':
            status = r['MemberList'][0]['MemberStatus']
            itchat.delete_member_from_chatroom(chatroom['UserName'], [friend])
            #以下使用字典 get() 函数返回指定键的值,如果值不在字典中返回默认值:dict.get(key, default=None)
            return { 3: u'该好友已经将你加入黑名单。',
                4: u'该好友已经将你删除。', }.get(status,
                u'该好友仍旧与你是好友关系。')
        else:
            return u'无法获取好友状态,预计已经达到接口调用限制。'

@itchat.msg_register(itchat.content.CARD)
def get_friend(msg):
    if msg['ToUserName'] != 'filehelper': return
    friendStatus = get_friend_status(msg['RecommendInfo'])
    itchat.send(friendStatus, 'filehelper')

itchat.auto_login(True)
itchat.send(HELP_MSG, 'filehelper')
itchat.run()
Пример #52
0
def parsejsonCont(jsonCont):
    dimensionCapacity = ''
    refurbClearModel = ''
    dimensionRelYear = ''
    dimensionScreensize = ''
    ptxt = ''
    title = jsonCont['title']
    try:
        refurbClearModel = jsonCont['filters']['dimensions'][
            'refurbClearModel']
    except Exception:
        print('%s no refurbClearModel' % (title))
    try:
        dimensionRelYear = jsonCont['filters']['dimensions'][
            'dimensionRelYear']
    except Exception:
        print('%s no dimensionRelYear' % (title))
    try:
        dimensionScreensize = jsonCont['filters']['dimensions'][
            'dimensionScreensize']
    except Exception:
        print('%s no dimensionScreensize' % (title))

    if refurbClearModel == 'macbookpro' and dimensionRelYear == '2018' \
    and dimensionScreensize=='13inch':
        try:
            dimensionCapacity = jsonCont['filters']['dimensions'][
                'dimensionCapacity']
        except Exception:
            print('%s no dimensionCapacity' % (title))
        dimensionColor = jsonCont['filters']['dimensions']['dimensionColor']
        tsMemorySize = jsonCont['filters']['dimensions']['tsMemorySize']
        amount = jsonCont['price']['currentPrice']['amount']
        productDetailsUrl = jsonCont['productDetailsUrl']

        cpuType = ''
        if title.find('i5') != -1:
            cpuType = 'i5'
        elif title.find('i7') != -1:
            cpuType = 'i7'
        else:
            cpuType = 'unknown'

        ptxt = 'MacBook Pro %s, %s, %s, %s, %s, %s, %s\n' % (
            dimensionScreensize, dimensionColor, cpuType, dimensionRelYear,
            tsMemorySize.upper(), dimensionCapacity.upper(), amount)
        print(ptxt)
        if tsMemorySize == '16gb' and (dimensionCapacity == '512gb' or dimensionCapacity == '1tb') \
        and cpuType == 'i5':
            bookUrl = 'https://www.apple.com%s' % (productDetailsUrl)
            print(bookUrl)
            print('==================================')
            f.write(bookUrl)
            f.write('==================================\n')
            global noticeCount
            if noticeCount < 6:
                if nType.upper() == 'WX':
                    itchat.send(
                        '速度点击下面链接, 关注的好东西到了! %s\n %s' % (nowTime, ptxt),
                        'filehelper')
                    itchat.send(bookUrl, 'filehelper')
                else:
                    messagebox.showwarning("提示", '关注的好东西到了!%s' % nowTime)
            #web.open_new(bookUrl)
            noticeCount = noticeCount + 1
            isHave = 1
    return ptxt
Пример #53
0
# -*- coding: UTF-8 -*-

import itchat

if __name__ == '__main__':
    itchat.auto_login(
        hotReload=True)  # 登录,会下载二维码给手机扫描登录,hotReload设置为True表示以后自动登录
    itchat.send('hello my love', toUserName='******')  # 发送信息给微信文件助手

    friends = itchat.search_friends(name='好友昵称')  # 获取微信好友列表
    userName = friends[0]['UserName']
    itchat.send('hello my love', toUserName=userName)  # 发送信息给指定好友

    itchat.run()  # 让itchat一直运行
Пример #54
0
isHave = 0
if __name__ == '__main__':
    print('请输入通知方式:')
    nType = input()
    if nType.upper() == 'WX':
        print('通知方式: 微信')
        itchat.login()
    else:
        print('通知方式: 本地')
    count = 1
    refurbishedUrl = 'https://www.apple.com/cn/shop/refurbished/mac/512gb-%E6%B7%B1%E7%A9%BA%E7%81%B0%E8%89%B2-%E9%93%B6%E8%89%B2-2018-13-%E8%8B%B1%E5%AF%B8-macbook-pro-16gb'
    while 1:
        f = open('D:/code/python_script/fetch_web_data/data.txt',
                 'a',
                 encoding="utf-8")
        nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        print('%s, 当前第%d次开始扫描' % (nowTime, count))
        f.write('%s, 当前第%d次开始扫描\n' % (nowTime, count))
        currentTime = time.time()
        url = '%s?%s' % (refurbishedUrl, currentTime)
        fecth_mac_book_web(url)
        f.close()
        if (count == 1 or count % 8 == 0) and nType.upper() == 'WX':
            if noticeCount > 0:
                itchat.send('已经成功扫描到%d次,请尽快下单!%s' % (noticeCount, nowTime),
                            'filehelper')
            else:
                itchat.send('已经扫描了%d次,不辞劳苦,继续加油!%s' % (count, nowTime),
                            'filehelper')
        count = count + 1
        time.sleep(90)
Пример #55
0
import itchat
itchat.login()
itchat.send(u'你好啊','filehelper')
Пример #56
0
def print_content(msg):
    print(msg['Text'], msg.user)
    if msg.user.UserName == 'filehelper':
        itchat.send('Hello, filehelper', toUserName=msg.user.UserName)
Пример #57
0
def download_files(msg):
    itchat.send('这是我的小号,暂无调戏功能,有事请加我大号:Honlann', msg['FromUserName'])
Пример #58
0
    print('Successful login')


def ec():
    print('Exit')

# user是要发送给的人的名单
def send_Message(user):
    users = list()
    for person in user:
        # 异常捕获是因为微信可能没加这个人
    	try:
    		tmp = itchat.search_friends(name='郑棉鑫')[0]['UserName']
    		users.append(tmp)
    	except:
    		print('找不到: '+person)
    content = '那我是 弱智了。。。 x'
    # print(len(users))
    for person in users:
        itchat.send(content, person)

itchat.auto_login(loginCallback=lc, exitCallback=ec, hotReload=True)
for i in range(10000, 0, -1):
    content = '那我是 弱智了。。。 x%d' % i
    itchat.send(content, itchat.search_friends(name='郑棉鑫')[0]['UserName'])
    
# rest = get_rest()
# send_Message(user=rest)

itchat.logout()
Пример #59
0
def send_move(friends_name, text):
    users = itchat.search_friends(name = friends_name)
    print(users)
    userName = users[0]['UserName']
    itchat.send(text, toUserName = '******')
    print('Success')
Пример #60
0
def send2indiduals(message, individuals):
    for individual in individuals:
        person = itchat.search_friends(remarkName=individual)[0]
        userName = person['UserName']
        itchat.send(message, toUserName=userName)