https://dev.kronoz.win/r/marzneshin.git
| 1 |
a47eb4c |
Dawsh |
2y ago |
import importlib.util |
| 2 |
a47eb4c |
Dawsh |
2y ago |
from os.path import dirname |
| 3 |
a47eb4c |
Dawsh |
2y ago |
from config import TELEGRAM_API_TOKEN, TELEGRAM_PROXY_URL |
| 4 |
a47eb4c |
Dawsh |
2y ago |
from telebot.async_telebot import AsyncTeleBot |
| 5 |
f7af2b3 |
Dawsh |
2y ago |
from telebot import asyncio_helper |
| 6 |
a47eb4c |
Dawsh |
2y ago |
|
| 7 |
a47eb4c |
Dawsh |
2y ago |
bot = None |
| 8 |
a47eb4c |
Dawsh |
2y ago |
if TELEGRAM_API_TOKEN: |
| 9 |
a47eb4c |
Dawsh |
2y ago |
asyncio_helper.proxy = TELEGRAM_PROXY_URL |
| 10 |
a47eb4c |
Dawsh |
2y ago |
bot = AsyncTeleBot(TELEGRAM_API_TOKEN) |
| 11 |
a47eb4c |
Dawsh |
2y ago |
|
| 12 |
f7af2b3 |
Dawsh |
2y ago |
handler_names = ["admin", "user"] |
| 13 |
f7af2b3 |
Dawsh |
2y ago |
|
| 14 |
a47eb4c |
Dawsh |
2y ago |
|
| 15 |
a47eb4c |
Dawsh |
2y ago |
async def start_bot(): |
| 16 |
a47eb4c |
Dawsh |
2y ago |
if bot: |
| 17 |
a47eb4c |
Dawsh |
2y ago |
handler_dir = dirname(__file__) + "/handlers/" |
| 18 |
a47eb4c |
Dawsh |
2y ago |
for name in handler_names: |
| 19 |
a47eb4c |
Dawsh |
2y ago |
spec = importlib.util.spec_from_file_location(name, f"{handler_dir}{name}.py") |
| 20 |
a47eb4c |
Dawsh |
2y ago |
spec.loader.exec_module(importlib.util.module_from_spec(spec)) |
| 21 |
a47eb4c |
Dawsh |
2y ago |
|
| 22 |
a47eb4c |
Dawsh |
2y ago |
from app.telegram import utils # setup custom handlers |
| 23 |
a47eb4c |
Dawsh |
2y ago |
utils.setup() |
| 24 |
f7af2b3 |
Dawsh |
2y ago |
await bot.polling() |
| 25 |
a47eb4c |
Dawsh |
2y ago |
|
| 26 |
a47eb4c |
Dawsh |
2y ago |
|
| 27 |
a47eb4c |
Dawsh |
2y ago |
from .handlers.report import ( # noqa |
| 28 |
a47eb4c |
Dawsh |
2y ago |
report, |
| 29 |
a47eb4c |
Dawsh |
2y ago |
report_new_user, |
| 30 |
a47eb4c |
Dawsh |
2y ago |
report_user_modification, |
| 31 |
a47eb4c |
Dawsh |
2y ago |
report_user_deletion, |
| 32 |
a47eb4c |
Dawsh |
2y ago |
report_status_change, |
| 33 |
a47eb4c |
Dawsh |
2y ago |
report_user_usage_reset, |
| 34 |
a47eb4c |
Dawsh |
2y ago |
report_user_subscription_revoked |
| 35 |
a47eb4c |
Dawsh |
2y ago |
) |
| 36 |
a47eb4c |
Dawsh |
2y ago |
|
| 37 |
a47eb4c |
Dawsh |
2y ago |
__all__ = [ |
| 38 |
a47eb4c |
Dawsh |
2y ago |
"bot", |
| 39 |
a47eb4c |
Dawsh |
2y ago |
"report", |
| 40 |
a47eb4c |
Dawsh |
2y ago |
"report_new_user", |
| 41 |
a47eb4c |
Dawsh |
2y ago |
"report_user_modification", |
| 42 |
a47eb4c |
Dawsh |
2y ago |
"report_user_deletion", |
| 43 |
a47eb4c |
Dawsh |
2y ago |
"report_status_change", |
| 44 |
a47eb4c |
Dawsh |
2y ago |
"report_user_usage_reset", |
| 45 |
a47eb4c |
Dawsh |
2y ago |
"report_user_subscription_revoked" |
| 46 |
a47eb4c |
Dawsh |
2y ago |
] |