From e9a0ede5b28de4d3068abe38d9de89288becec4a Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Mon, 25 May 2020 12:52:07 +0200 Subject: [PATCH] Allows pickled loading in chatbot --- Chatbot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Chatbot.py b/Chatbot.py index 613a74e..c00c604 100644 --- a/Chatbot.py +++ b/Chatbot.py @@ -17,7 +17,7 @@ class Chatbot(commands.Cog): self.pmLast = datetime(2018, 1, 1, 1, 1, 1) self.pmCount = 0 try: - np.load('markov_dict.npy') + np.load('markov_dict.npy', allow_pickle=True) except FileNotFoundError: #If there's no initial file, make a new one: initFile = {'pairs':{self.START_OF_MESSAGE:{'Hoi':1},'Hoi':{self.END_OF_MESSAGE:1}}, 'trairs':{}, 'responsePairs':{}} @@ -187,7 +187,7 @@ class Chatbot(commands.Cog): channel=self.bot.get_channel(channelId) #Open current chain: - wordDict = np.load('markov_dict.npy').item() + wordDict = np.load('markov_dict.npy', allow_pickle=True).item() #Iterate through the last x messages from the channel: messageIterator = channel.history(limit=nrOfMessages, before=None, after=None, oldest_first=False, around=None) @@ -276,7 +276,7 @@ class Chatbot(commands.Cog): MAX_N_WORDS = 100 #Don't use more words than this #Get dictionary/Markov chain - wordDict = np.load('markov_dict.npy').item() + wordDict = np.load('markov_dict.npy', allow_pickle=True).item() wordPairDict = wordDict['pairs'] wordTrairDict = wordDict['trairs'] responsePairDict = wordDict['responsePairs'] @@ -389,7 +389,7 @@ class Chatbot(commands.Cog): MAX_N_TRIES = 50 #Get dictionary/Markov chain - wordDict = np.load('markov_dict.npy').item() + wordDict = np.load('markov_dict.npy', allow_pickle=True).item() wordPairDict = wordDict['pairs'] #try: