堕落了

Posted by bfpiaoran on October 8, 2017

前一阵子一直看java

然后十一当了一把咸鱼  在游戏中度过

这几天生怕python忘记了

随手看了一个库

itchat  一个很nice的库

抽空自己试着写个库

http://itchat.readthedocs.io/zh/latest/

补上脚本

import itchat,random,time

@itchat.msg_register(itchat.content.TEXT)
def print_content(msg):
    print(msg['Text'])  # 打印接收到的消息
    print(msg)

def test():
    test = u'检测好友'
    my = itchat.search_friends()
    print(my)
    friendList = itchat.get_friends(update=True)[1:]
    for i in friendList:
        print(i['NickName'])
        if i['NickName'] == '陈晨':
            status = itchat.send(msg=test,toUserName=i['UserName'])
            a = 0
            for i in status:
                print(i)
                if i == 'MsgID':
                    break
                else:
                    a += 1
            print(a)
        # print(i['UserName'])
        # print(i['DisplayName'])
        # print(test, i['UserName'])
        # try:
        #     itchat.send(msg=test,toUserName=i['UserName'])
        # except Exception as e:
        #     print(e)
        # time.sleep(1+random.random()*124)

# itchat.auto_login(hotReload=True)   保存cookie  enableCmdQR=True 命令行二维码
itchat.auto_login()
test()
itchat.run()