mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-27 05:21:10 -05:00
Add some more semi-useless things to SupyMisc
This commit is contained in:
parent
72afa143c6
commit
158edecfe9
@ -129,6 +129,43 @@ class SupyMisc(callbacks.Plugin):
|
|||||||
nick = msg.nick
|
nick = msg.nick
|
||||||
irc.reply(ircutils.hostFromHostmask(irc.state.nickToHostmask(nick)))
|
irc.reply(ircutils.hostFromHostmask(irc.state.nickToHostmask(nick)))
|
||||||
gethost = wrap(gethost, [(additional('nick'))])
|
gethost = wrap(gethost, [(additional('nick'))])
|
||||||
|
|
||||||
|
### Access to python built-in functions
|
||||||
|
def int2bin(self, irc, msg, args, num):
|
||||||
|
"""<int>
|
||||||
|
Returns the binary representation of <int>.
|
||||||
|
"""
|
||||||
|
out = bin(int(num))
|
||||||
|
irc.reply(out)
|
||||||
|
int2bin = wrap(int2bin, ['int'])
|
||||||
|
|
||||||
|
def int2hex(self, irc, msg, args, num):
|
||||||
|
"""<int>
|
||||||
|
Returns the hexadecimal representation of <int>.
|
||||||
|
"""
|
||||||
|
out = hex(int(num))
|
||||||
|
irc.reply(out)
|
||||||
|
int2hex = wrap(int2hex, ['int'])
|
||||||
|
|
||||||
|
def bin2int(self, irc, msg, args, num):
|
||||||
|
"""<binary>
|
||||||
|
Returns the decimal representation of <binary>.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
irc.reply(int(num, base=2))
|
||||||
|
except ValueError:
|
||||||
|
irc.error("Invalid input: {}.".format(num))
|
||||||
|
bin2int = wrap(bin2int, ['somethingWithoutSpaces'])
|
||||||
|
|
||||||
|
def hex2int(self, irc, msg, args, num):
|
||||||
|
"""<hex>
|
||||||
|
Returns the decimal representation of <hex>.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
irc.reply(int(num, base=16))
|
||||||
|
except ValueError:
|
||||||
|
irc.error("Invalid input: {}.".format(num))
|
||||||
|
hex2int = wrap(hex2int, ['somethingWithoutSpaces'])
|
||||||
|
|
||||||
Class = SupyMisc
|
Class = SupyMisc
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user