Allows pickled loading in chatbot

This commit is contained in:
Mark Hoekveen
2020-05-25 12:52:07 +02:00
parent d12289b2a6
commit e9a0ede5b2
+4 -4
View File
@@ -17,7 +17,7 @@ class Chatbot(commands.Cog):
self.pmLast = datetime(2018, 1, 1, 1, 1, 1) self.pmLast = datetime(2018, 1, 1, 1, 1, 1)
self.pmCount = 0 self.pmCount = 0
try: try:
np.load('markov_dict.npy') np.load('markov_dict.npy', allow_pickle=True)
except FileNotFoundError: except FileNotFoundError:
#If there's no initial file, make a new one: #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':{}} 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) channel=self.bot.get_channel(channelId)
#Open current chain: #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: #Iterate through the last x messages from the channel:
messageIterator = channel.history(limit=nrOfMessages, before=None, after=None, oldest_first=False, around=None) 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 MAX_N_WORDS = 100 #Don't use more words than this
#Get dictionary/Markov chain #Get dictionary/Markov chain
wordDict = np.load('markov_dict.npy').item() wordDict = np.load('markov_dict.npy', allow_pickle=True).item()
wordPairDict = wordDict['pairs'] wordPairDict = wordDict['pairs']
wordTrairDict = wordDict['trairs'] wordTrairDict = wordDict['trairs']
responsePairDict = wordDict['responsePairs'] responsePairDict = wordDict['responsePairs']
@@ -389,7 +389,7 @@ class Chatbot(commands.Cog):
MAX_N_TRIES = 50 MAX_N_TRIES = 50
#Get dictionary/Markov chain #Get dictionary/Markov chain
wordDict = np.load('markov_dict.npy').item() wordDict = np.load('markov_dict.npy', allow_pickle=True).item()
wordPairDict = wordDict['pairs'] wordPairDict = wordDict['pairs']
#try: #try: