2021-09-13 23:09:26 +00:00
|
|
|
# Copyright (C) 2021 By VeezMusicProject
|
|
|
|
|
2021-09-09 01:18:24 +00:00
|
|
|
# ===========
|
|
|
|
# running bot
|
|
|
|
# ===========
|
2021-09-13 08:24:22 +00:00
|
|
|
import logging
|
|
|
|
import time
|
2021-09-13 09:51:14 +00:00
|
|
|
import sys
|
2021-09-09 03:05:12 +00:00
|
|
|
import asyncio
|
2021-09-13 09:51:14 +00:00
|
|
|
import glob
|
|
|
|
import importlib
|
|
|
|
from pathlib import Path
|
2021-09-09 01:18:24 +00:00
|
|
|
from pyrogram import Client, idle
|
2021-09-12 04:34:03 +00:00
|
|
|
from config import Veez
|
2021-09-09 01:18:24 +00:00
|
|
|
from bot.videoplayer import app
|
2021-09-09 05:02:51 +00:00
|
|
|
from bot.videoplayer import call_py
|
2021-09-13 08:24:22 +00:00
|
|
|
from helpers.loggings import LOG
|
2021-09-13 09:54:02 +00:00
|
|
|
|
2021-09-13 09:51:14 +00:00
|
|
|
|
2021-09-09 01:18:24 +00:00
|
|
|
bot = Client(
|
|
|
|
":memory:",
|
2021-09-12 04:34:03 +00:00
|
|
|
Veez.API_ID,
|
|
|
|
Veez.API_HASH,
|
|
|
|
bot_token=Veez.BOT_TOKEN,
|
2021-09-09 01:18:24 +00:00
|
|
|
plugins=dict(root="bot"),
|
|
|
|
)
|
|
|
|
|
2021-09-13 09:51:14 +00:00
|
|
|
StartTime = time.time()
|
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
|
|
|
_path = f"bot/*.py"
|
|
|
|
files = glob.glob(_path)
|
|
|
|
|
|
|
|
def load_plugins(plugin_name):
|
|
|
|
path = Path(f"bot/{plugin_name}.py")
|
|
|
|
name = "bot.{}".format(plugin_name)
|
|
|
|
spec = importlib.util.spec_from_file_location(name, path)
|
|
|
|
load = importlib.util.module_from_spec(spec)
|
|
|
|
spec.loader.exec_module(load)
|
|
|
|
sys.modules[f"bot." + plugin_name] = load
|
|
|
|
print("Imported => " + plugin_name)
|
|
|
|
|
|
|
|
async def start():
|
|
|
|
print('\n')
|
2021-09-14 08:18:57 +00:00
|
|
|
print('------------------ Initalizing VEEZ --------------------')
|
2021-09-13 09:51:14 +00:00
|
|
|
if bot:
|
|
|
|
await bot.start()
|
|
|
|
await app.start()
|
|
|
|
await call_py.start()
|
2021-09-14 08:18:57 +00:00
|
|
|
print('------------------------ DONE --------------------------')
|
|
|
|
print('------------------ Importing Modules -------------------')
|
2021-09-13 09:51:14 +00:00
|
|
|
for name in files:
|
|
|
|
with open(name) as a:
|
|
|
|
path_ = Path(a.name)
|
|
|
|
plugin_name = path_.stem
|
|
|
|
load_plugins(plugin_name.replace(".py", ""))
|
2021-09-14 08:18:57 +00:00
|
|
|
print('------------------- INITIATED VEEZ ---------------------')
|
|
|
|
print(' Logged in as User =>> {}'.format((await app.get_me()).first_name))
|
2021-09-13 09:51:14 +00:00
|
|
|
if bot:
|
2021-09-14 08:18:57 +00:00
|
|
|
print(' Logged in to Bots =>> {}'.format((await bot.get_me()).first_name))
|
|
|
|
print('--------------------------------------------------------')
|
2021-09-13 09:51:14 +00:00
|
|
|
await idle()
|
2021-09-13 15:10:10 +00:00
|
|
|
if __name__ == '__main__':
|
2021-09-13 14:42:36 +00:00
|
|
|
is_bot = bool(Veez.BOT_TOKEN)
|
|
|
|
loop.run_until_complete(start())
|
2021-09-13 15:10:10 +00:00
|
|
|
|
|
|
|
|
2021-09-14 05:51:47 +00:00
|
|
|
bot.start()
|
|
|
|
print("[STATUS]:✅ »» BOT CLIENT STARTED ««")
|
|
|
|
app.start()
|
|
|
|
print("[STATUS]:✅ »» USERBOT CLIENT STARTED ««")
|
|
|
|
call_py.start()
|
|
|
|
print("[STATUS]:✅ »» PYTGCALLS CLIENT STARTED ««")
|
|
|
|
idle()
|
|
|
|
print("[STATUS]:❌ »» BOT STOPPED ««")
|