From 1c495002636a49e37021a8cfc7ac5d27b551014c Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 19 Apr 2003 21:23:05 +0000 Subject: [PATCH] Added strtranslate, strupper, and strlower. --- plugins/Utilities.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/plugins/Utilities.py b/plugins/Utilities.py index 39877ee0e..ce53d2748 100644 --- a/plugins/Utilities.py +++ b/plugins/Utilities.py @@ -31,20 +31,20 @@ """ Various utility commands, mostly useful for manipulating nested commands. - -Commands include: - strjoin - strconcat """ from baseplugin import * -import re +import string import utils import privmsgs import callbacks +def configure(onStart, afterConnect, advanced): + from questions import expect, anything, yn + onStart.append('load Utilities') + class Utilities(callbacks.Privmsg): def strjoin(self, irc, msg, args): " " @@ -52,6 +52,30 @@ class Utilities(callbacks.Privmsg): args = flatten(map(callbacks.tokenize, args)) irc.reply(msg, sep.join(args)) + def strtranslate(self, irc, msg, args): + """ + + Replaces with in + . The first and second arguments must necessarily be the same + length. + """ + (bad, good, text) = privmsgs.getArgs(args, needed=3) + irc.reply(msg, text.translate(string.maketrans(bad, good))) + + def strupper(self, irc, msg, args): + """ + + Returns uppercased. + """ + irc.reply(msg, privmsgs.getArgs(args).upper()) + + def strlower(self, irc, msg, args): + """ + + Returns lowercased. + """ + irc.reply(msg, privmsgs.getArgs(args).lower()) + def repr(self, irc, msg, args): """