Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Tarkov-Discord-Chatbot/Word Checker
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
50 lines (41 sloc)
1.42 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#old function | |
def oldwordcheck(message): | |
#keyword list | |
procedures = ["price", "info", "stats"] | |
#checks for a match between each word in the message and the keyword list | |
for word in procedures: | |
if word in message: | |
return word | |
return "no procedure" | |
#shiny new checker | |
def NewWordCheck(message): | |
#keyword dictionary | |
keywords = { | |
"price" : ["price", "value", "cost", "rubles"], | |
"info" : ["info", "information", "details", "facts"], | |
"stats" : ["stats", "statistics", "data"] | |
} | |
#loops through each word in the message | |
for searchWord in message.split(): | |
#loops through each key in the dictionary | |
for key, value in keywords.items() : | |
#checks for a match between the message word and either the key or the values associated to it | |
if value.__contains__(searchWord): | |
return key | |
return "no procedure" | |
#temp function for testing purpose | |
def stats(): | |
print("this is the statistics function") | |
#temp function for testing purpose | |
def price(): | |
print("this is the price function") | |
#temp function for testing purpose | |
def info(): | |
print("this is the information function") | |
#temp user message for testing purpose | |
message = "how many roubles does the ak101 cost" | |
procedure = NewWordCheck(message) | |
if procedure == "no procedure": | |
print("error, no function found/nothing to do") | |
else: | |
eval(procedure + "()") |