MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / welcometocq

Function welcometocq

plugin/manager/manager.go:715–729  ·  view source on GitHub ↗

传入 ctx 和 welcome格式string 返回cq格式string 使用方法:welcometocq(ctx,w.Msg)

(ctx *zero.Ctx, welcome string)

Source from the content-addressed store, hash-verified

713
714// 传入 ctx 和 welcome格式string 返回cq格式string 使用方法:welcometocq(ctx,w.Msg)
715func welcometocq(ctx *zero.Ctx, welcome string) string {
716 uid := strconv.FormatInt(ctx.Event.UserID, 10) // 用户id
717 nickname := ctx.CardOrNickName(ctx.Event.UserID) // 用户昵称
718 at := "[CQ:at,qq=" + uid + "]" // at用户
719 avatar := "[CQ:image,file=" + "https://q4.qlogo.cn/g?b=qq&nk=" + uid + "&s=640]" // 用户头像
720 gid := strconv.FormatInt(ctx.Event.GroupID, 10) // 群id
721 groupname := ctx.GetThisGroupInfo(true).Name // 群名
722 cqstring := strings.ReplaceAll(welcome, "{at}", at)
723 cqstring = strings.ReplaceAll(cqstring, "{nickname}", nickname)
724 cqstring = strings.ReplaceAll(cqstring, "{avatar}", avatar)
725 cqstring = strings.ReplaceAll(cqstring, "{uid}", uid)
726 cqstring = strings.ReplaceAll(cqstring, "{gid}", gid)
727 cqstring = strings.ReplaceAll(cqstring, "{groupname}", groupname)
728 return cqstring
729}

Callers 1

initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected