diff --git a/.gitignore b/.gitignore index 6cc16f7a61267cbca3e4a528013c696d08630353..d98fd796231449696e5c60b07284d7eb30f32c86 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ venv/ __pycache__/* config.json db.sqlite3 +Project-yui.iml +project-yui.iml projectyui.log plugins/chatbot_simple plugins/eshe_test \ No newline at end of file diff --git a/Yui.py b/Yui.py index bb5d8e58ba690ff88f0a0f257dcbf4eecaf805fb..7abff59cde88f510243f7564289a36c305fdb2e9 100644 --- a/Yui.py +++ b/Yui.py @@ -1,25 +1,24 @@ +import asyncio +import os +import shlex +import sys import time - -from common.Store import store -import common.VK.Convert as Converter -from common.VK.VKWrappers import make_upload_docs, make_upload_photo, make_reply -import common.Logger as Logger - - import traceback from objdict import ObjDict -import os -import sys -import asyncio -import shlex + +import common.Logger as Logger +import common.VK.Convert as Converter +from common.Store import store +from common.VK.VKWrappers import make_upload_docs, make_upload_photo, make_reply from utils import load_config + class Yui: def __init__(self): self.store = store - self.ver = "0.1.5 beta" + self.ver = "0.1.6 beta" Logger.Ylog(f"> Привет, я Yui! Бот для социальной сети ВК.\n> На данный момент моя версия: {self.ver}") load_config() @@ -33,12 +32,26 @@ class Yui: sys.path.insert(0, "plugins") for file in plugin_folder_files: + if file.startswith("__"): + continue + try: + plugin_subfolder = os.listdir(f"plugins/{file}") + sys.path.insert(0, f"plugins/{file}") + for subfiles in plugin_subfolder: + if subfiles.endswith(".py"): + try: + a = __import__(os.path.splitext(subfiles)[0], None, None, ['']) + Logger.Slog(f"Юи загрузила плагин {subfiles}") + except Exception as err: + traceback.print_exc() + except Exception: + pass + if file.endswith(".py"): try: - a = __import__(os.path.splitext(file)[0], None, None, ['']) + a = __import__(os.path.splitext(file)[0], None, None, ['']) Logger.Slog(f"Юи загрузила плагин {file}") except Exception as err: - print(err) traceback.print_exc() return True @@ -52,8 +65,6 @@ class Yui: command = None for (k, v) in store.handlers.items(): - print(k) - print(updated_message.text) if updated_message.text.startswith(k): command = k break diff --git a/common/Plugin.py b/common/Plugin.py index 678d69ab8523c7c7e86e3a253cc52ddd47412177..da64ae55f3eb8a6bf67c2c60ff4646a8d963b1e2 100644 --- a/common/Plugin.py +++ b/common/Plugin.py @@ -42,7 +42,6 @@ class YPlugin(object): def on_command(self, command): def wrapper(func): - print(command) if type(command) in [list,tuple]: for comm in command: self.store.add_handler(comm, func) diff --git a/common/VK/Convert.py b/common/VK/Convert.py index e4a3f46fe1ea8238dbd8283fc9ef6bf486d9cf51..3e797d755d00afe3156ef3640902f816fe57edce 100644 --- a/common/VK/Convert.py +++ b/common/VK/Convert.py @@ -93,8 +93,6 @@ async def convert_to_message(update): Message.from_id = obj.get("from_id") Message.peer_id = obj.get("peer_id") - print(obj.get("from_id")) - print(obj.get("peer_id")) if int(obj.get("from_id")) != int(obj.get("peer_id")): Message.is_multichat = True Message.chat_id = obj.get("peer_id") - chat_const diff --git a/common/VK/VKLongPoll.py b/common/VK/VKLongPoll.py index 21f9ec1edeb8d894b3d4e21a367f5bfe9e746b61..dd7639330c61a40a2f02a060c4629c2c4548b8fa 100644 --- a/common/VK/VKLongPoll.py +++ b/common/VK/VKLongPoll.py @@ -43,9 +43,12 @@ class VKLongPoll: raw_response = json.loads(raw_respose_text) if 'error' in raw_response: error = ObjDict() + error.error = True + error.response = raw_response['error'] return error sucs = ObjDict() + sucs.error = False sucs.response = raw_response['response'] return sucs diff --git a/requirements.txt b/requirements.txt index cb751b8747556de61519cfe41cdf00aeaafca315..c604085089e2e83a9847fbf0af96752fcd719706 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,12 +2,6 @@ aiohttp asyncio requests objdict - - -chatterbot - - - peewee_async psycopg2 aiopg