diff --git a/tests/plugin_examples/cmdcn/cmdcn.py b/tests/plugin_examples/cmdcn/cmdcn.py index e92519d3..9692f1a5 100644 --- a/tests/plugin_examples/cmdcn/cmdcn.py +++ b/tests/plugin_examples/cmdcn/cmdcn.py @@ -1,6 +1,11 @@ from pkg.plugin.models import * from pkg.plugin.host import EventContext +""" +基本命令的中文形式支持 +""" + + __mapping__ = { "帮助": "help", "重置": "reset", diff --git a/tests/plugin_examples/hello_plugin/main.py b/tests/plugin_examples/hello_plugin/main.py index edcd8ed5..99f5849c 100644 --- a/tests/plugin_examples/hello_plugin/main.py +++ b/tests/plugin_examples/hello_plugin/main.py @@ -1,6 +1,10 @@ from pkg.plugin.models import * from pkg.plugin.host import EventContext +""" +在收到私聊或群聊消息"hello"时,回复"hello, <发送者id>!"或"hello, everyone!" +""" + # 注册插件 @register(name="Hello", description="hello world", version="0.1", author="RockChinQ") diff --git a/tests/plugin_examples/urlikethisijustsix/__init__.py b/tests/plugin_examples/urlikethisijustsix/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/plugin_examples/urlikethisijustsix/urlt.py b/tests/plugin_examples/urlikethisijustsix/urlt.py new file mode 100644 index 00000000..7db16ff8 --- /dev/null +++ b/tests/plugin_examples/urlikethisijustsix/urlt.py @@ -0,0 +1,43 @@ +import random + +from mirai import Plain + +from pkg.plugin.models import * +from pkg.plugin.host import EventContext + +""" +私聊或群聊消息为以下列出的一些冒犯性词语时,自动回复__random_reply__中的一句话 +""" + + +__words__ = ['sb', "傻逼", "dinner", "操你妈", "cnm", "fuck you", "fuckyou", + "f*ck you", "弱智", "若智", "答辩", "依托答辩", "低能儿", "nt", "脑瘫", "闹谈", "老坛"] + +__random_reply__ = ['好好好', "啊对对对", "好好好好", "你说得对", "谢谢夸奖"] + + +@register(name="啊对对对", description="你都这样了,我就顺从你吧", version="0.1", author="RockChinQ") +class AdddPlugin(Plugin): + + def __init__(self): + pass + + # 绑定私聊消息事件和群消息事件 + @on(PersonNormalMessageReceived) + @on(GroupNormalMessageReceived) + def normal_message_received(self, event: EventContext, **kwargs): + msg = kwargs['text_message'] + + # 如果消息中包含关键词 + if msg in __words__: + # 随机一个回复 + idx = random.randint(0, len(__random_reply__)-1) + + # 返回回复的消息 + event.add_return("reply", [Plain(__random_reply__[idx])]) + + # 阻止向接口获取回复 + event.prevent_default() + + def __del__(self): + pass