Skip to content

Commit

Permalink
更新readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsongyan committed Sep 11, 2017
1 parent f53f5a6 commit 407147f
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# qbot
基于webqq协议的qq机器人
基于webqq协议的qq机器人(2017-09-11测试可用)

# 使用方法
```
go get -u -v github.com/wangsongyan/qbot
```
```
package main
import (
"fmt"
"io/ioutil"
"os/exec"
"github.com/wangsongyan/qbot"
)
func execCommand(path string) {
c := exec.Command("cmd", "/C", "start", path)
if err := c.Run(); err != nil {
//fmt.Println("Error: ", err)
}
}
func main() {
r, _ := qbot.New()
r.OnQRChange(func(r *qbot.Robot, qrdata []byte) {
if err := ioutil.WriteFile("v.png", qrdata, 0666); err == nil {
execCommand("v.png")
}
})
r.OnMessage(func(r *qbot.Robot, message *qbot.Message) {
fmt.Println(message)
switch message.PollType {
case "message":
r.SendToBuddy(message.FromUin, message.Content+"\r\n\t--qbot")
case "group_message":
//r.SendToGroup(message.FromUin, message.Content)
case "discu_message":
//r.SendToDiscuss(message.FromUin, message.Content)
}
})
r.Run()
}
```

0 comments on commit 407147f

Please sign in to comment.