xync-bot 0.0.8__tar.gz → 0.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xync-bot might be problematic. Click here for more details.
- {xync-bot-0.0.8 → xync-bot-0.0.9}/PKG-INFO +1 -1
- {xync-bot-0.0.8 → xync-bot-0.0.9}/pyproject.toml +2 -2
- {xync-bot-0.0.8 → xync-bot-0.0.9}/xync_bot/handlers/main.py +2 -2
- xync-bot-0.0.9/xync_bot/handlers/vpn.py +38 -0
- {xync-bot-0.0.8 → xync-bot-0.0.9}/xync_bot.egg-info/PKG-INFO +1 -1
- xync-bot-0.0.8/xync_bot/handlers/vpn.py +0 -18
- {xync-bot-0.0.8 → xync-bot-0.0.9}/setup.cfg +0 -0
- {xync-bot-0.0.8 → xync-bot-0.0.9}/xync_bot/__init__.py +0 -0
- {xync-bot-0.0.8 → xync-bot-0.0.9}/xync_bot/handlers/__init__.py +0 -0
- {xync-bot-0.0.8 → xync-bot-0.0.9}/xync_bot.egg-info/SOURCES.txt +0 -0
- {xync-bot-0.0.8 → xync-bot-0.0.9}/xync_bot.egg-info/dependency_links.txt +0 -0
- {xync-bot-0.0.8 → xync-bot-0.0.9}/xync_bot.egg-info/requires.txt +0 -0
- {xync-bot-0.0.8 → xync-bot-0.0.9}/xync_bot.egg-info/top_level.txt +0 -0
|
@@ -15,11 +15,11 @@ dependencies = [
|
|
|
15
15
|
"tortoise-api-model",
|
|
16
16
|
"python-wireguard"
|
|
17
17
|
]
|
|
18
|
-
version = "0.0.
|
|
18
|
+
version = "0.0.9"
|
|
19
19
|
|
|
20
20
|
[project.urls]
|
|
21
21
|
Homepage = "https://gitlab.com/xync/back/tg-bot"
|
|
22
22
|
Repository = "https://gitlab.com/xync/back/tg-bot"
|
|
23
23
|
|
|
24
24
|
[tool.setuptools]
|
|
25
|
-
packages = ["xync_bot"]
|
|
25
|
+
packages = ["xync_bot", "xync_bot.handlers"]
|
|
@@ -38,7 +38,7 @@ async def fraud_handler(msg: Message):
|
|
|
38
38
|
@main.message(CommandStart())
|
|
39
39
|
async def start_no_ref_handler(msg: Message):
|
|
40
40
|
me = msg.from_user
|
|
41
|
-
# client, cr = await user_upsert(me) # baskdoor for first user
|
|
41
|
+
# client, cr = await user_upsert(me) # todo: baskdoor for first user
|
|
42
42
|
logging.info(f'Start: {me.id}. Msg: {msg}')
|
|
43
43
|
await msg.answer(f'Sorry {me.full_name}, we do not accept only persons who has a guarantor.\n'
|
|
44
44
|
'https://telegra.ph/XyncNet-02-13')
|
|
@@ -50,7 +50,7 @@ async def ref_link_handler(msg: Message):
|
|
|
50
50
|
cl = await Client.get(user_id=my_id)
|
|
51
51
|
link = await create_start_link(msg.bot, str(cl.id), encode=True)
|
|
52
52
|
logging.info(f'Start: {my_id}. Msg: {msg}')
|
|
53
|
-
await msg.answer(f"Give it to your protege: {link}
|
|
53
|
+
await msg.answer(f"Give it to your protege: {link}")
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
async def user_upsert(u: TgUser, status: UserStatus = None) -> (Client, bool):
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from aiogram.types import MenuButtonWebApp, WebAppInfo
|
|
2
|
+
import logging
|
|
3
|
+
from os import getenv as env
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from aiogram import Bot, Dispatcher
|
|
6
|
+
from tortoise.backends.asyncpg import AsyncpgDBClient
|
|
7
|
+
|
|
8
|
+
from xync_bot.handlers import main, vpn
|
|
9
|
+
|
|
10
|
+
load_dotenv()
|
|
11
|
+
|
|
12
|
+
TOKEN = env('TOKEN')
|
|
13
|
+
logging.basicConfig(filemode='a', level=logging.DEBUG)
|
|
14
|
+
bot = Bot(token=TOKEN, parse_mode='Markdown')
|
|
15
|
+
dp = Dispatcher(bot=bot)
|
|
16
|
+
dp.include_routers(vpn)
|
|
17
|
+
dp.include_routers(main)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async def on_startup(wh_url: str, twa_url: str, cn: AsyncpgDBClient, mbt: str = 'Go!'):
|
|
21
|
+
""" SET DEISPATCHER GLOBAL WORKFLOW DATA FOR DB Connection """
|
|
22
|
+
dp['dbc'] = cn
|
|
23
|
+
""" WEBHOOK SETUP """
|
|
24
|
+
webhook_info = await bot.get_webhook_info()
|
|
25
|
+
if webhook_info.url != wh_url:
|
|
26
|
+
await bot.set_webhook(url=wh_url)
|
|
27
|
+
""" WEBAPP URL SETUP IN MENU """
|
|
28
|
+
await bot.set_chat_menu_button(menu_button=MenuButtonWebApp(text=mbt, web_app=WebAppInfo(url=twa_url)))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async def on_shutdown():
|
|
32
|
+
""" CLOSE BOT SESSION """
|
|
33
|
+
await bot.delete_webhook()
|
|
34
|
+
await bot.session.close()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
dp.startup.register(on_startup)
|
|
38
|
+
dp.shutdown.register(on_shutdown)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from aiogram import Router
|
|
2
|
-
from aiogram.filters import Command
|
|
3
|
-
from aiogram.types import Message
|
|
4
|
-
from antifragility_schema.models import Client, Vpn
|
|
5
|
-
from python_wireguard import Key
|
|
6
|
-
|
|
7
|
-
vpn = Router()
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@vpn.message(Command('get_vpn'))
|
|
11
|
-
async def get_vpn(msg: Message):
|
|
12
|
-
my_id = msg.from_user.id
|
|
13
|
-
cl = await Client.get(user_id=my_id).prefetch_related('vpn')
|
|
14
|
-
if not cl.vpn:
|
|
15
|
-
private, public = Key.key_pair()
|
|
16
|
-
await Vpn.create(priv=private, pub=public, client=cl)
|
|
17
|
-
await msg.answer(f"Take your file!")
|
|
18
|
-
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|