diff --git a/GuDice/__init__.py b/GuDice/__init__.py index 6ce431c..714ad6d 100644 --- a/GuDice/__init__.py +++ b/GuDice/__init__.py @@ -1,14 +1,17 @@ # -*- encoding:utf-8 -*- from GuDice.api import API +from GuDice.bot import Bot from GuDice.classify import Classify from GuDice.dice import Dice from GuDice.event import Event -from GuDice.plugin import PluginManager +from GuDice.plugin import PluginManager, Plugin + __all__ = [ "API", "Classify", "Dice", "Event", - "PluginManager" + "PluginManager", + "Plugin" ] diff --git a/GuDice/event.py b/GuDice/event.py index c6ef006..43dbcab 100644 --- a/GuDice/event.py +++ b/GuDice/event.py @@ -1,19 +1,12 @@ # -*- encoding:utf-8 -*- class Event: - - def private_message(self, event, bot): + def private_message(self, data, bot): pass - def group_message(self, event, bot): + def group_message(self, data, bot): pass - def main(self, event, bot): - if event['type'] == "private_message": - self.private_message(event['data'], bot) - elif event['type'] == "group_message": - self.group_message(event['data'], bot) - class MessageData: user_id: int diff --git a/GuDice/plugin.py b/GuDice/plugin.py index 95220dd..8a2d563 100644 --- a/GuDice/plugin.py +++ b/GuDice/plugin.py @@ -3,6 +3,7 @@ import sys import importlib from os.path import abspath, join, exists, dirname +from GuDice import Event, API file_dir = dirname(abspath(__file__)) @@ -35,6 +36,18 @@ def plugin_test(self): pass +# 插件基类 +class Plugin(Event): + def init(self): + pass + + def main(self, event, bot): + if event['type'] == "private_message": + self.private_message(event['data'], bot) + elif event['type'] == "group_message": + self.group_message(event['data'], bot) + + if __name__ == "__main__": Manager = PluginManager() Manager.plugin_registered()