qqbot_for_husthole

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

README

qqbot-for-husthole

华科树洞的QQ机器人功能封装

如何使用
  1. 获取包
go get github.com/ufatfat/qqbot-for-husthole
  1. 引入包
import qqbot "github.com/ufatfat/qqbot-for-husthole"
  1. 将事件监听中间件加入路由树
router.Post("/event_listener", qqbot.BotEventHandler)
  1. 初始化bot
bot, err := qqbot.InitBot("{botServer}", "{redirectServer}", "{mysqlConn}", "{redisConn}", "{redisPassword}", {redisDB})

如:

bot, _ := qqbot.InitBot("http://localhost:2333/", "http://husthole.com/", "YOUR_ACCOUNT:YOUR_PASSWORD@tcp(YOUR_MYSQL_DATABASE:3306)/YOUR_DATABASE?parseTime=True", "YOUR_REDIS_IP:6379", "YOUR_REDIS_PASSWORD", YOUR_REDIS_DB)
API Docs
发送回复通知

原型:

func (bot *QQBot) SendReplyNotice (isComment bool, userID uint64, holeID, replyID uint, timestamp time.Time, userAlias, content, original string) (err error)

使用:

bot, _ := qqbot.InitBot("http://localhost:2333/", "http://husthole.com/", "YOUR_ACCOUNT:YOUR_PASSWORD@tcp(YOUR_MYSQL_DATABASE:3306)/YOUR_DATABASE?parseTime=True", "YOUR_REDIS_IP:6379", "YOUR_REDIS_PASSWORD", YOUR_REDIS_DB)

_ = bot.SendReplyNotice(true, 570407467, 123, 1, time.Now(), "东九大宝贝", "一个测试", "测试测试")

收到内容:

东九大宝贝回复了您发表的#123号树洞
时间:04:23:33
内容:一个测试
查看回复:http://husthole.com/?holeID=123&replyID=1

Documentation

Index

Constants

View Source
const (
	BOT_SERVER      = "http://localhost:4000/"
	REDIRECT_SERVER = "http://husthole.com/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BindInfo added in v0.0.3

type BindInfo struct {
	BindingStatus int8
	BindQQ        int64
}

绑定QQ信息

参数信息:

BindingStatus:绑定状态 //0: 未绑定; 1: 正在绑定; 2: 已绑定

BindQQ:绑定的QQ

type QQBot added in v0.0.2

type QQBot struct {
	BotServer      string
	RedirectServer string
	Rdb            *redis.Client
	Db             *sql.DB
	ErrQQBound     error
}

func InitBot added in v0.0.2

func InitBot(botServer, redirectServer, mysqlConn, redisConn, redisPswd string, redisDB int) (bot *QQBot, err error)

func (*QQBot) BindQQ added in v0.0.2

func (bot *QQBot) BindQQ(QQ int64, encryptedEmail string) (err error)

功能: 绑定QQ至用户账号

参数:

QQ: 用户要绑定的qq

encryptedEmail: 用户加密后的email

func (*QQBot) BotEventHandler added in v0.0.2

func (bot *QQBot) BotEventHandler(c *gin.Context)

func (*QQBot) GetBindInfo added in v0.0.3

func (bot *QQBot) GetBindInfo(encryptedEmail string) (bindInfo BindInfo, err error)

功能: 获取用户的QQ绑定状态

参数: encryptedEmail: 加密后的email

返回值: bindInfo BindInfo, err error

func (*QQBot) GetBotQQ added in v0.1.3

func (bot *QQBot) GetBotQQ() (botQQ int64, err error)

返回Bot的QQ号, 现暂只有一个Bot

func (*QQBot) GetStatus added in v0.1.4

func (bot *QQBot) GetStatus(encryptedEmail string) (status bool, err error)

func (*QQBot) SendReplyNotice added in v0.0.2

func (bot *QQBot) SendReplyNotice(isComment bool, holeID, replyID uint, timestamp time.Time, encryptedEmail, userAlias, content string) (err error)

功能:发送回复通知

参数:

isComment: 是否为对树洞本身的回复

holeID: 树洞号

replyID: 回复ID

timestamp: 回复时间戳

encryptedEmail: 加密后的用户email

userAlias: 树洞昵称

content: 回复内容

func (*QQBot) ToggleStatus added in v0.1.4

func (bot *QQBot) ToggleStatus(encryptedEmail string) (status bool, err error)

Jump to

Keyboard shortcuts

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