Add initial code
This commit is contained in:
35
src/main.py
Normal file
35
src/main.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import json
|
||||
|
||||
from core.bot import Bot
|
||||
|
||||
def main():
|
||||
|
||||
try:
|
||||
with open("config.json", "rt") as config_file:
|
||||
config = json.load(config_file)
|
||||
except OSError as e:
|
||||
print(f"Could not open config.json! Error: {e.strerror}")
|
||||
return
|
||||
except Exception as e:
|
||||
print(f"Error loading config. Error: {e}")
|
||||
return
|
||||
|
||||
# Load token from token file if not in JSON config
|
||||
if config["token"] == "":
|
||||
try:
|
||||
with open("token.txt", "rt") as token_file:
|
||||
config["token"] = token_file.readline()
|
||||
except OSError as e:
|
||||
print(f"Could not open token.txt! Error: {e.strerror}")
|
||||
return
|
||||
|
||||
try:
|
||||
bot = Bot()
|
||||
bot.load_config(config)
|
||||
bot.run(config["token"])
|
||||
except Exception as e:
|
||||
print(f"Exception running bot! Error: {e}")
|
||||
return
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user