Skip to content

Commit

Permalink
Merge branch 'main' into create-pull-request/patch
Browse files Browse the repository at this point in the history
  • Loading branch information
MoeMagicMango authored Aug 19, 2023
2 parents 9fcd93a + d6588d2 commit abdd012
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 150 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3
github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4
github.com/MoYoez/Arcaea_auaAPI v0.0.0-20230403123758-2b7aba395359
github.com/disintegration/imaging v1.6.2
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565
github.com/glebarez/sqlite v1.6.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 h1:mCVrTvS2LMN
github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g=
github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4 h1:OrqldcPSJWnPxZtmkOd9HJmFFD3rl0Qrob89rHHpoXw=
github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4/go.mod h1:jUmX4WBgGRcfjGeIobmVao10AHmXtL3gT00qLbx3/yo=
github.com/MoYoez/Arcaea_auaAPI v0.0.0-20230403123758-2b7aba395359 h1:MwTh5qrVnUH1AMenPSRW9AQ11P4JRspQTI3/P0IFQj8=
github.com/MoYoez/Arcaea_auaAPI v0.0.0-20230403123758-2b7aba395359/go.mod h1:0zfIgZzZ5QnD2a+iHN/qbRlHHAueSHxriekkLokR3Fo=
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

_ "github.com/FloatTech/ZeroBot-Plugin-Playground/example/JiangRed"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/example/xiaoguofan"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/arcaea"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/asoularticle"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/chatgpt"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/chinesebqb"
Expand All @@ -43,6 +42,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/qqclean"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/recall" // SGK2401
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/rsshub"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/slash"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/subweibo"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/tgyj"
_ "github.com/FloatTech/ZeroBot-Plugin-Playground/plugin/vote"
Expand Down
146 changes: 0 additions & 146 deletions plugin/arcaea/main.go

This file was deleted.

57 changes: 57 additions & 0 deletions plugin/slash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## Slash Bot

A Bot Running On Telegram, However it was modified for Zerobot-plugin.

### Usage

* This plugin will cause conflict with other plugins, so please make sure that the prio is the loweset.

* 此功能需要管理员 /启用slash 才可使用

Regex Patterns,没有特定需求,**会和其他以 / 为初始头的Bot冲突**:

以下是示例:

> /rua
=> {Username}rua了他自己~

Ep: MoeMagicMango💫 rua了他自己~

> @Lucy | HafuKo💫 /rua
* 因为正则影响相关,如果@Lucy的话可能会被Matcher的阻断器卡住不会回应

> => {username} rua了 {targetName}
Ep:

=> MoeMagicMango💫 rua了 Lucy | HafuKo💫

> /rua @Lucy | Hafuko 💫
Ep:

=> MoeMagicMango💫 rua了 Lucy | HafuKo💫

> @Lucy | HafuKo💫 /rua 捏捏
Ep:

=> MoeMagicMango💫 rua了 Lucy | HafuKo💫捏捏

>/rua 捏捏 @Lucy | HafuKo💫
Ep:

=> MoeMagicMango💫 rua了 Lucy | HafuKo💫捏捏

#### 回复环境下 (在回复某个人的对话,记得去掉qq自带的@)

> /rua
=> {username} rua了 {targetName}

Ep:

=> MoeMagicMango💫 rua了 Lucy | HafuKo💫
71 changes: 71 additions & 0 deletions plugin/slash/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Package slash https://github.com/Rongronggg9/SlashBot
package slash

import (
"strconv"
"strings"

ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

var (
// so noisy and try not to use this.
engine = control.Register("slash", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Help: "slash Plugin, Origin from https://github.com/Rongronggg9/SlashBot\n",
})
)

func init() {
engine.OnRegex(`^/(.*)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
getPatternInfo := ctx.State["regex_matched"].([]string)[1]
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(ctx.CardOrNickName(ctx.Event.UserID)+getPatternInfo+"了他自己~"))
})
/*
Params:
/rua [CQ:at,qq=123123] || match1 = /rua | match2 = cq... | match3 = id
match4 match 5 match 6
*/
engine.OnRegex(`^(/.*)(\[CQ:at,qq=(.*)\])|^(\[CQ:at,qq=(.*)\])\s(/.*)`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
getMatchedQID := ctx.State["regex_matched"].([]string)[3]
var getMatchedInfo string
if getMatchedQID == "" {
getMatchedQID = ctx.State["regex_matched"].([]string)[5]
getMatchedInfo = ctx.State["regex_matched"].([]string)[6]
} else {
getMatchedInfo = ctx.State["regex_matched"].([]string)[1]
}
// use matchedinfo
qidToInt64, _ := strconv.ParseInt(getMatchedQID, 10, 64)
getUserInfo := ctx.CardOrNickName(qidToInt64)
getPersentUserinfo := ctx.CardOrNickName(ctx.Event.UserID)
// split info
modifyInfo := strings.ReplaceAll(getMatchedInfo, "/", "")
splitInfo := strings.Split(modifyInfo, " ")
if len(splitInfo) == 2 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(getPersentUserinfo+" "+splitInfo[0]+"了"+getUserInfo+splitInfo[1]))
} else {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(getPersentUserinfo+" "+splitInfo[0]+"了"+getUserInfo))
}
})

engine.OnRegex(`^(\[CQ:reply,id=(.*)\])\s/(.*)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
getPatternUserMessageID := ctx.State["regex_matched"].([]string)[2]
getPatternInfo := ctx.State["regex_matched"].([]string)[3]
getSplit := strings.Split(getPatternInfo, " ")
rsp := ctx.CallAction("get_msg", zero.Params{
"message_id": getPatternUserMessageID,
}).Data.String()
sender := gjson.Get(rsp, "sender.user_id").Int()
if len(getSplit) == 2 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(ctx.CardOrNickName(ctx.Event.UserID)+" "+getSplit[0]+"了 "+ctx.CardOrNickName(sender)+" "+getSplit[1]))
} else {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(ctx.CardOrNickName(ctx.Event.UserID)+" "+getPatternInfo+"了 "+ctx.CardOrNickName(sender)))
}
})

}

0 comments on commit abdd012

Please sign in to comment.