Giter Site home page Giter Site logo

wechat-bot's Introduction

wechat-bot

Build Status Inline docs Gem version License

微信机器人 Ruby 版本。

快速上手

require 'wechat-bot'

bot = WeChat::Bot.new do
  on :message, "ping" do |message|
    message.reply "PONG"
  end
end

bot.start

wechat-bot's People

Contributors

dependabot-preview[bot] avatar icyleaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

slacken

wechat-bot's Issues

加载报错

/Users/jevan/.rvm/gems/ruby-2.4.1/gems/wechat-bot-0.1.0.alpha/lib/wechat/bot/ext/wechat_emoji_string.rb:1:in `<top (required)>': uninitialized constant WeChat (NameError)
	from /Users/jevan/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /Users/jevan/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /Users/jevan/.rvm/gems/ruby-2.4.1/gems/wechat-bot-0.1.0.alpha/lib/wechat/bot.rb:1:in `<top (required)>'
	from /Users/jevan/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /Users/jevan/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /Users/jevan/.rvm/gems/ruby-2.4.1/gems/wechat-bot-0.1.0.alpha/lib/wechat-bot.rb:1:in `<top (required)>'
	from /Users/jevan/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
	from /Users/jevan/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
	from /Users/jevan/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'

看文件结构 最顶部的module应该为Wechat?

验证消息的支持

添加好友的消息验证支持:

{
    "BaseResponse": {
        "Ret": 0,
        "ErrMsg": ""
    },
    "AddMsgCount": 1,
    "AddMsgList": [
        {
            "MsgId": "2072363471476057614",
            "FromUserName": "fmessage",
            "ToUserName": "@cccccccccccccccc",
            "MsgType": 37,
            "Content": "&lt;msg fromusername=\"icyleaf\" encryptusername=\"aaaaaaaaa@stranger\" fromnickname=\"icyleaf<span class=\"emoji emoji1f37a\"></span>\" content=\"我是icyleaf\"  shortpy=\"ICYLEAF?\" imagestatus=\"3\" scene=\"3\" country=\"NL\" province=\"Rotterdam\" city=\"\" sign=\"爱好户外的代码仔,下厨初心者\" percard=\"1\" sex=\"1\" alias=\"\" weibo=\"\" weibonickname=\"\" albumflag=\"0\" albumstyle=\"0\" albumbgimgid=\"916984107630592_916984107630592\" snsflag=\"49\" snsbgimgid=\"http://mmsns.qpic.cn/mmsns/pbuUcBancwpmPuCsleNS6mqkicTJ4Z50HYANOp5SwUdHLU0g/0\" snsbgobjectid=\"11932405796503722\" mhash=\"ce0d1651a79363d221fd668d359a\" mfullhash=\"ce0d1651a79363d22fd668d359a\" bigheadimgurl=\"http://wx.qlogo.cn/mmhead/ver_1/cF4rribxYH1bmLvoHVwweibgwnENFjcDjQcnuKQxuyQMzfxZZuHvpfA5icpGicguLnBIkyBiagtiboNREOFz82Q/0\" smallheadimgurl=\"http://wx.qlogo.cn/mmhead/ver_1/cF4rribxYeHLvoHVwweibgwnENFjcDjQcnuKQxuyQMzfxZZuHvpfA5icpGicguLnBIkyBiagtiboNREOFz82Q/132\" ticket=\"v2_8bbdcbb874412bff7a689586ab7595e025cb6721216ce80a321ef0f5badb739bac81793079d39e20104b2ed31944@stranger\" opcode=\"2\" googlecontact=\"\" qrticket=\"\" chatroomusername=\"\" sourceusername=\"\" sourcenickname=\"\"&gt;&lt;brandlist count=\"0\" ver=\"658641770\"&gt;&lt;/brandlist&gt;&lt;/msg&gt;",
            "Status": 3,
            "ImgStatus": 1,
            "CreateTime": 1498458422,
            "VoiceLength": 0,
            "PlayLength": 0,
            "FileName": "",
            "FileSize": "",
            "MediaId": "",
            "Url": "",
            "AppMsgType": 0,
            "StatusNotifyCode": 0,
            "StatusNotifyUserName": "",
            "RecommendInfo": {
                "UserName": "@aaaaaaaaaaaaaaaa",
                "NickName": "icyleaf<span class=\"emoji emoji1f37a\"></span>",
                "QQNum": 0,
                "Province": "Rotterdam",
                "City": "",
                "Content": "我是icyleaf",
                "Signature": "爱好户外的代码仔,下厨初心者",
                "Alias": "",
                "Scene": 3,
                "VerifyFlag": 0,
                "AttrStatus": 37986749,
                "Sex": 1,
                "Ticket": "v2_8bbdcbb874412bfb6721216ce80a321ef0f5badb739bac81793079d39e20104b2ed31944@stranger",
                "OpCode": 2
            },
            "ForwardFlag": 0,
            "AppInfo": {
                "AppID": "",
                "Type": 0
            },
            "HasProductId": 0,
            "Ticket": "",
            "ImgHeight": 0,
            "ImgWidth": 0,
            "SubMsgType": 0,
            "NewMsgId": 2072363471476057600,
            "OriContent": ""
        }
    ],
    "ModContactCount": 0,
    "ModContactList": [],
    "DelContactCount": 0,
    "DelContactList": [],
    "ModChatRoomMemberCount": 0,
    "ModChatRoomMemberList": [],
    "Profile": {
        "BitFlag": 0,
        "UserName": {
            "Buff": ""
        },
        "NickName": {
            "Buff": ""
        },
        "BindUin": 0,
        "BindEmail": {
            "Buff": ""
        },
        "BindMobile": {
            "Buff": ""
        },
        "Status": 0,
        "Sex": 0,
        "PersonalCard": 0,
        "Alias": "",
        "HeadImgUpdateFlag": 0,
        "HeadImgUrl": "",
        "Signature": ""
    },
    "ContinueFlag": 0,
    "SyncKey": {
        "Count": 8,
        "List": [
            {
                "Key": 1,
                "Val": 111
            },
            {
                "Key": 2,
                "Val": 22
            },
            {
                "Key": 3,
                "Val": 33
            },
            {
                "Key": 11,
                "Val": 444
            }
        ]
    },
    "SKey": "",
    "SyncCheckKey": {
        "Count": 8,
        "List": [
            {
                "Key": 1,
                "Val": 1111
            },
            {
                "Key": 2,
                "Val": 222
            },
            {
                "Key": 3,
                "Val": 333
            },
            {
                "Key": 11,
                "Val": 444
            }
        ]
    }
}

TODO: 微信 API 接口

  • 登录
    • jslogin 获取 uuid
    • l/uuid 获取 QR Code
    • login 验证登录
    • webwxinit 初始化
    • webwxstatusnotify 设置状态通知
  • 登出
    • webwxlogout 登出
  • 新消息
    • synccheck 消息状态
    • webwxsync 消息详情
  • 消息
    • webwxsendmsg 文本消息
    • webwxsendmsgimg 图片消息
    • webwxsendemoticon 自定义表情消息(不支持微信商店表情)
    • webwxrevokemsg 撤回消息
  • 联系人
    • webwxgetcontact 联系人列表
    • webwxbatchgetcontact 批量获取联系人列表
    • webwxverifyuser 添加好友
  • 图片/文件
    • webwxuploadmedia 上传图片
    • webwxgetmsgimg 获取具体图片
  • 群组
    • webwxcreatechatroom 创建群组
    • webwxupdatechatroom 更新群组(修改群组名、添加/删除成员)

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.