From 0ed743bb8eca6ed00bf14055f358f40ac65f2756 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 29 Jan 2022 02:47:58 +0100 Subject: [PATCH] Format: allow empty substrings in 'replace' This allows for easy substring removal without having to use regex. --- plugins/Format/plugin.py | 2 +- plugins/Format/test.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/Format/plugin.py b/plugins/Format/plugin.py index 232f0b2d3..2c39dcadd 100644 --- a/plugins/Format/plugin.py +++ b/plugins/Format/plugin.py @@ -109,7 +109,7 @@ class Format(callbacks.Plugin): with in . """ irc.reply(text.replace(bad, good)) - replace = wrap(replace, ['something', 'something', 'text']) + replace = wrap(replace, ['anything', 'anything', 'text']) def upper(self, irc, msg, args, text): """ diff --git a/plugins/Format/test.py b/plugins/Format/test.py index a189d408f..f331013a4 100644 --- a/plugins/Format/test.py +++ b/plugins/Format/test.py @@ -56,9 +56,12 @@ class FormatTestCase(PluginTestCase): def testTranslate(self): self.assertResponse('translate 123 456 1234567890', '4564567890') self.assertError('translate 123 1234 123125151') - + def testReplace(self): self.assertResponse('replace # %23 bla#foo', 'bla%23foo') + self.assertResponse('replace "/" "" t/e/s/t', 'test') + self.assertResponse('replace "" :) hello', ':)h:)e:)l:)l:)o:)') + self.assertResponse('replace de "d e" a b c de f ', 'a b c d e f') def testUpper(self): self.assertResponse('upper foo', 'FOO')