From c599e9962b3fbef9c49d198cdf98043c790a670d Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 31 Mar 2003 10:08:22 +0000 Subject: [PATCH] Added binary command --- plugins/FunCommands.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/FunCommands.py b/plugins/FunCommands.py index f4b876c4d..26bd62cd9 100644 --- a/plugins/FunCommands.py +++ b/plugins/FunCommands.py @@ -149,10 +149,26 @@ class FunCommands(callbacks.Privmsg): def base(self, irc, msg, args): """ - Converts to base the number + Converts from base the number """ (base, number) = privmsgs.getArgs(args, needed=2) irc.reply(msg, str(long(number, int(base)))) + + def binary(self, irc, msg, args): + """ + + Returns the binary representation of . + """ + 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): "; turn string into a hexstring."