From 2929c5f58fb10139bdd8e5f53475745f43960eee Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 11 Sep 2023 18:52:35 +0300 Subject: [PATCH] update --- {src => api}/webhook.py | 24 +++++++++---------- {src => bot}/api.py | 2 +- {src => bot}/config.py | 0 {src => bot}/handlers/callback_unlink.py | 8 +++---- {src => bot}/handlers/callback_vouch.py | 4 ++-- {src => bot}/handlers/command_ask.py | 6 ++--- {src => bot}/handlers/command_graph.py | 6 ++--- {src => bot}/handlers/command_my.py | 6 ++--- {src => bot}/handlers/handle_default.py | 7 +++--- {src => bot}/handlers/handle_feedback.py | 10 ++++---- {src => bot}/handlers/handle_join_request.py | 6 ++--- .../handlers/handle_members_change.py | 8 +++---- {src => bot}/handlers/handle_startup.py | 6 ++--- {src => bot}/handlers/send_button.py | 6 ++--- {src => bot}/storage/__init__.py | 4 ++-- {src => bot}/storage/profile.py | 0 {src => bot}/utils/graph.py | 0 {src => bot}/utils/mention.py | 0 vercel.json | 4 ++-- 19 files changed, 53 insertions(+), 54 deletions(-) rename {src => api}/webhook.py (78%) rename {src => bot}/api.py (99%) rename {src => bot}/config.py (100%) rename {src => bot}/handlers/callback_unlink.py (90%) rename {src => bot}/handlers/callback_vouch.py (95%) rename {src => bot}/handlers/command_ask.py (77%) rename {src => bot}/handlers/command_graph.py (67%) rename {src => bot}/handlers/command_my.py (91%) rename {src => bot}/handlers/handle_default.py (89%) rename {src => bot}/handlers/handle_feedback.py (84%) rename {src => bot}/handlers/handle_join_request.py (75%) rename {src => bot}/handlers/handle_members_change.py (89%) rename {src => bot}/handlers/handle_startup.py (88%) rename {src => bot}/handlers/send_button.py (92%) rename {src => bot}/storage/__init__.py (93%) rename {src => bot}/storage/profile.py (100%) rename {src => bot}/utils/graph.py (100%) rename {src => bot}/utils/mention.py (100%) diff --git a/src/webhook.py b/api/webhook.py similarity index 78% rename from src/webhook.py rename to api/webhook.py index b34cd61..32cb76d 100644 --- a/src/webhook.py +++ b/api/webhook.py @@ -1,17 +1,17 @@ from sanic import Sanic from sanic.response import text -from handlers.handle_feedback import handle_feedback, handle_answer -from handlers.handle_members_change import handle_join, handle_left -from handlers.handle_join_request import handle_join_request -from handlers.handle_default import handle_default -from handlers.command_my import handle_command_my -from handlers.command_graph import handle_command_graph -from handlers.command_ask import handle_command_ask -from handlers.callback_vouch import handle_button -from handlers.callback_unlink import handle_unlink -from handlers.handle_startup import handle_startup -from api import register_webhook, send_message -from config import FEEDBACK_CHAT_ID +from bot.handlers.handle_feedback import handle_feedback, handle_answer +from bot.handlers.handle_members_change import handle_join, handle_left +from bot.handlers.handle_join_request import handle_join_request +from bot.handlers.handle_default import handle_default +from bot.handlers.command_my import handle_command_my +from bot.handlers.command_graph import handle_command_graph +from bot.handlers.command_ask import handle_command_ask +from bot.handlers.callback_vouch import handle_button +from bot.handlers.callback_unlink import handle_unlink +from bot.handlers.handle_startup import handle_startup +from bot.api import register_webhook, send_message +from bot.config import FEEDBACK_CHAT_ID app = Sanic(name="welcomecenter") app.config.REGISTERED = False diff --git a/src/api.py b/bot/api.py similarity index 99% rename from src/api.py rename to bot/api.py index 1cb1691..4097017 100644 --- a/src/api.py +++ b/bot/api.py @@ -2,7 +2,7 @@ import requests import aiohttp import json import os -from config import BOT_TOKEN, WEBHOOK +from bot.config import BOT_TOKEN, WEBHOOK apiBase = f"https://api.telegram.org/bot{TOKEN}/" diff --git a/src/config.py b/bot/config.py similarity index 100% rename from src/config.py rename to bot/config.py diff --git a/src/handlers/callback_unlink.py b/bot/handlers/callback_unlink.py similarity index 90% rename from src/handlers/callback_unlink.py rename to bot/handlers/callback_unlink.py index 3fb6180..8264ad6 100644 --- a/src/handlers/callback_unlink.py +++ b/bot/handlers/callback_unlink.py @@ -1,7 +1,7 @@ -from api import send_message, delete_message, kick_member -from handlers.command_my import handle_command_my -from utils.mention import userdata_extract -from storage import Profile +from bot.api import send_message, delete_message, kick_member +from bot.handlers.command_my import handle_command_my +from bot.utils.mention import userdata_extract +from bot.storage import Profile # remove link of callback sender # from member vouched before diff --git a/src/handlers/callback_vouch.py b/bot/handlers/callback_vouch.py similarity index 95% rename from src/handlers/callback_vouch.py rename to bot/handlers/callback_vouch.py index 1bd8d41..cfcb0e9 100644 --- a/src/handlers/callback_vouch.py +++ b/bot/handlers/callback_vouch.py @@ -1,6 +1,6 @@ -from api import send_message, forward_message, delete_message, \ +from bot.api import send_message, forward_message, delete_message, \ approve_chat_join_request, edit_replymarkup, get_chat -from storage import Profile, storage +from bot.storage import Profile, storage def update_button(chat_id, member_id, text='❤️'): diff --git a/src/handlers/command_ask.py b/bot/handlers/command_ask.py similarity index 77% rename from src/handlers/command_ask.py rename to bot/handlers/command_ask.py index b4a2313..2f04113 100644 --- a/src/handlers/command_ask.py +++ b/bot/handlers/command_ask.py @@ -1,6 +1,6 @@ -from storage import Profile -from handlers.send_button import show_request_msg -from api import get_member +from bot.storage import Profile +from bot.handlers.send_button import show_request_msg +from bot.api import get_member def handle_command_ask(msg): print(f'handling request resend') diff --git a/src/handlers/command_graph.py b/bot/handlers/command_graph.py similarity index 67% rename from src/handlers/command_graph.py rename to bot/handlers/command_graph.py index dbbed9d..641f94f 100644 --- a/src/handlers/command_graph.py +++ b/bot/handlers/command_graph.py @@ -1,6 +1,6 @@ -from utils.graph import generate_chart -from api import send_document -from storage import storage, scan +from bot.utils.graph import generate_chart +from bot.api import send_document +from bot.storage import storage, scan import json diff --git a/src/handlers/command_my.py b/bot/handlers/command_my.py similarity index 91% rename from src/handlers/command_my.py rename to bot/handlers/command_my.py index a73caf2..5f80c2f 100644 --- a/src/handlers/command_my.py +++ b/bot/handlers/command_my.py @@ -1,6 +1,6 @@ -from storage import Profile, scan -from api import get_member, send_message, get_chat_administrators -from utils.mention import userdata_extract +from bot.storage import Profile, scan +from bot.api import get_member, send_message, get_chat_administrators +from bot.utils.mention import userdata_extract def construct_unlink_buttons(actor): diff --git a/src/handlers/handle_default.py b/bot/handlers/handle_default.py similarity index 89% rename from src/handlers/handle_default.py rename to bot/handlers/handle_default.py index 23fba1a..74ff7f2 100644 --- a/src/handlers/handle_default.py +++ b/bot/handlers/handle_default.py @@ -1,7 +1,6 @@ -from api import send_message, delete_message, get_chat_administrators -from storage import Profile -from handlers.send_button import show_request_msg -from storage import storage +from bot.api import send_message, delete_message, get_chat_administrators +from bot.storage import Profile, storage +from bot.handlers.send_button import show_request_msg def handle_default(msg): print(f'default handler for all messages') diff --git a/src/handlers/handle_feedback.py b/bot/handlers/handle_feedback.py similarity index 84% rename from src/handlers/handle_feedback.py rename to bot/handlers/handle_feedback.py index 631dc50..ab56c9c 100644 --- a/src/handlers/handle_feedback.py +++ b/bot/handlers/handle_feedback.py @@ -1,10 +1,10 @@ import json -from api import send_message, forward_message, delete_message, get_chat_administrators -from handlers.send_button import show_request_msg -from utils.mention import userdata_extract -from storage import storage, Profile -from config import FEEDBACK_CHAT_ID +from bot.api import send_message, forward_message, delete_message, get_chat_administrators +from bot.handlers.send_button import show_request_msg +from bot.utils.mention import userdata_extract +from bot.storage import storage, Profile +from bot.config import FEEDBACK_CHAT_ID def handle_feedback(msg): diff --git a/src/handlers/handle_join_request.py b/bot/handlers/handle_join_request.py similarity index 75% rename from src/handlers/handle_join_request.py rename to bot/handlers/handle_join_request.py index f7dda29..35df7dc 100644 --- a/src/handlers/handle_join_request.py +++ b/bot/handlers/handle_join_request.py @@ -1,6 +1,6 @@ -from api import approve_chat_join_request, delete_message -from handlers.send_button import show_request_msg -from storage import Profile, storage +from bot.api import approve_chat_join_request, delete_message +from bot.handlers.send_button import show_request_msg +from bot.storage import Profile, storage def handle_join_request(msg): diff --git a/src/handlers/handle_members_change.py b/bot/handlers/handle_members_change.py similarity index 89% rename from src/handlers/handle_members_change.py rename to bot/handlers/handle_members_change.py index 22ddff8..56fb575 100644 --- a/src/handlers/handle_members_change.py +++ b/bot/handlers/handle_members_change.py @@ -1,7 +1,7 @@ -from handlers.send_button import show_request_msg -from api import delete_message -from storage import Profile, storage -from config import FEEDBACK_CHAT_ID +from bot.handlers.send_button import show_request_msg +from bot.api import delete_message +from bot.storage import Profile, storage +from bot.config import FEEDBACK_CHAT_ID def handle_join(msg): chat_id = str(msg['chat']['id']) diff --git a/src/handlers/handle_startup.py b/bot/handlers/handle_startup.py similarity index 88% rename from src/handlers/handle_startup.py rename to bot/handlers/handle_startup.py index 24caf22..3d70df0 100644 --- a/src/handlers/handle_startup.py +++ b/bot/handlers/handle_startup.py @@ -1,7 +1,7 @@ from storage import scan, Profile -from api import approve_chat_join_request, kick_member -from handlers.callback_vouch import update_button -from utils.mention import userdata_extract +from bot.api import approve_chat_join_request, kick_member +from bot.handlers.callback_vouch import update_button +from bot.utils.mention import userdata_extract # устанавливает соответствие данных def handle_startup(): diff --git a/src/handlers/send_button.py b/bot/handlers/send_button.py similarity index 92% rename from src/handlers/send_button.py rename to bot/handlers/send_button.py index 2dfaf30..936049b 100644 --- a/src/handlers/send_button.py +++ b/bot/handlers/send_button.py @@ -1,6 +1,6 @@ -from api import send_message, send_photo, get_userphotos -from utils.mention import mention, userdata_extract -from storage import storage +from bot.api import send_message, send_photo, get_userphotos +from bot.utils.mention import mention, userdata_extract +from bot.storage import storage def show_request_msg(msg): chat_id = str(msg['chat']['id']) diff --git a/src/storage/__init__.py b/bot/storage/__init__.py similarity index 93% rename from src/storage/__init__.py rename to bot/storage/__init__.py index 5a95b77..838d528 100644 --- a/src/storage/__init__.py +++ b/bot/storage/__init__.py @@ -1,6 +1,6 @@ import redis -from storage.profile import Profile as ProfileObj -from config import REDIS_URL +from profile import Profile as ProfileObj +from bot.config import REDIS_URL import json diff --git a/src/storage/profile.py b/bot/storage/profile.py similarity index 100% rename from src/storage/profile.py rename to bot/storage/profile.py diff --git a/src/utils/graph.py b/bot/utils/graph.py similarity index 100% rename from src/utils/graph.py rename to bot/utils/graph.py diff --git a/src/utils/mention.py b/bot/utils/mention.py similarity index 100% rename from src/utils/mention.py rename to bot/utils/mention.py diff --git a/vercel.json b/vercel.json index 5428422..e2e757a 100755 --- a/vercel.json +++ b/vercel.json @@ -1,7 +1,7 @@ { "version": 2, "functions": { - "src/webhook.py": { + "api/webhook.py": { "memory": 1024, "maxDuration": 10 } @@ -9,7 +9,7 @@ "routes": [ { "src": "/", - "dest": "/src/webhook.py" + "dest": "/api/webhook.py" } ] }