mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 19:52:54 +01:00
Added strtranslate, strupper, and strlower.
This commit is contained in:
parent
8054a1cf5d
commit
1c49500263
@ -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):
|
||||
"<separator> <strings to join>"
|
||||
@ -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):
|
||||
"""<chars to translate> <chars to replace those with> <text>
|
||||
|
||||
Replaces <chars to translate> with <chars to replace those with> in
|
||||
<text>. 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):
|
||||
"""<text>
|
||||
|
||||
Returns <text> uppercased.
|
||||
"""
|
||||
irc.reply(msg, privmsgs.getArgs(args).upper())
|
||||
|
||||
def strlower(self, irc, msg, args):
|
||||
"""<text>
|
||||
|
||||
Returns <text> lowercased.
|
||||
"""
|
||||
irc.reply(msg, privmsgs.getArgs(args).lower())
|
||||
|
||||
def repr(self, irc, msg, args):
|
||||
"""<text>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user