This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
forked from thepriyamkalra/TGSuite-v1
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathBEASTBOT.py
63 lines (53 loc) · 1.7 KB
/
BEASTBOT.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import logging
import os
import sys
from pathlib import Path
from userbot import Userbot
from userbot.storage import Storage
from telethon.sessions import StringSession
logging.basicConfig(level=logging.INFO)
ENV = bool(os.environ.get("ENV", False))
if ENV:
from production import Config
else:
if os.path.exists("development.py"):
from development import devConfig as Config
else:
logging.warning("No config.py Found!")
logging.info(
"Please run the command, again, after creating config.py similar to README.md")
sys.exit(1)
if Config.DB_URI is None:
logging.warning("No DB_URI Found!")
sys.exit(1)
if len(Config.SUDO_USERS) >= 0:
Config.SUDO_USERS.add("me")
if Config.SESSION is not None:
session_name = str(Config.SESSION)
userbot = Userbot(
StringSession(session_name),
module_path="modules/",
api_config=Config,
api_id=Config.APP_ID,
api_hash=Config.API_HASH
)
userbot.run_until_disconnected()
elif len(sys.argv) == 2:
session_name = str(sys.argv[1])
userbot = Userbot(
session_name,
module_path="modules/",
connection_retries=None,
api_config=Config,
api_id=Config.APP_ID,
api_hash=Config.API_HASH
)
userbot.run_until_disconnected()
else:
logging.error("USAGE EXAMPLE:\n"
"python3 -m BEASTBOT <SESSION_NAME>"
"\nPlease follow the above format to run your userbot."
"\nAborting.")