diff options
| author | 2016-04-20 13:52:23 +0100 | |
|---|---|---|
| committer | 2016-04-20 13:52:23 +0100 | |
| commit | c5c53bc48198d5dc874649e88a4b436ddd207dc7 (patch) | |
| tree | d5d9a9262c77f3b530de096b796baf79cd9e4997 | |
| parent | fixed a broken usage of the timer system. (functions are not json-able!) (diff) | |
added hash.py. why not.
| -rw-r--r-- | modules/hash.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/hash.py b/modules/hash.py new file mode 100644 index 00000000..86657bd1 --- /dev/null +++ b/modules/hash.py @@ -0,0 +1,18 @@ +import hashlib + +class Module(object): + def __init__(self, bot): + self.bot = bot + bot.events.on("received").on("command").on("hash" + ).hook(self.hash, min_args=2, help="Hash a string", + usage="<algo> <string>") + + def hash(self, event): + algorithm = event["args_split"][0].lower() + if algorithm in hashlib.algorithms_available: + phrase = " ".join(event["args_split"][1:]) + cipher_text = hashlib.new(algorithm, phrase.encode("utf8") + ).hexdigest() + event["stdout"].write("%s -> %s" % (phrase, cipher_text)) + else: + event["stderr"].write("Unknown algorithm provided") |
