Changed Config to a extern file based system

This commit is contained in:
blackfur 2021-01-17 18:58:50 +01:00
parent 8510ff5f6a
commit 1719185eef
2 changed files with 6 additions and 14 deletions

4
.gitignore vendored
View file

@ -4,8 +4,8 @@
# Exclude VENV # Exclude VENV
venv/ venv/
# Exclude ChatLogs, DataBases and the API Token # Exclude ChatLogs, DataBases and the Config
chatlogs/ chatlogs/
db.sqlite3 db.sqlite3
token config.yml

16
run.py
View file

@ -1,4 +1,3 @@
# DO NOT CHANGE THIS
import os import os
import sys import sys
import yaml import yaml
@ -6,16 +5,8 @@ import discord
from chatterbot import ChatBot from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer
# Change this to set the settings with open("config.yml", "r") as file:
config = {"botname": "Sheepy", config = yaml.load(file)
"filterpings": True,
"usechannels": [717758904527880253, 772839872557088769, 773980809471197235],
"trainchannels": [[492412566430154783, 1000], [761462125696385047, 1000]],
"corpus": ["chatterbot.corpus.english"]}
# DO NOT CHANGE THIS
with open("token", "r") as tokenfile:
token = tokenfile.read()
bot = discord.Client() bot = discord.Client()
@ -89,6 +80,7 @@ async def on_ready():
await train() await train()
print("Finished train!") print("Finished train!")
else: else:
global chatbot
chatbot = ChatBot(config["botname"]) chatbot = ChatBot(config["botname"])
bot.run(token) bot.run(config["token"])