isort
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import requests
|
||||
from config import ADMIN_USERNAME, ADMIN_PASSWORD, GET_INBOUNDS_URL
|
||||
import json
|
||||
|
||||
import requests
|
||||
|
||||
from config import GET_INBOUNDS_URL, API_URL
|
||||
|
||||
session = None
|
||||
|
||||
def login_with_credentials(username, password):
|
||||
global session
|
||||
session = requests.Session()
|
||||
auth_url = "https://solonet.pocomacho.ru:62553/solonet/login/"
|
||||
auth_url = f"{API_URL}/login/"
|
||||
data = {
|
||||
"username": username,
|
||||
"password": password
|
||||
@@ -39,7 +41,7 @@ def link(session, client_id: str, email: str):
|
||||
if 'obj' not in response or len(response['obj']) == 0:
|
||||
raise Exception("Не удалось получить данные клиентов.")
|
||||
|
||||
inbounds = response['obj'][0] # Убедитесь, что это правильный индекс
|
||||
inbounds = response['obj'][0]
|
||||
settings = json.loads(inbounds['settings'])
|
||||
|
||||
# Найти клиентский ID в настройках
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
from aiogram import Bot, Dispatcher, Router
|
||||
from aiogram.fsm.storage.memory import MemoryStorage
|
||||
from config import API_TOKEN
|
||||
|
||||
from auth import login_with_credentials
|
||||
from config import API_TOKEN
|
||||
|
||||
bot = Bot(token=API_TOKEN)
|
||||
storage = MemoryStorage()
|
||||
dp = Dispatcher(bot=bot, storage=storage)
|
||||
router = Router()
|
||||
|
||||
from handlers import start, profile, keys, balance, pay
|
||||
from handlers import balance, keys, pay, profile, start
|
||||
from key_management import router as key_management_router
|
||||
|
||||
|
||||
# Регистрация обработчиков
|
||||
dp.include_router(start.router)
|
||||
dp.include_router(profile.router)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import json
|
||||
|
||||
from config import API_URL
|
||||
|
||||
|
||||
def add_client(session, client_id: str, email: str, tg_id: str, limit_ip: int, total_gb: int, expiry_time: int, enable: bool, flow: str):
|
||||
url = 'https://solonet.pocomacho.ru:62553/solonet/panel/api/inbounds/addClient'
|
||||
url = f'{API_URL}/panel/api/inbounds/addClient'
|
||||
|
||||
email = email.lower()
|
||||
|
||||
@@ -41,7 +44,7 @@ def add_client(session, client_id: str, email: str, tg_id: str, limit_ip: int, t
|
||||
print(f"Ошибка при добавлении клиента: {response.status_code}, {response.text}")
|
||||
|
||||
def extend_client_key(session, tg_id, client_id, email: str, new_expiry_time: int) -> bool:
|
||||
response = session.get(f"https://solonet.pocomacho.ru:62553/solonet/panel/api/inbounds/getClientTraffics/{email}")
|
||||
response = session.get(f"{API_URL}/panel/api/inbounds/getClientTraffics/{email}")
|
||||
print(f"GET {response.url} Status: {response.status_code}")
|
||||
print(f"GET Response: {response.text}")
|
||||
|
||||
@@ -89,7 +92,7 @@ def extend_client_key(session, tg_id, client_id, email: str, new_expiry_time: in
|
||||
}
|
||||
|
||||
try:
|
||||
response = session.post(f"https://solonet.pocomacho.ru:62553/solonet/panel/api/inbounds/updateClient/{client_id}", json=payload, headers=headers)
|
||||
response = session.post(f"{API_URL}/panel/api/inbounds/updateClient/{client_id}", json=payload, headers=headers)
|
||||
print(f"POST {response.url} Status: {response.status_code}")
|
||||
print(f"POST Request Data: {json.dumps(payload, indent=2)}")
|
||||
print(f"POST Response: {response.text}")
|
||||
@@ -104,7 +107,7 @@ def extend_client_key(session, tg_id, client_id, email: str, new_expiry_time: in
|
||||
return False
|
||||
|
||||
def delete_client(session, client_id: str) -> bool:
|
||||
url = f"https://solonet.pocomacho.ru:62553/solonet/panel/api/inbounds/1/delClient/{client_id}"
|
||||
url = f"{API_URL}/panel/api/inbounds/1/delClient/{client_id}"
|
||||
headers = {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
|
||||
+5
-2
@@ -1,6 +1,9 @@
|
||||
import asyncpg
|
||||
from datetime import datetime
|
||||
from config import DATABASE_URL
|
||||
|
||||
import asyncpg
|
||||
|
||||
from config import DATABASE_URL
|
||||
|
||||
|
||||
async def init_db():
|
||||
conn = await asyncpg.connect(DATABASE_URL)
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
from aiogram import types, Router
|
||||
import aiosqlite
|
||||
from aiogram import Router, types
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
+8
-7
@@ -1,12 +1,13 @@
|
||||
import asyncpg
|
||||
from aiogram import types, Router
|
||||
from bot import bot
|
||||
from datetime import datetime, timedelta
|
||||
from database import get_balance, update_balance
|
||||
from client import extend_client_key
|
||||
from config import ADMIN_USERNAME, DATABASE_URL, ADMIN_PASSWORD
|
||||
|
||||
import asyncpg
|
||||
from aiogram import Router, types
|
||||
|
||||
from auth import login_with_credentials
|
||||
from client import extend_client_key, delete_client
|
||||
from bot import bot
|
||||
from client import delete_client, extend_client_key
|
||||
from config import ADMIN_PASSWORD, ADMIN_USERNAME, DATABASE_URL
|
||||
from database import get_balance, update_balance
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
+6
-5
@@ -1,12 +1,13 @@
|
||||
from aiogram import types, Router
|
||||
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
import asyncpg
|
||||
from aiogram import Router, types
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
from config import ADMIN_ID, DATABASE_URL
|
||||
from database import get_balance, update_balance, get_key_count
|
||||
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
|
||||
from bot import bot
|
||||
from config import ADMIN_ID, DATABASE_URL
|
||||
from database import get_balance, get_key_count, update_balance
|
||||
from handlers.profile import process_callback_view_profile
|
||||
import asyncpg
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
+5
-3
@@ -1,8 +1,10 @@
|
||||
from aiogram import types, Router
|
||||
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from datetime import datetime
|
||||
|
||||
from aiogram import Router, types
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
from datetime import datetime
|
||||
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
|
||||
from database import get_balance, get_key_count
|
||||
|
||||
router = Router()
|
||||
|
||||
+5
-2
@@ -1,10 +1,13 @@
|
||||
from aiogram import Router, types
|
||||
from aiogram.filters import Command
|
||||
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery, Message, ReplyKeyboardMarkup, KeyboardButton
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
from aiogram.types import (CallbackQuery, InlineKeyboardButton,
|
||||
InlineKeyboardMarkup, KeyboardButton, Message,
|
||||
ReplyKeyboardMarkup)
|
||||
|
||||
from bot import bot
|
||||
from config import ADMIN_ID, CHANNEL_URL
|
||||
from bot import bot # Убедитесь, что bot и dp импортируются из правильного места
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
+16
-13
@@ -1,21 +1,24 @@
|
||||
import asyncio
|
||||
import re
|
||||
import uuid
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta
|
||||
from aiogram import Router, types, F
|
||||
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery, Message
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
|
||||
from auth import login_with_credentials, link
|
||||
from client import add_client
|
||||
from config import API_TOKEN, ADMIN_PASSWORD, ADMIN_USERNAME, ADMIN_CHAT_ID, DATABASE_URL
|
||||
from database import add_connection, has_active_key, get_balance, store_key, update_balance
|
||||
from bot import dp, bot
|
||||
from handlers.profile import process_callback_view_profile
|
||||
from handlers.start import start_command
|
||||
|
||||
import asyncpg
|
||||
from aiogram import F, Router, types
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
from aiogram.types import (CallbackQuery, InlineKeyboardButton,
|
||||
InlineKeyboardMarkup, Message)
|
||||
|
||||
from auth import link, login_with_credentials
|
||||
from bot import bot, dp
|
||||
from client import add_client
|
||||
from config import (ADMIN_CHAT_ID, ADMIN_PASSWORD, ADMIN_USERNAME, API_TOKEN,
|
||||
DATABASE_URL)
|
||||
from database import (add_connection, get_balance, has_active_key, store_key,
|
||||
update_balance)
|
||||
from handlers.profile import process_callback_view_profile
|
||||
from handlers.start import start_command
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user