qqbot

package module
v0.0.0-...-60b5e74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2016 License: MIT Imports: 17 Imported by: 1

README

This is a client of the smart-web-qq in the Go programming language.

Installation

go get github.com/MrToy/qqbot/examples
cd $GOPATH/github.com/MrToy/qqbot/examples
go build robot.go

or directly

go run robot.go

Usage

  • This is how to get friends list
import "github.com/MrToy/qqbot"
...
user := qqbot.NewUser()
qqbot.WebHandler(user.WaitVerify())
user.Login()
fmt.Println(user.GetFriends())
...

start qqbot and open http://loacalhost:8081/captcha ,then use mobile qq scan this captcha

  • This is how to login with cache
import "github.com/MrToy/qqbot"
...
store := qqbot.NewUserStore("./user")
defer store.DB.Close()
user := store.Get()
if err := user.Login(); err != nil {
	qqbot.WebHandler(user.WaitVerify())
	user.Login()
}
store.Put(user)
fmt.Println(user.GetFriends())
...
  • Message Get and Send 【you must be logined】
...
user.SendMessage(uin,"some text")
...
for msg := range user.Poll() {
   fmt.Println(msg)
}
...

And You can use "图灵机器人" API for reduce the message

qqbot.Tulin(uin int64,msg string, key string) string
//This uin is a tag who speaked
//This key you can get by 图灵机器人's website

More usage examples please view https://github.com/MrToy/qqbot/examples

Documentation

You can read APIs in package documentation here https://godoc.org/github.com/MrToy/qqbot

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tulin

func Tulin(uid int64, info, key string) string

func TxHash

func TxHash(uin int, pt string) string

func WebHandler

func WebHandler(c chan image.Image)

Types

type Friend

type Friend struct {
	Nick     string
	MarkName string
	Uin      int64
	Status   string
}

type Group

type Group struct {
	Code int64
	Name string
	Gid  int64
}

type Message

type Message struct {
	Type    string //one of message|group_message
	From    int64
	To      int64
	Content string
}

type SelfInfo

type SelfInfo struct {
	Account  int64
	Nick     string
	Gender   string
	Country  string
	Province string
	City     string
}

type User

type User struct {
	Client                       http.Client `json:"-"`
	Captcha                      image.Image `json:"-"`
	Vfwebqq, Ptwebqq, Pssesionid string
	Uin                          int
}

func NewUser

func NewUser() *User

func (*User) GetFriends

func (this *User) GetFriends() []Friend

func (*User) GetGroups

func (this *User) GetGroups() []Group

func (*User) GetOnline

func (this *User) GetOnline() []Friend

func (*User) GetSelfInfo

func (this *User) GetSelfInfo() SelfInfo

func (*User) Login

func (this *User) Login() error

func (*User) Poll

func (this *User) Poll() chan Message

func (*User) SendDiscuMessage

func (this *User) SendDiscuMessage(uin int64, content string) error

func (*User) SendGroupMessage

func (this *User) SendGroupMessage(uin int64, content string) error

func (*User) SendMessage

func (this *User) SendMessage(uin int64, content string) error

func (*User) WaitVerify

func (this *User) WaitVerify() chan image.Image

type UserStore

type UserStore struct {
	DB *leveldb.DB
}

func NewUserStore

func NewUserStore(p string) *UserStore

func (*UserStore) Clear

func (this *UserStore) Clear()

func (*UserStore) Get

func (this *UserStore) Get() *User

func (*UserStore) Put

func (this *UserStore) Put(user *User)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL