You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1KB

  1. # encoding:utf-8
  2. from bridge.context import ContextType
  3. from bridge.reply import Reply, ReplyType
  4. import plugins
  5. from plugins import *
  6. from common.log import logger
  7. @plugins.register(name="Finish", desire_priority=-999, hidden=True, desc="A plugin that check unknow command", version="1.0", author="js00000")
  8. class Finish(Plugin):
  9. def __init__(self):
  10. super().__init__()
  11. self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context
  12. logger.info("[Finish] inited")
  13. def on_handle_context(self, e_context: EventContext):
  14. if e_context['context'].type != ContextType.TEXT:
  15. return
  16. content = e_context['context'].content
  17. logger.debug("[Finish] on_handle_context. content: %s" % content)
  18. if content.startswith("#"):
  19. reply = Reply()
  20. reply.type = ReplyType.TEXT
  21. reply.content = "未知指令\n查看指令列表请输入#help\n"
  22. e_context['reply'] = reply
  23. e_context.action = EventAction.BREAK_PASS # 事件结束,并跳过处理context的默认逻辑
  24. def get_help_text(self, **kwargs):
  25. return ""