From a5708359ddd7f9e093c625177065af9ab759e0f0 Mon Sep 17 00:00:00 2001 From: blackfur <64478051+theblackfurguy@users.noreply.github.com> Date: Sun, 31 Jan 2021 17:49:47 +0100 Subject: [PATCH] Added fix so bot wont rerun tasks on connection loss + Added a fix so bot will show correct status after connection loss + Added notification when the tasks start --- run.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/run.py b/run.py index 9eb9259..8a1e8f2 100644 --- a/run.py +++ b/run.py @@ -25,7 +25,7 @@ def printhelp(): def printversion(): - print("SheepBotFrame Beta 1.43") + print("SheepBotFrame Beta 1.44") def remove_mention(m, s, i): @@ -36,6 +36,7 @@ def remove_mention(m, s, i): async def download(): + print("Starting download...") await bot.change_presence(activity=discord.Game(name=" downloading Message History")) os.system("rm chatlogs/*.tmp.yml") for trainchannel in config["trainchannels"]: @@ -51,6 +52,7 @@ async def download(): async def train(): + print("Starting training...") await bot.change_presence(activity=discord.Game(name=" training, training and training...")) corpustrainer = ChatterBotCorpusTrainer(chatbot) listtrainer = ListTrainer(chatbot) @@ -62,11 +64,8 @@ async def train(): listtrainer.train(log) -@bot.event -async def on_ready(): - await bot.change_presence(activity=discord.Game(name=" listening for messages!")) +async def startup(): global chatbot - print("Logged in!") args = sys.argv args.pop(0) for arg in args: @@ -100,6 +99,15 @@ async def on_ready(): global finished finished = True print("Starting to listen to messages...") + await bot.change_presence(activity=discord.Game(name=" listening for messages!")) + + +@bot.event +async def on_ready(): + await bot.change_presence(activity=discord.Game(name=" listening for messages!")) + print("Logged in!") + if not finished: + await startup() @bot.event