less spam + minor improvements
This commit is contained in:
+9
-5
@@ -29,7 +29,7 @@ class Chatbot(object):
|
||||
if message.author.bot:
|
||||
return #ignore your own messages, Stroop
|
||||
|
||||
if message.content.strip()[0] != '!': #don't respond to a command
|
||||
if message.content.strip() == "" or message.content.strip()[0] != '!': #don't respond to a command
|
||||
if message.content.lower() == "nihao":
|
||||
yield from message.channel.send("kankerlauw")
|
||||
return
|
||||
@@ -40,9 +40,9 @@ class Chatbot(object):
|
||||
pass
|
||||
else:
|
||||
a = random.randint(0,999)
|
||||
if message.channel.id == 137218228953939968 and a < 80: #shitpost channel
|
||||
if message.channel.id == 137218228953939968 and a < 40: #shitpost channel
|
||||
yield from self.respondToMessage(message)
|
||||
elif a < 20: #all other channels
|
||||
elif a < 10: #all other channels
|
||||
yield from self.respondToMessage(message)
|
||||
|
||||
#process commands:
|
||||
@@ -105,7 +105,7 @@ class Chatbot(object):
|
||||
return newPairDict, newTrairDict;
|
||||
|
||||
#Learn to respond to messages
|
||||
#Returns ???
|
||||
#Returns a new dict with response pairs
|
||||
def learnResponse(self, wordDictResp, message1: str, message2: str):
|
||||
STOP_WORDS = ["aan", "achter", "al", "ben", "dan", "dat", "de", "die", "dit", "een", "en", "er", "gehad", "had", "heb",
|
||||
"hen", "het", "hun", "in", "is", "kon", "met", "na", "of", "om", "ook", "op", "tot", "van", "was", "wat", "zo",
|
||||
@@ -250,6 +250,7 @@ class Chatbot(object):
|
||||
|
||||
#Go through the chain:
|
||||
for i in range(1, MAX_N_WORDS):
|
||||
|
||||
if chain[-1] == self.END_OF_MESSAGE:
|
||||
break
|
||||
|
||||
@@ -261,7 +262,10 @@ class Chatbot(object):
|
||||
if userWord in responsePairDict:
|
||||
for goodResponseWord in responsePairDict[userWord]:
|
||||
if goodResponseWord in pairPossibilities.keys():
|
||||
pairPossibilities[goodResponseWord] += responsePairDict[userWord][goodResponseWord] * 0.1
|
||||
if i == 1:
|
||||
pairPossibilities[goodResponseWord] += responsePairDict[userWord][goodResponseWord] * 2 #first word? try to respond
|
||||
else:
|
||||
pairPossibilities[goodResponseWord] += responsePairDict[userWord][goodResponseWord] * 0.1
|
||||
#Increase score for trairs:
|
||||
if i > 1: #we can only compare trairs if we have at least two words already
|
||||
if chain[-2] in wordTrairDict:
|
||||
|
||||
Reference in New Issue
Block a user