添加文本处理功能
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-09 23:39:13 +08:00
parent 36a564547c
commit 420630e35c
5 changed files with 553 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import random
from konabot.plugins.handle_text.base import TextHandleResult, TextHandler, TextHandlerEnvironment
class THShuffle(TextHandler):
name: str = "shuffle"
keywords: list = ["打乱"]
async def handle(self, env: TextHandlerEnvironment, istream: str | None, args: list[str]) -> TextHandleResult:
if istream is not None:
w = istream
elif len(args) == 0:
return TextHandleResult(1, "使用方法:打乱 <待打乱的文本>,或者使用管道符传入待打乱的文本")
else:
w = args[0]
args = args[1:]
w = [*w]
random.shuffle(w)
return TextHandleResult(0, ''.join(w))