45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package newbond
|
|
|
|
import (
|
|
"git.lxtend.com/qqbot/constants"
|
|
"git.lxtend.com/qqbot/handler"
|
|
"git.lxtend.com/qqbot/model"
|
|
)
|
|
|
|
func init() {
|
|
handler.RegisterHandler("监听新债", listenBond, constants.LEVEL_USER)
|
|
handler.RegisterHelpInform("监听新债", "新债", "开启新债监听")
|
|
handler.RegisterHandler("取消监听新债", unListenBond, constants.LEVEL_USER)
|
|
handler.RegisterHelpInform("取消监听新债", "新债", "关闭新债监听")
|
|
}
|
|
|
|
func listenBond(msg model.Message) (reply *model.Reply) {
|
|
if err := AddGroupListen(int(msg.GroupInfo.GroupId)); err != nil {
|
|
return &model.Reply{
|
|
ReplyMsg: "开启新债监听失败,报错: " + err.Error(),
|
|
ReferOriginMsg: true,
|
|
FromMsg: msg,
|
|
}
|
|
}
|
|
return &model.Reply{
|
|
ReplyMsg: "开启新债监听成功",
|
|
ReferOriginMsg: true,
|
|
FromMsg: msg,
|
|
}
|
|
}
|
|
|
|
func unListenBond(msg model.Message) (reply *model.Reply) {
|
|
if err := RemoveGroupListen(int(msg.GroupInfo.GroupId)); err != nil {
|
|
return &model.Reply{
|
|
ReplyMsg: "关闭新债监听失败,报错: " + err.Error(),
|
|
ReferOriginMsg: true,
|
|
FromMsg: msg,
|
|
}
|
|
}
|
|
return &model.Reply{
|
|
ReplyMsg: "关闭新债监听成功",
|
|
ReferOriginMsg: true,
|
|
FromMsg: msg,
|
|
}
|
|
}
|