mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-22 04:16:07 +00:00
debug: ExamplePlugin
This commit is contained in:
+14
-13
@@ -1,22 +1,23 @@
|
|||||||
from pkg.plugin.models import Plugin, PersonMessage, GroupMessage, register
|
import pkg.plugin.models as models
|
||||||
from pkg.plugin.host import EventContext
|
from pkg.plugin.host import *
|
||||||
|
|
||||||
|
|
||||||
@register(name="ExamplePlugin", description="用于展示QChatGPT插件支持功能的插件", version="0.0.1", author="RockChinQ")
|
@models.register(name="ExamplePlugin", description="用于展示QChatGPT插件支持功能的插件", version="0.0.1", author="RockChinQ")
|
||||||
class ExamplePlugin(Plugin):
|
class ExamplePlugin(models.Plugin):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
#
|
||||||
|
# @models.on(models.PersonMessageReceived)
|
||||||
|
# def on_person_message_received(self, host: PluginHost, event: EventContext, **kwargs):
|
||||||
|
# """收到个人消息时触发"""
|
||||||
|
# host.send_person_message(kwargs['sender_id'], "你好,我是一个插件")
|
||||||
|
# event.prevent_default()
|
||||||
|
|
||||||
@Plugin.on(PersonMessage)
|
@models.on(models.KeySwitched)
|
||||||
def person_message(self, event: EventContext, **kwargs):
|
def on_key_switched(self, host: PluginHost, event: EventContext, **kwargs):
|
||||||
print("person_message", kwargs)
|
"""按键事件"""
|
||||||
event.prevent_default()
|
host.send_person_message(1010553892, "按键事件")
|
||||||
|
|
||||||
@Plugin.on(GroupMessage)
|
|
||||||
def group_message(self, **kwargs):
|
|
||||||
print("group_message", kwargs)
|
|
||||||
self.host.notify_admin("group_message")
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user