learn automatically
This commit is contained in:
+12
-2
@@ -35,14 +35,17 @@ class Chatbot(object):
|
||||
return
|
||||
|
||||
if "DMChannel" in type(message.channel).__name__: #respond to messages in PM channels
|
||||
yield from self.learnFromMessagesInChannel(message.channel.id, 1)
|
||||
yield from self.respondToMessage(message)
|
||||
elif message.channel.id == 139061614178598912: #don't abuse the "belangrijk" channel
|
||||
pass
|
||||
else:
|
||||
a = random.randint(0,999)
|
||||
if message.channel.id == 137218228953939968 and a < 40: #shitpost channel
|
||||
yield from self.learnFromMessagesInChannel(message.channel.id, 10)
|
||||
yield from self.respondToMessage(message)
|
||||
elif a < 10: #all other channels
|
||||
yield from self.learnFromMessagesInChannel(message.channel.id, 20)
|
||||
yield from self.respondToMessage(message)
|
||||
|
||||
#process commands:
|
||||
@@ -146,6 +149,15 @@ class Chatbot(object):
|
||||
param nrOfMessages: use the x most recent messages
|
||||
"""
|
||||
|
||||
yield from self.learnFromMessagesInChannel(channelId, 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):
|
||||
|
||||
channel=self.bot.get_channel(channelId)
|
||||
#Open current chain:
|
||||
wordDict = np.load('markov_dict.npy').item()
|
||||
@@ -193,8 +205,6 @@ class Chatbot(object):
|
||||
|
||||
np.save("markov_dict.npy", wordDict)
|
||||
|
||||
yield from ctx.channel.send("Ik heb weer wat nieuwe woordjes geleerd. :slight_smile:")
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
@asyncio.coroutine
|
||||
|
||||
Reference in New Issue
Block a user