狗仔小分队的博客

  • 服务器
    • 干货推荐
    • 教程&一键脚本
    • 特价监控
  • 实用工具
    • 小工具汇总
  • 教程
    • Ubuntu
    • Python
    • 学习
  • 福利
    • 商城
    • 薅羊毛
    • 影视&资源推荐
  1. 首页
  2. 教程
  3. Python
  4. 正文

python 微信机器人

2017年6月14日 4295点热度 0人点赞 0条评论

使用wxpy库
目前微信小号,手机不登陆,wxpy只能保持20小时在线

照着官方手册抄下来的最简单的代码:

# pip install pillow wxpy
# coding: utf-8
from __future__ import unicode_literals
from wxpy import *
import time

dstart=0
def caltime():
global dstart
if dstart==0:
dstart=int(time.time())
dnow=int(time.time())
ddiff=dnow-dstart
dday=ddiff//86400
dhour=ddiff%86400//3600
dminute=ddiff%3600//60
dsecond=ddiff%60
return (dday,dhour,dminute,dsecond)

bot = Bot('bot.pkl',console_qr=True)
caltime()
# my_friend = bot.friends().search("xx")[0]
# my_friend.send('Hello WeChat!')

@bot.register(Friend)
def reply_test(msg):
msg.reply('在线时间 %s 天 %s 小时 %s 分钟 %s 秒'%caltime())
msg.reply(msg.text+' .. got it!')

bot.join()

 

标签: bot python
最后更新:2017年10月14日

xiaofd

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

COPYRIGHT © 2021 xiaofd.net. ALL RIGHTS RESERVED.

THEME KRATOS MADE BY VTROIS