This repository has been archived by the owner on Nov 29, 2024. It is now read-only.
forked from The-MoonTg-project/Moon-Userbot
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.py
70 lines (59 loc) · 2.25 KB
/
install.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
64
65
66
67
68
69
70
# Moon-Userbot - telegram userbot
# Copyright (C) 2020-present Moon Userbot Organization
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from datetime import datetime
import sys
from pyrogram import Client
from utils import config
common_params = {
"api_id": config.api_id,
"api_hash": config.api_hash,
"hide_password": True,
"test_mode": config.test_server,
}
if __name__ == "__main__":
if config.STRINGSESSION:
common_params["session_string"] = config.STRINGSESSION
app = Client("my_account", **common_params)
if config.db_type in ["mongo", "mongodb"]:
from pymongo import MongoClient, errors
db = MongoClient(config.db_url)
try:
db.server_info()
except errors.ConnectionFailure as e:
raise RuntimeError(
"MongoDB server isn't available! "
f"Provided url: {config.db_url}. "
"Enter valid URL and restart installation"
) from e
install_type = sys.argv[1] if len(sys.argv) > 1 else "3"
if install_type == "1":
restart = "pm2 restart Moon"
elif install_type == "2":
restart = "sudo systemctl restart Moon"
else:
restart = "cd Moon-Userbot/ && python main.py"
app.start()
try:
app.send_message(
"me",
f"<b>[{datetime.now()}] Moon-Userbot launched! \n"
"Channel: @moonuserbot\n"
"Custom modules: @moonub_modules\n"
"Chat: @moonub_chat\n"
f"For restart, enter:</b>\n"
f"<code>{restart}</code>",
)
except Exception as e:
print(f"[ERROR]: Sending Message to me failed! {e}")
app.stop()