华科树洞的QQ机器人功能封装
- 获取包
go get github.com/ufatfat/qqbot-for-husthole
- 引入包
import qqbot "github.com/ufatfat/qqbot-for-husthole"
- 将事件监听中间件加入路由树
router.Post("/event_listener", qqbot.BotEventHandler)
- 初始化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)
原型:
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