add rare trigger
This commit is contained in:
parent
58f7990c14
commit
5e87ac7aec
1 changed files with 21 additions and 1 deletions
22
main.py
22
main.py
|
@ -121,7 +121,14 @@ class Listener(Stream):
|
|||
# Check if the last word found is a supported word
|
||||
if lastWord in universalBase:
|
||||
answer = None
|
||||
# Fetch an adequate response
|
||||
|
||||
# Check repetition
|
||||
repetition = findall(r"di(\S+)", lastWord)
|
||||
if(len(repetition) > 0):
|
||||
# We need to repeat something...
|
||||
answer = repeater(repetition[0])
|
||||
|
||||
# Fetch an other adequate (better) response
|
||||
for mot in base.items():
|
||||
if lastWord in mot[1]:
|
||||
# Handle specific case
|
||||
|
@ -132,6 +139,7 @@ class Listener(Stream):
|
|||
else:
|
||||
answer = answers[mot[0]][1] # soir
|
||||
else:
|
||||
# Normal answer
|
||||
answer = answers[mot[0]]
|
||||
if answer == None:
|
||||
if keys["VERBOSE"]:
|
||||
|
@ -172,6 +180,18 @@ class Listener(Stream):
|
|||
print("\n")
|
||||
return False
|
||||
|
||||
def repeater(word: str) -> str:
|
||||
"""Formating a word who need to be repeated"""
|
||||
# Remove first letter if the first letter is a "S" or a "T"
|
||||
# Explanation: Trigger word for the repeater is "di" and sometimes it is
|
||||
# "dis", sometimes its "dit", that's why we need to remove this 2 letters
|
||||
# from the final answer
|
||||
if word[0] == 's' or word[0] == 't':
|
||||
word = word[1:]
|
||||
|
||||
# Random format from the base answer
|
||||
return createBaseAnswers(word)
|
||||
|
||||
def getFriendsID(api: API, users: list[str]) -> list:
|
||||
"""Get all friends of choosen users"""
|
||||
liste = []
|
||||
|
|
Reference in a new issue