-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into create-pull-request/patch
- Loading branch information
Showing
6 changed files
with
129 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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💫 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) | ||
} | ||
}) | ||
|
||
} |