Significantly reduces the number of words that are spotted by the bot (currently 436 -> 63)
This commit is contained in:
parent
61cdb2568c
commit
5ca9dd6eda
1 changed files with 9 additions and 16 deletions
25
main.py
25
main.py
|
@ -126,20 +126,12 @@ def permute(array: list) -> list:
|
||||||
quoiListe = []
|
quoiListe = []
|
||||||
|
|
||||||
for text in array: # all element of the list
|
for text in array: # all element of the list
|
||||||
n = len(text)
|
if text.lower() not in quoiListe:
|
||||||
mx = 1 << n # Number of permutations is 2^n
|
quoiListe.append(text.lower())
|
||||||
text = text.lower() # Converting string to lower case
|
if text.upper() not in quoiListe:
|
||||||
|
quoiListe.append(text.upper())
|
||||||
for i in range(mx): # Using all subsequences and permuting them
|
if text.capitalize() not in quoiListe:
|
||||||
combination = [k for k in text]
|
quoiListe.append(text.capitalize())
|
||||||
for j in range(n):
|
|
||||||
if (((i >> j) & 1) == 1): # If j-th bit is set, we convert it to upper case
|
|
||||||
combination[j] = text[j].upper()
|
|
||||||
|
|
||||||
temp = ""
|
|
||||||
for i in combination:
|
|
||||||
temp += i
|
|
||||||
quoiListe.append(temp)
|
|
||||||
return quoiListe
|
return quoiListe
|
||||||
|
|
||||||
def createBaseTrigger(lists) -> list:
|
def createBaseTrigger(lists) -> list:
|
||||||
|
@ -190,10 +182,10 @@ if __name__ == "__main__":
|
||||||
"oui": ["oui", "ui"],
|
"oui": ["oui", "ui"],
|
||||||
"non": ["non", "nn"],
|
"non": ["non", "nn"],
|
||||||
"nan": ["nan"],
|
"nan": ["nan"],
|
||||||
"hein": ["1"], # + ["hein"],
|
"hein": ["hein", "1"],
|
||||||
"ci": ["ci", "si"],
|
"ci": ["ci", "si"],
|
||||||
"con": ["con"],
|
"con": ["con"],
|
||||||
"ok": ["oké", "k"], # + ["ok", "okay"],
|
"ok": ["ok", "okay", "oké", "k"],
|
||||||
"ouais": ["ouais", "oué"],
|
"ouais": ["ouais", "oué"],
|
||||||
"comment": ["comment"],
|
"comment": ["comment"],
|
||||||
"mais": ["mais", "mé"]
|
"mais": ["mais", "mé"]
|
||||||
|
@ -226,6 +218,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
# creation of a list of all the words (upper and lower case)
|
# creation of a list of all the words (upper and lower case)
|
||||||
triggerWords = permute(universalBase)
|
triggerWords = permute(universalBase)
|
||||||
|
print(len(triggerWords))
|
||||||
|
|
||||||
# loading environment variables and launching the bot
|
# loading environment variables and launching the bot
|
||||||
keys = load(["TOKEN", "TOKEN_SECRET", "CONSUMER_KEY", "CONSUMER_SECRET", "PSEUDOS", "VERBOSE"])
|
keys = load(["TOKEN", "TOKEN_SECRET", "CONSUMER_KEY", "CONSUMER_SECRET", "PSEUDOS", "VERBOSE"])
|
||||||
|
|
Reference in a new issue