Spaces:
Runtime error
Runtime error
Update Hellbot/__main__.py
Browse files- Hellbot/__main__.py +54 -33
Hellbot/__main__.py
CHANGED
@@ -1,33 +1,54 @@
|
|
1 |
-
from pyrogram import idle
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pyrogram import idle
|
2 |
+
import dns.resolver
|
3 |
+
import socket
|
4 |
+
|
5 |
+
from Hellbot import __version__
|
6 |
+
from Hellbot.core import (
|
7 |
+
Config,
|
8 |
+
ForcesubSetup,
|
9 |
+
GachaBotsSetup,
|
10 |
+
TemplateSetup,
|
11 |
+
UserSetup,
|
12 |
+
db,
|
13 |
+
hellbot,
|
14 |
+
)
|
15 |
+
from Hellbot.functions.tools import initialize_git
|
16 |
+
from Hellbot.functions.utility import BList, Flood, TGraph
|
17 |
+
|
18 |
+
def custom_resolver(hostname):
|
19 |
+
resolver = dns.resolver.Resolver()
|
20 |
+
resolver.nameservers = ["8.8.8.8", "8.8.4.4"] # Using Google's DNS servers
|
21 |
+
answers = resolver.resolve(hostname, "A")
|
22 |
+
return answers[0].address
|
23 |
+
|
24 |
+
|
25 |
+
original_getaddrinfo = socket.getaddrinfo
|
26 |
+
|
27 |
+
|
28 |
+
def custom_getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
|
29 |
+
try:
|
30 |
+
ip = custom_resolver(host)
|
31 |
+
return [(socket.AF_INET, socket.SOCK_STREAM, proto, "", (ip, port))]
|
32 |
+
except Exception as e:
|
33 |
+
return original_getaddrinfo(host, port, family, type, proto, flags)
|
34 |
+
|
35 |
+
|
36 |
+
socket.getaddrinfo = custom_getaddrinfo
|
37 |
+
|
38 |
+
async def main():
|
39 |
+
await hellbot.startup()
|
40 |
+
await db.connect()
|
41 |
+
await UserSetup()
|
42 |
+
await ForcesubSetup()
|
43 |
+
await GachaBotsSetup()
|
44 |
+
await TemplateSetup()
|
45 |
+
await Flood.updateFromDB()
|
46 |
+
await BList.updateBlacklists()
|
47 |
+
await TGraph.setup()
|
48 |
+
await initialize_git(Config.PLUGINS_REPO)
|
49 |
+
await hellbot.start_message(__version__)
|
50 |
+
await idle()
|
51 |
+
|
52 |
+
|
53 |
+
if __name__ == "__main__":
|
54 |
+
hellbot.run(main())
|