From 1719185eef0faaff24b5aa47e1560cf0d785e1e5 Mon Sep 17 00:00:00 2001 From: blackfur <64478051+theblackfurguy@users.noreply.github.com> Date: Sun, 17 Jan 2021 18:58:50 +0100 Subject: [PATCH] Changed Config to a extern file based system --- .gitignore | 4 ++-- run.py | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index c95bdc2..322a323 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ # Exclude VENV venv/ -# Exclude ChatLogs, DataBases and the API Token +# Exclude ChatLogs, DataBases and the Config chatlogs/ db.sqlite3 -token \ No newline at end of file +config.yml \ No newline at end of file diff --git a/run.py b/run.py index 088d8fe..c7b1a75 100644 --- a/run.py +++ b/run.py @@ -1,4 +1,3 @@ -# DO NOT CHANGE THIS import os import sys import yaml @@ -6,16 +5,8 @@ import discord from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer -# Change this to set the settings -config = {"botname": "Sheepy", - "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() +with open("config.yml", "r") as file: + config = yaml.load(file) bot = discord.Client() @@ -89,6 +80,7 @@ async def on_ready(): await train() print("Finished train!") else: + global chatbot chatbot = ChatBot(config["botname"]) -bot.run(token) +bot.run(config["token"])