fixes
This commit is contained in:
parent
839871f636
commit
dd50cb4a36
2 changed files with 35 additions and 3 deletions
|
@ -72,6 +72,8 @@ def reddit(inp):
|
||||||
else:
|
else:
|
||||||
item["warning"] = ""
|
item["warning"] = ""
|
||||||
|
|
||||||
|
if not item["subreddit"]:
|
||||||
|
item["subreddit"] = subreddit
|
||||||
|
|
||||||
return u'\x02{title} : {subreddit}\x02 - posted by \x02{author}\x02' \
|
return u'\x02{title} : {subreddit}\x02 - posted by \x02{author}\x02' \
|
||||||
' {timesince} ago - {ups} upvotes, {downs} downvotes -' \
|
' {timesince} ago - {ups} upvotes, {downs} downvotes -' \
|
||||||
|
|
|
@ -62,15 +62,45 @@ def rot13(inp):
|
||||||
"""rot13 <string> -- Encode <string> with rot13."""
|
"""rot13 <string> -- Encode <string> with rot13."""
|
||||||
return inp.encode('rot13')
|
return inp.encode('rot13')
|
||||||
|
|
||||||
|
@hook.command
|
||||||
|
def base64(inp):
|
||||||
|
"""base64 <string> -- Encode <string> with base64."""
|
||||||
|
return inp.encode('base64')
|
||||||
|
|
||||||
|
@hook.command
|
||||||
|
def unbase64(inp):
|
||||||
|
"""unbase64 <string> -- Decode <string> with base64."""
|
||||||
|
return inp.decode('base64')
|
||||||
|
|
||||||
|
@hook.command
|
||||||
|
def checkbase64(inp):
|
||||||
|
try:
|
||||||
|
decoded = inp.decode('base64')
|
||||||
|
recoded = decoded.encode('base64').strip()
|
||||||
|
is_base64 = recoded == inp
|
||||||
|
except:
|
||||||
|
is_base64 = False
|
||||||
|
|
||||||
|
if is_base64:
|
||||||
|
return '"{}" is base64 encoded'.format(recoded)
|
||||||
|
else:
|
||||||
|
return '"{}" is not base64 encoded'.format(inp)
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def unescape(inp):
|
def unescape(inp):
|
||||||
"""unescape <string> -- Unescapes <string>."""
|
"""unescape <string> -- Unescapes <string>."""
|
||||||
return inp.decode('unicode-escape')
|
try:
|
||||||
|
return inp.decode('unicode-escape')
|
||||||
|
except Exception as e:
|
||||||
|
return "Error: {}".format(e)
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def escape(inp):
|
def escape(inp):
|
||||||
"""escape <string> -- escapes <string>."""
|
"""escape <string> -- Escapes <string>."""
|
||||||
return inp.encode('unicode-escape')
|
try:
|
||||||
|
return inp.encode('unicode-escape')
|
||||||
|
except Exception as e:
|
||||||
|
return "Error: {}".format(e)
|
||||||
|
|
||||||
# length
|
# length
|
||||||
|
|
||||||
|
|
Reference in a new issue