Exemple #1
0
 def setUpClass(cls):
     from b3.fake import fakeConsole
     cls.conf = XmlConfigParser()
     cls.conf.setXml(r"""
         <configuration plugin="censor">
             <settings name="settings">
                 <set name="max_level">40</set>
                 <!-- ignore bad words that have equal or less characters: -->
                 <set name="ignore_length">3</set>
             </settings>
             <badwords>
                 <penalty type="warning" reasonkeyword="default_reason"/>
                 <badword name="foo" lang="en">
                     <regexp>\bf[o0]{2}\b</regexp>
                 </badword>
             </badwords>
             <badnames>
                 <penalty type="warning" reasonkeyword="badname"/>
                 <badname name="c**t">
                     <word>c**t</word>
                 </badname>
             </badnames>
         </configuration>
     """)
     cls.p = CensorPlugin(fakeConsole, cls.conf)
     cls.p.onLoadConfig()
     cls.p.onStartup()
Exemple #2
0
 def init_plugin(self, config_content):
     self.conf = XmlConfigParser()
     self.conf.setXml(config_content)
     self.p = CensorPlugin(self.console, self.conf)
     self.log.setLevel(logging.DEBUG)
     self.log.info(
         "============================= Censor plugin: loading config ============================"
     )
     self.p.onLoadConfig()
     self.log.info(
         "============================= Censor plugin: starting  ================================="
     )
     self.p.onStartup()
Exemple #3
0
    def setUp(self):
        # Timer needs to be patched or the Censor plugin would schedule a 2nd check one minute after
        # penalizing a player.
        self.timer_patcher = patch('threading.Timer')
        self.timer_patcher.start()

        super(CensorTestCase, self).setUp()
        self.conf = XmlConfigParser()
        self.conf.setXml(r"""
            <configuration plugin="censor">
                <badwords>
                    <penalty type="warning" reasonkeyword="racist"/>
                </badwords>
                <badnames>
                    <penalty type="warning" reasonkeyword="badname"/>
                </badnames>
            </configuration>
        """)
        self.p = CensorPlugin(b3.console, self.conf)
        self.p.onLoadConfig()