-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
executable file
·65 lines (45 loc) · 1.55 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
60
61
62
63
64
65
import asyncio
import json
import logging
from colorama import init as init_colorama
from bot import BedrockBot
def check_jsons():
try:
f = open("config.json", "r")
except FileNotFoundError:
token = input("BOT SETUP - Enter bot token: ")
with open("config.json", "w+") as f:
json.dump({"token": token}, f, indent=4)
try:
f = open("blacklist.json", "r")
except FileNotFoundError:
with open("blacklist.json", "w+") as f:
json.dump([], f, indent=4)
try:
f = open("runs_blacklist.json", "r")
except FileNotFoundError:
with open("runs_blacklist.json", "w+") as f:
json.dump({"videos": [], "players": []}, f, indent=4)
def setup_logging():
FORMAT = "%(asctime)s - [%(levelname)s]: %(message)s"
DATE_FORMAT = "%d/%m/%Y (%H:%M:%S)"
logger = logging.getLogger("discord")
logger.setLevel(logging.INFO)
file_handler = logging.FileHandler(
filename="discord.log", mode="a", encoding="utf-8"
)
file_handler.setFormatter(logging.Formatter(fmt=FORMAT, datefmt=DATE_FORMAT))
file_handler.setLevel(logging.INFO)
logger.addHandler(file_handler)
console_handler = logging.StreamHandler()
console_handler.setFormatter(logging.Formatter(fmt=FORMAT, datefmt=DATE_FORMAT))
console_handler.setLevel(logging.WARNING)
logger.addHandler(console_handler)
def run_bot():
bot = BedrockBot()
bot.run()
if __name__ == "__main__":
init_colorama(autoreset=True)
setup_logging()
check_jsons()
run_bot()