|
-
-
- import plugins
- from plugins import *
- from common.log import logger
-
-
- @plugins.register(name="Hello", desc="A simple plugin that says hello", version="0.1", author="lanvent")
- class Hello(Plugin):
- def __init__(self):
- super().__init__()
- self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context
- logger.info("[Hello] inited")
-
- def on_handle_context(self, e_context: EventContext):
-
- if e_context['context']['type'] != "TEXT":
- return
-
- content = e_context['context']['content']
- logger.debug("[Hello] on_handle_context. content: %s" % content)
- if content == "Hello":
- reply = {}
- reply['type'] = "TEXT"
- msg = e_context['context']['msg']
- if e_context['context']['isgroup']:
- reply['content'] = "Hello, " + msg['ActualNickName'] + " from " + msg['User'].get('NickName', "Group")
- else:
- reply['content'] = "Hello, " + msg['User'].get('NickName', "My friend")
- e_context['reply'] = reply
- e_context.action = EventAction.BREAK_PASS
-
- if content == "Hi":
- reply={}
- reply['type'] = "TEXT"
- reply['content'] = "Hi"
- e_context['reply'] = reply
- e_context.action = EventAction.BREAK
-
- if content == "End":
-
- e_context['context']['type'] = "IMAGE_CREATE"
- content = "The World"
- e_context.action = EventAction.CONTINUE
|