mirror of https://github.com/Mikaela/Limnoria.git
Added binary command
This commit is contained in:
parent
9b5739ca68
commit
c599e9962b
|
@ -149,11 +149,27 @@ class FunCommands(callbacks.Privmsg):
|
||||||
def base(self, irc, msg, args):
|
def base(self, irc, msg, args):
|
||||||
"""<base> <number>
|
"""<base> <number>
|
||||||
|
|
||||||
Converts to base <base> the number <number>
|
Converts from base <base> the number <number>
|
||||||
"""
|
"""
|
||||||
(base, number) = privmsgs.getArgs(args, needed=2)
|
(base, number) = privmsgs.getArgs(args, needed=2)
|
||||||
irc.reply(msg, str(long(number, int(base))))
|
irc.reply(msg, str(long(number, int(base))))
|
||||||
|
|
||||||
|
def binary(self, irc, msg, args):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Returns the binary representation of <text>.
|
||||||
|
"""
|
||||||
|
L = []
|
||||||
|
for c in privmsgs.getArgs(args):
|
||||||
|
i = ord(c)
|
||||||
|
while i:
|
||||||
|
if i & 1:
|
||||||
|
L.append('1')
|
||||||
|
else:
|
||||||
|
L.append('0')
|
||||||
|
i >>= 1
|
||||||
|
irc.reply(msg, ''.join(L))
|
||||||
|
|
||||||
def hexlify(self, irc, msg, args):
|
def hexlify(self, irc, msg, args):
|
||||||
"<text>; turn string into a hexstring."
|
"<text>; turn string into a hexstring."
|
||||||
text = privmsgs.getArgs(args)
|
text = privmsgs.getArgs(args)
|
||||||
|
|
Loading…
Reference in New Issue