fix voor chatbot in DM kanaal

This commit is contained in:
2022-11-03 22:38:41 +01:00
parent a8192fb59f
commit 617550614d
+5 -5
View File
@@ -61,14 +61,14 @@ class Chatbot(commands.Cog):
if (self.isAllowedToLearnFromPm(message)): #avoid spam-learning
self.pmCount += 1
self.pmLast = datetime.now()
yield from self.learnFromMessagesInChannel(message.channel.id, 1)
yield from self.learnFromMessagesInChannel(message.channel, 1)
yield from self.respondToMessage(message)
elif message.channel.id == self.bot.hdChannels["belangrijk"]: #don't abuse the "belangrijk" channel
pass
else:
a = random.randint(0,999) # probablity
if a < 40:
yield from self.learnFromMessagesInChannel(message.channel.id, 10)
yield from self.learnFromMessagesInChannel(message.channel, 10)
if "stroop" in message.content.lower():
a = a / 20 # significantly increase the chance of responding if somebody talks about him.
if message.channel.id == self.bot.hdChannels["shitpost"] and a < 40: #shitpost channel
@@ -190,16 +190,16 @@ class Chatbot(commands.Cog):
param nrOfMessages: use the x most recent messages
"""
yield from self.learnFromMessagesInChannel(channelId, nrOfMessages)
channel=self.bot.get_channel(channelId)
yield from self.learnFromMessagesInChannel(channel, nrOfMessages)
yield from ctx.channel.send("Ik heb weer wat nieuwe woordjes geleerd. :slight_smile:")
#Learns from an x number of messages from a certain channel
@asyncio.coroutine
def learnFromMessagesInChannel(self, channelId, nrOfMessages):
def learnFromMessagesInChannel(self, channel, nrOfMessages):
channel=self.bot.get_channel(channelId)
#Open current chain:
wordDict = np.load('markov_dict.npy', allow_pickle=True).item()