less spam + minor improvements
This commit is contained in:
+8
-4
@@ -29,7 +29,7 @@ class Chatbot(object):
|
|||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
return #ignore your own messages, Stroop
|
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":
|
if message.content.lower() == "nihao":
|
||||||
yield from message.channel.send("kankerlauw")
|
yield from message.channel.send("kankerlauw")
|
||||||
return
|
return
|
||||||
@@ -40,9 +40,9 @@ class Chatbot(object):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
a = random.randint(0,999)
|
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)
|
yield from self.respondToMessage(message)
|
||||||
elif a < 20: #all other channels
|
elif a < 10: #all other channels
|
||||||
yield from self.respondToMessage(message)
|
yield from self.respondToMessage(message)
|
||||||
|
|
||||||
#process commands:
|
#process commands:
|
||||||
@@ -105,7 +105,7 @@ class Chatbot(object):
|
|||||||
return newPairDict, newTrairDict;
|
return newPairDict, newTrairDict;
|
||||||
|
|
||||||
#Learn to respond to messages
|
#Learn to respond to messages
|
||||||
#Returns ???
|
#Returns a new dict with response pairs
|
||||||
def learnResponse(self, wordDictResp, message1: str, message2: str):
|
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",
|
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",
|
"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:
|
#Go through the chain:
|
||||||
for i in range(1, MAX_N_WORDS):
|
for i in range(1, MAX_N_WORDS):
|
||||||
|
|
||||||
if chain[-1] == self.END_OF_MESSAGE:
|
if chain[-1] == self.END_OF_MESSAGE:
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -261,6 +262,9 @@ class Chatbot(object):
|
|||||||
if userWord in responsePairDict:
|
if userWord in responsePairDict:
|
||||||
for goodResponseWord in responsePairDict[userWord]:
|
for goodResponseWord in responsePairDict[userWord]:
|
||||||
if goodResponseWord in pairPossibilities.keys():
|
if goodResponseWord in pairPossibilities.keys():
|
||||||
|
if i == 1:
|
||||||
|
pairPossibilities[goodResponseWord] += responsePairDict[userWord][goodResponseWord] * 2 #first word? try to respond
|
||||||
|
else:
|
||||||
pairPossibilities[goodResponseWord] += responsePairDict[userWord][goodResponseWord] * 0.1
|
pairPossibilities[goodResponseWord] += responsePairDict[userWord][goodResponseWord] * 0.1
|
||||||
#Increase score for trairs:
|
#Increase score for trairs:
|
||||||
if i > 1: #we can only compare trairs if we have at least two words already
|
if i > 1: #we can only compare trairs if we have at least two words already
|
||||||
|
|||||||
Reference in New Issue
Block a user