Browse Source

[rutils] Remove a few commands

master
sfan5 5 years ago
parent
commit
96770e471e
  1. 5
      COMMANDS.md
  2. 29
      rutils.py

5
COMMANDS.md

@ -37,11 +37,6 @@ Required arguments are enclosed in { and }, optional arguments are enclosed in [
<tr> <td>!rev {string}</td> <td>Reverse String</td> <td>Anyone</td> </tr>
<tr> <td>!b64e {string}</td> <td>Base64-encode a string</td> <td>Anyone</td> </tr>
<tr> <td>!b64d {string}</td> <td>Base64-decode a string</td> <td>Anyone</td> </tr>
<tr> <td>!b32e {string}</td> <td>Base32-encode a string</td> <td>Anyone</td> </tr>
<tr> <td>!b32d {string}</td> <td>Base32-decode a string</td> <td>Anyone</td> </tr>
<tr> <td>!b16e {string}</td> <td>Base16-encode a string</td> <td>Anyone</td> </tr>
<tr> <td>!b16d {string}</td> <td>Base16-decode a string</td> <td>Anyone</td> </tr>
<tr> <td>!hash {hashtype} {string}</td> <td>Hash a string, supports various hash functions</td> <td>Anyone</td> </tr>
<tr> <td>!rand [min] {max}</td> <td>Says a random number between(incl.) min and max</td> <td>Anyone</td> </tr>
<tr> <td><b>seen.py</b></td> <td></td> <td></td> </tr>
<tr> <td>!seen {person}</td> <td>Output when person was last seen</td> <td>Anyone</td> </tr>

29
rutils.py

@ -4,7 +4,8 @@ rutils.py - Phenny Utility Module
Copyright 2012, sfan5
Licensed under GNU General Public License v2.0
"""
import base64, binascii, re, random, time, multiprocessing, hashlib
import base64
import random
def rs(s):
return repr(s)[1:-1]
@ -37,32 +38,6 @@ def make_thing(cmds, func):
b64e = make_thing(['b64e','base64encode'], base64.b64encode)
b64d = make_thing(['b64d','base64decode'], base64.b64decode)
b32e = make_thing(['b32e','base32encode'], base64.b32encode)
b32d = make_thing(['b32d','base32decode'], base64.b32decode)
b16e = make_thing(['b16e','base16encode'], base64.b16encode)
b16d = make_thing(['b16d','base16decode'], base64.b16decode)
def hash_(phenny, input):
if not input.group(2):
return phenny.reply("Usage: hash <hash function> <text> | Get available hash funcs with ?")
hashfuncs = {
'md5': hashlib.md5,
'sha1': hashlib.sha1,
'sha224': hashlib.sha224,
'sha256': hashlib.sha256,
'sha384': hashlib.sha384,
'sha512': hashlib.sha512,
}
if input.group(2).strip() == '?':
return phenny.reply('Supported hash functions: ' + ', '.join(hashfuncs.keys()))
hashf = input.group(2).split(' ')[0]
if not hashf in hashfuncs:
return phenny.reply('Unknown hash functions, supported: ' + ', '.join(hashfuncs.keys()))
data = ' '.join(input.group(2).split(' ')[1:]).encode('utf-8')
phenny.say(hashfuncs[hashf](data).hexdigest())
hash_.commands = ['hash']
hash_.priority = 'low'
def rand(phenny, input):
"""Returns a random number"""

Loading…
Cancel
Save