用python代码玩微信

# 安装包 pip install -U wxpy
from wxpy import *
import time
import json
bot=Bot()
my_friend = bot.friends().search('xxxx')[0]
# group=bot.groups().search("微信群")[0]
# # 打印来自其他好友、群聊和公众号的消息
# @bot.register()
# def print_others(msg):
#     print(msg)
#
# # 回复 my_friend 的消息 (优先匹配后注册的函数!)
# @bot.register(group)
# def reply_my_friend(msg):
#     return 'received: {} ({})'.format(msg.text, msg.type)
#
# # 自动接受新的好友请求
# @bot.register(msg_types=FRIENDS)
# def auto_accept_friends(msg):
#     # 接受好友请求
#     new_friend = msg.card.accept()
#     # 向新的好友发送消息
#     new_friend.send('哈哈,我自动接受了你的好友请求')
# embed()
# while True:
# for i in range(100):
#     time.sleep(1)
#     list_one = group.members[3].name
#     group.send('@{} 二林'.format(list_one))  # (这里可以设置微信群@的任何一个人)
#

my_friend.send("哈哈哈")
# 发送图片
# my_friend.send_image('my_picture.jpg')
# 进入 Python 命令行、让程序保持运行
embed()

# 或者仅仅堵塞线程
# bot.join()

 

posted @ 2019-01-02 12:17  晴空!  阅读(330)  评论(0编辑  收藏  举报