aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2018-03-02 01:32:16 +0100
committerGravatar Leon Sandøy <[email protected]>2018-03-02 01:32:16 +0100
commitf1ced1804b0355e66ae4a2dd1a5214bd939bb383 (patch)
tree80ebcb779edaf8b20bb04ecce40f999fce298c5e
parentSwitching CI linter from snekchek to flake8 (diff)
Adding annotations and making things more beautiful in __init__.py
-rw-r--r--bot/__init__.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/bot/__init__.py b/bot/__init__.py
index 894a97021..59b0eb2fd 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -2,12 +2,14 @@
import discord.ext.commands.view
-def case_insensitive_skip_string(self, string: str):
- """Our version of the skip_string method from
+def case_insensitive_skip_string(self, string: str) -> bool:
+ """
+ Our version of the skip_string method from
discord.ext.commands.view; used to find
the prefix in a message, but allowing prefix
to ignore case sensitivity
"""
+
strlen = len(string)
if self.buffer.lower()[self.index:self.index + strlen] == string:
self.previous = self.index
@@ -16,22 +18,24 @@ def case_insensitive_skip_string(self, string: str):
return False
-def case_insensitive_get_word(self):
- """Invokes the get_word method from
+def case_insensitive_get_word(self) -> str:
+ """
+ Invokes the get_word method from
discord.ext.commands.view used to find
the bot command part of a message, but
allows the command to ignore case sensitivity
"""
+
word = _get_word(self)
if isinstance(word, str):
return word.lower()
return word
-# save the old methods
+# Save the old methods
_skip_string = discord.ext.commands.view.StringView.skip_string
_get_word = discord.ext.commands.view.StringView.get_word
-# monkey patch them to be case insensitive
+# Monkey patch them to be case insensitive
discord.ext.commands.view.StringView.skip_string = case_insensitive_skip_string
discord.ext.commands.view.StringView.get_word = case_insensitive_get_word