Skip to content

Commit

Permalink
Ignoring case when adding programming languages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Konard committed Jan 29, 2020
1 parent 368fa62 commit 10c5c03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions python/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def message_new(self, event):
self.delete_message(event)
elif regex.findall(patterns.ADD_PROGRAMMING_LANGUAGE, message):
language = regex.match(patterns.ADD_PROGRAMMING_LANGUAGE, message).group('language')
language = self.get_default_programming_language(language)
if not language:
return
if "programming_languages" not in user.obj:
user.programming_languages = []
base.save(user)
Expand Down Expand Up @@ -173,6 +176,13 @@ def get_programming_languages_string(self, user):
else:
return ""

def get_default_programming_language(self, language):
for default_programming_language in default_programming_languages:
default_programming_language = default_programming_language.replace('\\', '')
if default_programming_language.lower() == language.lower():
return default_programming_language
return None

def contains_string(self, strings, matchedString, ignoreCase):
if ignoreCase:
for string in strings:
Expand Down
2 changes: 1 addition & 1 deletion python/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
APPLY_RATING = compile(r"\A\s*(?P<operator>\+|\-)(?P<amount>[0-9]*)\s*\Z")
TOP = compile(r"\A\s*(топ|top)\s*\Z", IGNORECASE)
TOP_LANGUAGES = compile(r"\A\s*(топ|top)\s*(?P<languages>(" + default_languages + r")(\s+(" + default_languages + r"))*)\s*\Z", IGNORECASE)
ADD_PROGRAMMING_LANGUAGE = compile(r"\A\s*\+=\s*(?P<language>" + default_languages + r")\s*\Z")
ADD_PROGRAMMING_LANGUAGE = compile(r"\A\s*\+=\s*(?P<language>" + default_languages + r")\s*\Z", IGNORECASE)

0 comments on commit 10c5c03

Please sign in to comment.