Git Product home page Git Product logo

qianxun-wechat-sdk's Introduction

千寻微信框架的 Python SDK

介绍

千寻微信框架的 Python SDK,基于千寻微信框架的 HTTP API 接口,封装了一些常用的接口,方便开发者使用。

安装

pip install qianxun-wechat-sdk

使用示例

import qianxun.Emoji as Emoji       # 导入 qianxun Emoji 表情模块
from qianxun.SDK import Robot       # 导入 qianxun SDK 框架

# 创建一个回调函数来接收 qianxun 框架的回调事件
def callback(request):
    print('=' * 50 + '回调事件' + '=' * 50, end='\n\n')
    print(request)

    if request['event'] == 10014:
        print('账号变动事件(10014)')

    if request['event'] == 10008:
        print('收到群聊消息(10008)')

    if request['event'] == 10009:
        print('收到私聊消息(10009)')

    if request['event'] == 10010:
        print('自己发出消息(10010)')

    if request['event'] == 10006:
        print('收到转账事件(10006)')

    if request['event'] == 10013:
        print('撤回事件(10013)')

    if request['event'] == 10011:
        print('好友请求(10011)')

    if request['event'] == 10007:
        print('支付事件(10007)')


if __name__ == '__main__':

    # 创建一个机器人实例,传入机器人的 ip 和端口,以及机器人的 wxid (可选)
    robot = Robot(host='127.0.0.1', port=7777, bot_wxid='')

    # 调用机器人的登录接口, 获取机器人的 wxid
    robot.bot_wxid = robot.getWeChatList()['result'][0]['wxid']

    # 创建一个机器人的回调事件,传入回调函数和端口
    robot.callbackEvents(callback_fun=callback, port=5000)

    # 调用机器人的发送文本消息接口,传入机器人的 wxid 和消息内容
    robot.sendTextMessage(wxid='filehelper', msg=f'你好 {Emoji.小丑脸} 测试 {Emoji.表情_捂脸}')

qianxun-wechat-sdk's People

Contributors

iibeibei avatar

Stargazers

DeMiao avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

digjack

qianxun-wechat-sdk's Issues

callback里应该怎么正确的回复消息?我这样新建一个robot对吗

def callback(request):
    import qianxun.Emoji as emoji
    from qianxun.SDK import Robot
    robot = Robot(host='127.0.0.1', port='7777', bot_wxid='')
    robot.bot_wxid = robot.getWeChatList()['result'][0]['wxid']
    if request['event'] == 10009:
        print('收到个人消息事件(10009)')
        wxid = request['data']['data']['fromWxid']
        robot.sendTextMessage(wxid=wxid, msg=f'测试,回复个人')
if __name__ == '__main__':
    robot = Robot(host='127.0.0.1', port='7777', bot_wxid='')
    robot.bot_wxid = robot.getWeChatList()['result'][0]['wxid']
    robot.callbackEvents(callback_fun=callback)

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.