Made new utility plugin with hash, length and other text formatting commands

This commit is contained in:
Luke Rogers 2013-10-01 03:26:40 +13:00
parent a16b1776f8
commit 52b14b367a
4 changed files with 42 additions and 22 deletions

View file

@ -35,9 +35,3 @@ def decypher(inp):
passwd = inp.split(" ")[0]
inp = " ".join(inp.split(" ")[1:])
return decode(passwd,inp)
@hook.command
def rot13(inp):
"""rot13 <string> -- Encode <string> with rot13."""
return inp.encode('rot13')

View file

@ -1,9 +0,0 @@
import hashlib
from util import hook
@hook.command
def hash(inp):
"""hash <text> -- Returns hashes of <text>."""
return ', '.join(x + ": " + getattr(hashlib, x)(inp).hexdigest()
for x in ['md5', 'sha1', 'sha256'])

View file

@ -1,7 +0,0 @@
from util import hook
@hook.command
def length(inp):
"""length <message> -- gets the length of <message>"""
return "The length of that message is {} characters.".format(len(inp))

42
plugins/utility.py Normal file
View file

@ -0,0 +1,42 @@
from util import hook
import hashlib
# basic text tools
@hook.command
def upper(inp):
"""upper <string> -- Convert string to uppercase."""
return inp.upper()
@hook.command
def lower(inp):
"""lower <string> -- Convert string to lowercase."""
return inp.lower()
@hook.command
def titlecase(inp):
"""title <string> -- Convert string to title case."""
return inp.title()
# encoding
@hook.command
def rot13(inp):
"""rot13 <string> -- Encode <string> with rot13."""
return inp.encode('rot13')
# length
@hook.command
def length(inp):
"""length <string> -- gets the length of <string>"""
return "The length of that string is {} characters.".format(len(inp))
# hashing
@hook.command
def hash(inp):
"""hash <string> -- Returns hashes of <string>."""
return ', '.join(x + ": " + getattr(hashlib, x)(inp).hexdigest()
for x in ['md5', 'sha1', 'sha256'])