go version wechat web api
go get -u -v github.com/songtianyi/wechat-go
mkdir $GOPATH/src/golang.org/x
cd $GOPATH/src/golang.org/x
git clone https://github.com/golang/net.git
git clone https://github.com/golang/text.git
package main
import (
"github.com/songtianyi/rrframework/logs"
"github.com/songtianyi/wechat-go/plugins/faceplusplus"
"github.com/songtianyi/wechat-go/wxweb"
"github.com/songtianyi/wechat-go/plugins/wxweb/gifer"
"github.com/songtianyi/wechat-go/plugins/wxweb/replier"
"github.com/songtianyi/wechat-go/plugins/wxweb/switcher"
)
func main() {
// create session
session, err := wxweb.CreateSession(nil, wxweb.TERMINAL_MODE)
if err != nil {
logs.Error(err)
return
}
// add plugins for this session, they are disabled by default
faceplusplus.Register(session)
replier.Register(session)
switcher.Register(session)
gifer.Register(session)
// enable plugin
session.HandlerRegister.EnableByName("switcher")
session.HandlerRegister.EnableByName("faceplusplus")
if err := session.LoginAndServe(); err != nil {
logs.Error("session exit, %s", err)
}
}
一个管理插件的插件
#关闭某个插件, 在微信聊天窗口输入
disable faceplusplus
#开启某个插件, 在微信聊天窗口输入
enable faceplusplus
#查看所有插件信息, 在微信聊天窗口输入
dump
对收到的图片做面部识别,返回性别和年龄
以收到的文字消息为关键字做gif搜索,返回gif图, 注意返回的gif可能尺度较大,比如文字消息中包含“污”等关键词。
对收到的文字/图片消息,做自动应答,回复固定文字消息