xteamki commited on
Commit
1b9a7d4
·
verified ·
1 Parent(s): 5126418

Upload 4 files

Browse files
Files changed (4) hide show
  1. Zaid/__init__.py +24 -0
  2. Zaid/__main__.py +38 -0
  3. Zaid/status.py +18 -0
  4. Zaid/utils.py +14 -0
Zaid/__init__.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from telethon import TelegramClient
4
+ from telethon import TelegramClient, events
5
+ from telethon.sessions import StringSession
6
+ from telethon.network.connection.tcpabridged import ConnectionTcpAbridged
7
+ import logging
8
+ from pytgcalls import PyTgCalls
9
+ from telethon.network.connection.tcpabridged import ConnectionTcpAbridged
10
+
11
+ logging.basicConfig(format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s',
12
+ level=logging.INFO)
13
+
14
+
15
+ from Config import Config
16
+ BOT_USERNAME = Config.BOT_USERNAME
17
+ ASSISTANT_ID = Config.ASSISTANT_ID
18
+
19
+ bot = TelegramClient('Zaid', api_id=Config.API_ID, api_hash=Config.API_HASH)
20
+ Zaid = bot.start(bot_token=Config.BOT_TOKEN)
21
+ client = TelegramClient(StringSession(Config.STRING_SESSION), Config.API_ID, Config.API_HASH)
22
+ call_py = PyTgCalls(client)
23
+ client.start()
24
+ call_py.start()
Zaid/__main__.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import telethon
3
+ import glob
4
+ from pathlib import Path
5
+ from Zaid.utils import load_plugins
6
+ import logging
7
+ from Zaid import Zaid
8
+ from Zaid import client, ASSISTANT_ID
9
+ from Zaid.plugins.autoleave import leave_from_inactive_call
10
+
11
+
12
+ logging.basicConfig(format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s',
13
+ level=logging.INFO)
14
+
15
+ path = "Zaid/plugins/*.py"
16
+ files = glob.glob(path)
17
+ for name in files:
18
+ with open(name) as a:
19
+ patt = Path(a.name)
20
+ plugin_name = patt.stem
21
+ load_plugins(plugin_name.replace(".py", ""))
22
+
23
+ async def start_bot():
24
+ print("[INFO]: LOADING ASSISTANT DETAILS")
25
+ botme = await client.get_me()
26
+ botid = telethon.utils.get_peer_id(botme)
27
+ print(f"[INFO]: ASSISTANT ID {botid}")
28
+ await asyncio.create_task(leave_from_inactive_call())
29
+
30
+
31
+ loop = asyncio.get_event_loop()
32
+ loop.run_until_complete(start_bot())
33
+
34
+ print("[INFO]: SUCCESSFULLY STARTED BOT!")
35
+ print("[INFO]: VISIT @TheUpdatesChannel")
36
+
37
+ if __name__ == "__main__":
38
+ Zaid.run_until_disconnected()
Zaid/status.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import functools
2
+
3
+ def is_admin(func):
4
+ @functools.wraps(func)
5
+ async def a_c(event):
6
+ is_admin = False
7
+ if not event.is_private:
8
+ try:
9
+ _s = await event.client.get_permissions(event.chat_id, event.sender_id)
10
+ if _s.is_admin:
11
+ is_admin = True
12
+ except:
13
+ is_admin = False
14
+ if is_admin:
15
+ await func(event, _s)
16
+ else:
17
+ await event.reply("Only Admins can execute this command!")
18
+ return a_c
Zaid/utils.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import logging
3
+ import importlib
4
+ from pathlib import Path
5
+
6
+ def load_plugins(plugin_name):
7
+ path = Path(f"Zaid/plugins/{plugin_name}.py")
8
+ name = "Zaid.plugins.{}".format(plugin_name)
9
+ spec = importlib.util.spec_from_file_location(name, path)
10
+ load = importlib.util.module_from_spec(spec)
11
+ load.logger = logging.getLogger(plugin_name)
12
+ spec.loader.exec_module(load)
13
+ sys.modules["Zaid.plugins." + plugin_name] = load
14
+ print("Bot has Started " + plugin_name)