mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 15:20:22 +00:00
world: 一大波优化与功能更新
- fix #441 - 优化wsserver解析 - 完善 ctx.this 相关函数 - 自动已读: Config 的 MarkMessage
This commit is contained in:
@@ -70,7 +70,7 @@ func init() {
|
||||
if err := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager.DoBlock(uid); err == nil {
|
||||
t := time.Now().Unix()
|
||||
cache.Set(uid, struct{}{})
|
||||
ctx.SetGroupBan(gid, uid, int64(bandur.Minutes()))
|
||||
ctx.SetThisGroupBan(uid, int64(bandur.Minutes()))
|
||||
ctx.SendChain(message.Text("检测到违禁词, 已封禁/屏蔽", bandur))
|
||||
db.Lock()
|
||||
defer db.Unlock()
|
||||
|
||||
@@ -68,7 +68,7 @@ func (bdres *baiduRes) audit(ctx *zero.Ctx, configpath string) {
|
||||
bantime = group.BANTime * 60
|
||||
}
|
||||
// 执行禁言
|
||||
ctx.SetGroupBan(ctx.Event.GroupID, ctx.Event.UserID, bantime)
|
||||
ctx.SetThisGroupBan(ctx.Event.UserID, bantime)
|
||||
}
|
||||
// 查看是否开启撤回提示
|
||||
if group.DMRemind {
|
||||
|
||||
@@ -39,8 +39,8 @@ func init() {
|
||||
userid := ctx.Event.UserID
|
||||
username := ctx.CardOrNickName(userid)
|
||||
data := (storage)(c.GetData(-su))
|
||||
groupname := ctx.GetThisGroupInfo(true).Name
|
||||
groupid := ctx.Event.GroupID
|
||||
groupname := ctx.GetGroupInfo(groupid, true).Name
|
||||
logrus.Info("[event]收到来自[", username, "](", userid, ")的群聊邀请,群:[", groupname, "](", groupid, ")")
|
||||
if data.isinviteon() || (!data.ismasteroff() && zero.SuperUserPermission(ctx)) {
|
||||
ctx.SetGroupAddRequest(ctx.Event.Flag, "invite", true, "")
|
||||
|
||||
@@ -527,7 +527,7 @@ func getlist(pathOfMusic string) (list []listinfo, err error) {
|
||||
|
||||
// 遍历群文件
|
||||
func getFileURLbyFileName(ctx *zero.Ctx, fileName string) (fileSearchName, fileURL string) {
|
||||
filesOfGroup := ctx.GetThisGroupRootFiles(ctx.Event.GroupID)
|
||||
filesOfGroup := ctx.GetThisGroupRootFiles()
|
||||
files := filesOfGroup.Get("files").Array()
|
||||
folders := filesOfGroup.Get("folders").Array()
|
||||
// 遍历当前目录的文件名
|
||||
|
||||
@@ -95,13 +95,11 @@ func init() { // 插件主体
|
||||
// 升为管理
|
||||
engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupAdmin(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupAdmin(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq
|
||||
true,
|
||||
)
|
||||
nickname := ctx.GetGroupMemberInfo( // 被升为管理的人的昵称
|
||||
ctx.Event.GroupID,
|
||||
nickname := ctx.GetThisGroupMemberInfo( // 被升为管理的人的昵称
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq
|
||||
false,
|
||||
).Get("nickname").Str
|
||||
@@ -110,13 +108,11 @@ func init() { // 插件主体
|
||||
// 取消管理
|
||||
engine.OnRegex(`^取消管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupAdmin(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupAdmin(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq
|
||||
false,
|
||||
)
|
||||
nickname := ctx.GetGroupMemberInfo( // 被取消管理的人的昵称
|
||||
ctx.Event.GroupID,
|
||||
nickname := ctx.GetThisGroupMemberInfo( // 被取消管理的人的昵称
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq
|
||||
false,
|
||||
).Get("nickname").Str
|
||||
@@ -125,13 +121,11 @@ func init() { // 插件主体
|
||||
// 踢出群聊
|
||||
engine.OnRegex(`^踢出群聊.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupKick(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupKick(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq
|
||||
false,
|
||||
)
|
||||
nickname := ctx.GetGroupMemberInfo( // 被踢出群聊的人的昵称
|
||||
ctx.Event.GroupID,
|
||||
nickname := ctx.GetThisGroupMemberInfo( // 被踢出群聊的人的昵称
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq
|
||||
false,
|
||||
).Get("nickname").Str
|
||||
@@ -148,19 +142,13 @@ func init() { // 插件主体
|
||||
// 开启全体禁言
|
||||
engine.OnRegex(`^开启全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupWholeBan(
|
||||
ctx.Event.GroupID,
|
||||
true,
|
||||
)
|
||||
ctx.SetThisGroupWholeBan(true)
|
||||
ctx.SendChain(message.Text("全员自闭开始~"))
|
||||
})
|
||||
// 解除全员禁言
|
||||
engine.OnRegex(`^解除全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupWholeBan(
|
||||
ctx.Event.GroupID,
|
||||
false,
|
||||
)
|
||||
ctx.SetThisGroupWholeBan(false)
|
||||
ctx.SendChain(message.Text("全员自闭结束~"))
|
||||
})
|
||||
// 禁言
|
||||
@@ -180,8 +168,7 @@ func init() { // 插件主体
|
||||
if duration >= 43200 {
|
||||
duration = 43199 // qq禁言最大时长为一个月
|
||||
}
|
||||
ctx.SetGroupBan(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupBan(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要禁言的人的qq
|
||||
duration*60, // 要禁言的时间(分钟)
|
||||
)
|
||||
@@ -190,8 +177,7 @@ func init() { // 插件主体
|
||||
// 解除禁言
|
||||
engine.OnRegex(`^解除禁言.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SetGroupBan(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupBan(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要解除禁言的人的qq
|
||||
0,
|
||||
)
|
||||
@@ -214,8 +200,7 @@ func init() { // 插件主体
|
||||
if duration >= 43200 {
|
||||
duration = 43199 // qq禁言最大时长为一个月
|
||||
}
|
||||
ctx.SetGroupBan(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupBan(
|
||||
ctx.Event.UserID,
|
||||
duration*60, // 要自闭的时间(分钟)
|
||||
)
|
||||
@@ -228,8 +213,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("名字太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupCard(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupCard(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群名片的人
|
||||
ctx.State["regex_matched"].([]string)[2], // 修改成的群名片
|
||||
)
|
||||
@@ -246,8 +230,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("头衔太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupSpecialTitle(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupSpecialTitle(
|
||||
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群头衔的人
|
||||
sptitle, // 修改成的群头衔
|
||||
)
|
||||
@@ -264,8 +247,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("头衔太长啦!"))
|
||||
return
|
||||
}
|
||||
ctx.SetGroupSpecialTitle(
|
||||
ctx.Event.GroupID,
|
||||
ctx.SetThisGroupSpecialTitle(
|
||||
ctx.Event.UserID, // 被修改群头衔的人
|
||||
sptitle, // 修改成的群头衔
|
||||
)
|
||||
@@ -445,7 +427,7 @@ func init() { // 插件主体
|
||||
case <-time.After(time.Minute):
|
||||
cancel()
|
||||
ctx.SendChain(message.Text("拜拜啦~"))
|
||||
ctx.SetGroupKick(ctx.Event.GroupID, uid, false)
|
||||
ctx.SetThisGroupKick(uid, false)
|
||||
case <-recv:
|
||||
cancel()
|
||||
ctx.SendChain(message.Text("答对啦~"))
|
||||
@@ -594,7 +576,7 @@ func init() { // 插件主体
|
||||
if ok {
|
||||
ctx.SetGroupAddRequest(ctx.Event.Flag, "add", true, "")
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SetGroupCard(ctx.Event.GroupID, ctx.Event.UserID, ghun)
|
||||
ctx.SetThisGroupCard(ctx.Event.UserID, ghun)
|
||||
} else {
|
||||
ctx.SetGroupAddRequest(ctx.Event.Flag, "add", false, reason)
|
||||
}
|
||||
@@ -618,7 +600,7 @@ func init() { // 插件主体
|
||||
}
|
||||
})
|
||||
engine.OnCommand("精华列表", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
list := ctx.GetGroupEssenceMessageList(ctx.Event.GroupID).Array()
|
||||
list := ctx.GetThisGroupEssenceMessageList().Array()
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("本群精华列表:"))}
|
||||
n := len(list)
|
||||
if n > 30 {
|
||||
@@ -675,7 +657,7 @@ func welcometocq(ctx *zero.Ctx, welcome string) string {
|
||||
at := "[CQ:at,qq=" + uid + "]" // at用户
|
||||
avatar := "[CQ:image,file=" + "http://q4.qlogo.cn/g?b=qq&nk=" + uid + "&s=640]" // 用户头像
|
||||
gid := strconv.FormatInt(ctx.Event.GroupID, 10) // 群id
|
||||
groupname := ctx.GetGroupInfo(ctx.Event.GroupID, true).Name // 群名
|
||||
groupname := ctx.GetThisGroupInfo(true).Name // 群名
|
||||
cqstring := strings.ReplaceAll(welcome, "{at}", at)
|
||||
cqstring = strings.ReplaceAll(cqstring, "{nickname}", nickname)
|
||||
cqstring = strings.ReplaceAll(cqstring, "{avatar}", avatar)
|
||||
|
||||
@@ -44,7 +44,7 @@ func init() {
|
||||
var secondname string
|
||||
if len(ctx.Event.Message) > 1 && ctx.Event.Message[1].Type == "at" {
|
||||
qq, _ := strconv.ParseInt(ctx.Event.Message[1].Data["qq"], 10, 64)
|
||||
secondname = ctx.GetGroupMemberInfo(ctx.Event.GroupID, qq, false).Get("nickname").Str
|
||||
secondname = ctx.GetThisGroupMemberInfo(qq, false).Get("nickname").Str
|
||||
}
|
||||
name = ctx.Event.Sender.NickName
|
||||
var text string
|
||||
|
||||
Reference in New Issue
Block a user