-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·59 lines (46 loc) · 1.86 KB
/
main.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
#!/usr/bin/python3
import logging
import os
import platform
from models import ChenBot
if int(platform.python_version_tuple()[1]) < 10:
logging.fatal("Python version must be 3.10 or greater! Exiting...")
raise RuntimeError("Python version is not 3.10 or greater.")
try:
with open(".env") as env:
for line in env.readlines():
if not line.strip() or line.startswith("#"):
continue
os.environ[line.split("=", maxsplit=1)[0]] = line.split("=", maxsplit=1)[1].split("#")[0].strip()
except FileNotFoundError:
logging.info(".env file not found, using secrets from the environment instead.")
try:
from config import Config
except ImportError:
logging.fatal(
"Failed loading configuration. Please make sure 'config.py' exists in the root directory of the project and contains valid data."
)
exit()
if os.name != "nt": # Lol imagine using Windows
try:
import uvloop
except ImportError:
logging.warn(
"Failed to import uvloop! Make sure to install it via 'pip install uvloop' for enhanced performance!"
)
else:
uvloop.install()
bot = ChenBot(Config())
if __name__ == "__main__":
bot.run()
# Copyright (C) 2022-present HyperGH
# 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