def setup_config(OriginalConfig): # Set all string variables in the default Config class as supybot # registry variables. for attrname in dir(OriginalConfig): # Don't configure attributs starting with '_' if attrname[0] == '_': continue attr = getattr(OriginalConfig, attrname) # Don't configure attributes that aren't strings. if isinstance(attr, str): attr = attr.replace('\n', '\\n') # For a global value: conf.registerGlobalValue and remove the # channel= option from registryValue call above. conf.registerChannelValue(MeetBotConfigGroup, attrname, registry.NormalizedString(attr, "")) settable_attributes.append(attrname) if isinstance(attr, bool): conf.registerChannelValue(MeetBotConfigGroup, attrname, registry.Boolean(attr, "")) settable_attributes.append(attrname) # writer_map conf.registerChannelValue( MeetBotConfigGroup, 'writer_map', WriterMap(OriginalConfig.writer_map, "") ) settable_attributes.append('writer_map')
def testNormalizedString(self): v = registry.NormalizedString("""foo bar baz biff """, 'help') self.assertEqual(v(), 'foo bar baz biff') v.setValue('foo bar baz') self.assertEqual(v(), 'foo bar baz') v.set('"foo bar baz"') self.assertEqual(v(), 'foo bar baz')
registry.String( '[CENSORED]', _("""Determines what word will replace bad words if the replacement method is 'simple'."""))) conf.registerGlobalValue( BadWords, 'stripFormatting', registry.Boolean( True, _("""Determines whether the bot will strip formatting characters from messages before it checks them for bad words. If this is False, it will be relatively trivial to circumvent this plugin's filtering. If it's True, however, it will interact poorly with other plugins that do coloring or bolding of text."""))) conf.registerChannelValue( BadWords, 'kick', registry.Boolean( False, _("""Determines whether the bot will kick people with a warning when they use bad words."""))) conf.registerChannelValue( BadWords.kick, 'message', registry.NormalizedString( _("""You have been kicked for using a word prohibited in the presence of this bot. Please use more appropriate language in the future."""), _("""Determines the kick message used by the bot when kicking users for saying bad words."""))) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
TriviaTime = conf.registerPlugin('TriviaTime') conf.registerGroup(TriviaTime, 'kaos') conf.registerGroup(TriviaTime, 'admin') conf.registerGroup(TriviaTime, 'questions') conf.registerGroup(TriviaTime, 'general') conf.registerGroup(TriviaTime, 'commands') conf.registerGroup(TriviaTime, 'voice') conf.registerGroup(TriviaTime, 'skip') # CONFIGURATION # file locations for database and question conf.registerChannelValue( TriviaTime.admin, 'sqlitedb', registry.NormalizedString("""plugins/TriviaTime/storage/db/trivia.db""", """Location of sqlite database file""")) conf.registerChannelValue( TriviaTime.admin, 'quizfile', registry.NormalizedString("""plugins/TriviaTime/storage/samplequestions""", """Location of question file""")) # timeout, number of hints, values conf.registerChannelValue( TriviaTime.commands, 'extraHint', registry.NormalizedString(""".""", """The command to show alternative hints""")) conf.registerChannelValue( TriviaTime.commands, 'showHintCommandKAOS', registry.NormalizedString(
# This will be called by supybot to configure this module. advanced is # a bool that specifies whether the user identified himself as an advanced # user or not. You should effect your configuration by manipulating the # registry as appropriate. from supybot.questions import expect, anything, something, yn conf.registerPlugin('RootWarner', True) RootWarner = conf.registerPlugin('RootWarner') conf.registerChannelValue( RootWarner, 'warn', registry.Boolean( True, """Determines whether the bot will warn people who join the channel with an ident of 'root' or '~root'.""")) conf.registerChannelValue( RootWarner, 'warning', registry.NormalizedString( """Don't IRC as root -- it's very possible that there's a security flaw latent in your IRC client (remember the BitchX format string vulnerabilities of days past?) and if you're IRCing as root, your entire box could be compromised.""", """Determines the message that is to be sent to users joining the channel with an ident of 'root' or '~root'. """)) conf.registerChannelValue( RootWarner, 'kick', registry.Boolean( False, """Determines whether the bot will kick people who join the channel with an ident of 'root' or '~root'.""")) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
MCStatus.service, 'prefix', registry.String( '', _("""This text is prepended to each service's name."""))) conf.registerChannelValue( MCStatus.service, 'suffix', registry.StringWithSpaceOnRight( ':', _("""This text is appended to each service's name, followed by a space until I find a better way."""))) conf.registerGroup(MCStatus, 'status') conf.registerChannelValue( MCStatus.status, 'online', registry.NormalizedString( '\x0309ONLINE\x03', _("""This text is displayed when a service is online"""))) conf.registerChannelValue( MCStatus.status, 'offline', registry.NormalizedString( '\x0304OFFLINE\x03', _("""This text is displayed when a service is offline."""))) # vim: ts=4 sw=4 sts=4 et tw=79
# file locations for database and question conf.registerChannelValue( TriviaTime.admin, 'db', registry.String("""plugins/TriviaTime/storage/db/trivia.db""", """Location of sqlite database file""")) conf.registerChannelValue( TriviaTime.admin, 'file', registry.String( """plugins/TriviaTime/storage/questions""", """Location of question file. Reload the plugin if changed.""")) # timeout, number of hints, values conf.registerChannelValue( TriviaTime.commands, 'extraHint', registry.NormalizedString( """.""", """The command to show extra hints and remaining KAOS""")) conf.registerChannelValue( TriviaTime.general, 'logGames', registry.Boolean(True, """Log changes to questions and games""")) conf.registerChannelValue( TriviaTime.general, 'globalStats', registry.Boolean(False, """Stats are global across all channels""")) conf.registerChannelValue( TriviaTime.hints, 'extraHintTime', registry.Integer( 90, """Number of seconds a user must wait between uses of the extra hint command.""" ))
the beginning.""")) registerChannelValue( supybot.reply.whenAddressedBy, 'nicks', registry.SpaceSeparatedSetOfStrings([], """Determines what extra nicks the bot will always respond to when addressed by, even if its current nick is something else.""")) ### # Replies ### registerGroup(supybot, 'replies') registerChannelValue( supybot.replies, 'success', registry.NormalizedString( """The operation succeeded.""", """Determines what message the bot replies with when a command succeeded. If this configuration variable is empty, no success message will be sent.""")) registerChannelValue( supybot.replies, 'error', registry.NormalizedString( """An error has occurred and has been logged. Please contact this bot's administrator for more information.""", """ Determines what error message the bot gives when it wants to be ambiguous.""")) registerChannelValue( supybot.replies, 'incorrectAuthentication', registry.NormalizedString( """Your hostmask doesn't match or your password is wrong.""", """Determines what message the bot replies with when someone
# Config groups conf.registerGroup(TriviaTime, 'kaos') conf.registerGroup(TriviaTime, 'admin') conf.registerGroup(TriviaTime, 'questions') conf.registerGroup(TriviaTime, 'general') conf.registerGroup(TriviaTime, 'commands') conf.registerGroup(TriviaTime, 'voice') conf.registerGroup(TriviaTime, 'skip') conf.registerGroup(TriviaTime, 'hints') # CONFIGURATION # file locations for database and question conf.registerChannelValue( TriviaTime.admin, 'db', registry.NormalizedString("""plugins/TriviaTime/storage/db/trivia.db""", """Location of sqlite database file""")) conf.registerChannelValue( TriviaTime.admin, 'file', registry.NormalizedString( """plugins/TriviaTime/storage/questions""", """Location of question file. Reload the plugin if changed.""")) # timeout, number of hints, values conf.registerChannelValue( TriviaTime.commands, 'extraHint', registry.NormalizedString( """~""", """The command to show extra hints and remaining KAOS""")) conf.registerChannelValue( TriviaTime.general, 'logGames',