Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Jan 16, 2023
0 parents commit 99097bc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Empty file added __init__.py
Empty file.
43 changes: 43 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from pkg.plugin.models import *
from pkg.plugin.host import EventContext


# 注册插件
@register(name="hello", description="hello world", version="0.1", author="RockChinQ")
class HelloPlugin(Plugin):

def __init__(self):
pass

# 当收到个人消息时触发
@on(PersonNormalMessageReceived)
def person_normal_message_received(self, event: EventContext, **kwargs):
msg = kwargs['text_message']
if msg == "hello": # 如果消息为hello

# 输出调试信息
logging.debug("hello, {}".format(kwargs['sender_id']))

# 回复消息 "hello, <发送者id>!"
event.add_return("reply", ["hello, {}!".format(kwargs['sender_id'])])

# 阻止该事件默认行为(向接口获取回复)
event.prevent_default()

# 当收到群消息时触发
@on(GroupNormalMessageReceived)
def group_normal_message_received(self, event: EventContext, **kwargs):
msg = kwargs['text_message']
if msg == "hello": # 如果消息为hello

# 输出调试信息
logging.debug("hello, {}".format(kwargs['sender_id']))

# 回复消息 "hello, everyone!"
event.add_return("reply", ["hello, everyone!"])

# 阻止该事件默认行为(向接口获取回复)
event.prevent_default()

def __del__(self):
pass

0 comments on commit 99097bc

Please sign in to comment.