Git Product home page Git Product logo

wx-robot's Introduction

python itchat+机器人web api实现个人微信机器人


本项目github地址

###效果图

demo1

demo2


使用方法(前提是设备安装了python):

本地使用:下载本项目到本地,解压,进入项目目录,输入pip install itchat,等待安装完成,输入python wx.py,用手机微信描生成的二维码,确认登陆即可


核心


##图灵机器人apikey

在本项目中使用的是我的图灵机器人apikey,这个机器人的名字是火腿,谨纪念最后一条我亲手养大的狗仔。他的爸爸是我,妈妈是安妮海瑟薇。

你可以获取自己的图灵机器人apikey,注册图灵机器人账号,创建机器人,在机器人详情中你会看到你的专属apikey:

apikey

复制你的apikey,打开下载到本地我的github项目wx-robot,打开tuling.py文件,把下面的key的值,即7c1ccc2786df4e1685dda9f7a98c4ec9改为你自己的apikey即可。

data = {0
    'key'    : '7c1ccc2786df4e1685dda9f7a98c4ec9', # 如果这个Tuling Key不能用,那就换一个
    'info'   : _info, # 这是我们发出去的消息
    'userid' : 'wechat-robot', # 这里你想改什么都可以
}

可以登陆自己的图灵机器人账号,在我的机器人那里设置自己机器人的身份以及父母等等,挺好玩的,如下:

setRotbot


##关键文件

本项目只有两个关键文件:

  1. wx.py(负责微信登陆与响应)

源自wx.py

#itchat装饰器
@itchat.msg_register(itchat.content.TEXT)
#定义消息回复函数
def text_reply(msg):
    return "柱明家的火腿:" + getResponse(msg["Text"])["text"]
#扫码登陆
itchat.auto_login(enableCmdQR=True)
#运行itchat
itchat.run()
  1. tuling.py(负责发送信息给图灵机器人api,并获取机器人的回复)

源自tuling.py

wx-robot's People

Contributors

gzm1997 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.