示例#1
0
    def testRegexpDefaultString(self):
        v = registry.Regexp('m/foo/', 'help')
        self.assertEqual(v(), re.compile('foo'))

        v = registry.Regexp('', 'help')
        self.assertEqual(v(), None)

        v = registry.Regexp(None, 'help')
        self.assertEqual(v(), None)
示例#2
0
 def testRegexp(self):
     v = registry.Regexp(None, 'help')
     self.assertEqual(v(), None)
     v.set('m/foo/')
     self.assertTrue(v().match('foo'))
     v.set('')
     self.assertEqual(v(), None)
示例#3
0
 def testRegexp(self):
     v = registry.Regexp(None, 'help')
     self.assertEqual(v(), None)
     v.set('m/foo/')
     self.assertTrue(v().match('foo'))
     v.set('')
     self.assertEqual(v(), None)
     self.assertRaises(registry.InvalidRegistryValue, v.setValue,
                       re.compile(r'foo'))
示例#4
0
文件: plugin.py 项目: affix/Fedbot
def registerObserver(name, regexpString='', commandString='', probability=1.0):
    g = conf.registerGlobalValue(
        conf.supybot.plugins.Observer.observers, name,
        registry.Regexp(
            regexpString, """Determines what regexp must
            match for this observer to be executed."""))
    if regexpString:
        g.set(regexpString)  # This is in case it's been registered.
    conf.registerGlobalValue(
        g, 'command',
        registry.String(
            '', """Determines
        what command will be run when this observer is executed."""))
    if commandString:
        g.command.setValue(commandString)
    conf.registerGlobalValue(
        g, 'probability',
        Probability(
            probability, """
        Determines what the probability of executing this observer is if it
        matches."""))
    g.probability.setValue(probability)
    conf.supybot.plugins.Observer.observers().add(name)
    return g
示例#5
0
conf.registerChannelValue(Rweb, 'titleSnarfer',
    registry.Boolean(False, _("""Determines whether the bot will output the
    HTML title of URLs it sees in the channel.""")))
conf.registerChannelValue(Rweb, 'snarferReportIOExceptions',
    registry.Boolean(False, _("""Determines whether the bot will notfiy the user
    about network exceptions like hostnotfound, timeout ....""")))
conf.registerChannelValue(Rweb, 'snarferShowDomain',
    registry.Boolean(True, _("""Determines whether domain names should be
    displayed by the title snarfer.""")))
conf.registerChannelValue(Rweb, 'snarferShowTargetDomain',
    registry.Boolean(False, _("""Determines whether the domain name displayed
    by the snarfer will be the original one (posted on IRC) or the target one
    (got after following redirects, if any).""")))
conf.registerChannelValue(Rweb, 'nonSnarfingRegexp',
    registry.Regexp(None, _("""Determines what URLs matching the given regexp
    will not be snarfed.  Give the empty string if you have no URLs that you'd
    like to exclude from being snarfed.""")))
conf.registerChannelValue(Rweb, 'checkIgnored',
    registry.Boolean(True, _("""Determines whether the title snarfer checks
    if the author of a message is ignored.""")))

conf.registerGlobalValue(Rweb, 'urlWhitelist',
    registry.SpaceSeparatedListOfStrings([], """If set, bot will only fetch data
    from urls in the whitelist, i.e. starting with http://domain/optionalpath/. This will
    apply to all commands that retrieve data from user-supplied URLs,
    including fetch, headers, title, doctype."""))

conf.registerGlobalValue(Rweb, 'timeout',
    registry.NonNegativeInteger(5, """Determines the maximum number of
    seconds the bot will wait for the site to respond, when using a command
    in this plugin other than 'fetch'. If 0, will use socket.defaulttimeout"""))
示例#6
0
    registry.CommaSeparatedListOfStrings([
        "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.60 Safari/537.36",
        "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
        "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko"
    ], _("""Reported user agent when fetching links""")))

# Mime Types
conf.registerGlobalValue(
    SpiffyTitles, 'mimeTypes',
    registry.CommaSeparatedListOfStrings(
        ["text/html"], _("""Acceptable mime types for displaying titles""")))

# Ignored domain pattern
conf.registerChannelValue(
    SpiffyTitles, 'ignoredDomainPattern',
    registry.Regexp("",
                    _("""Domains matching this patterns will be ignored""")))

# Whitelist domain pattern
conf.registerChannelValue(
    SpiffyTitles, 'whitelistDomainPattern',
    registry.Regexp(
        "", _("""Domains not matching this patterns will be ignored""")))

# Channel whitelist
conf.registerGlobalValue(
    SpiffyTitles, 'channelWhitelist',
    registry.CommaSeparatedListOfStrings(
        [], _("""Only show titles on these channels, or all if empty""")))

# Channel blacklist
conf.registerGlobalValue(
示例#7
0
文件: config.py 项目: TripSit/tbot
# POSSIBILITY OF SUCH DAMAGE.
###

import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring

_ = PluginInternationalization('URL')


def configure(advanced):
    # This will be called by supybot to configure this module.  advanced is
    # a bool that specifies whether the user identified themself 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('URL', True)


URL = conf.registerPlugin('URL')
conf.registerChannelValue(
    URL, 'nonSnarfingRegexp',
    registry.Regexp(
        None,
        _("""Determines what URLs are not to be snarfed and
    stored in the database for the channel; URLs matching the given regexp will
    not be snarfed.  Give the empty string if you have no URLs that you'd like
    to exclude from being snarfed.""")))

# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
示例#8
0
 def testRegexpSetValue(self):
     v = registry.Regexp(None, 'help')
     self.assertRaises(registry.InvalidRegistryValue,
                       v.setValue, r'foo')
     self.assertRaises(registry.InvalidRegistryValue,
                       v.setValue, re.compile(r'foo'))
示例#9
0
        '', """Determines the channel that the bot will look
    for messages to relay from.  Messages matching
    supybot.plugins.ChannelRelay.regexp will be relayed to the target channel
    specified by supybot.plugins.ChannelRelay.target."""))
conf.registerGlobalValue(
    ChannelRelay, 'target',
    ValidChannelOrNothing(
        '', """Determines the channel that the bot will send
    messages from the other channel.  Messages matching
    supybot.plugins.ChannelRelay.regexp will be relayed to this channel from
    the source channel."""))
conf.registerGlobalValue(
    ChannelRelay, 'regexp',
    registry.Regexp(
        None, """Determines what regular expression
    should be matched against messages to determine whether they should be
    relayed from the source channel to the target channel.  By default, the
    value is m/./, which means that all non-empty messages will be
    relayed."""))
if ChannelRelay.regexp() is None:
    ChannelRelay.regexp.set('m/./')
conf.registerGlobalValue(
    ChannelRelay, 'fancy',
    registry.Boolean(
        True, """Determines whether the bot should relay the
    messages in fancy form (i.e., including the nick of the sender of the
    messages) or non-fancy form (i.e., without the nick of the sender of the
    messages)."""))
conf.registerGlobalValue(
    ChannelRelay, 'prefix',
    registry.String(
        '', """Determines what prefix should be prepended to the
示例#10
0
    registry.Boolean(
        False,
        _("""Determines whether the bot should prefix nicks
    with a hyphen (-) to prevent excess highlights (in PRIVMSGs and actions)."""
          )))
conf.registerChannelValue(
    RelayNext, 'showPrefixes',
    registry.Boolean(
        False,
        _("""Determines whether the bot should status prefixes
    (@, %, +) when relaying.""")))
conf.registerChannelValue(
    RelayNext, 'ignoreRegexp',
    registry.Regexp(
        None,
        _("""If configured, text, part, and quit messages matching this regexp
                            will not be relayed. This may be useful for spam blocking."""
          )))

conf.registerGroup(RelayNext, 'antiflood')
conf.registerChannelValue(
    RelayNext.antiflood, 'enable',
    registry.Boolean(
        False,
        _("""Determines whether flood prevention should be enabled
    for the given channel.""")))
conf.registerChannelValue(
    RelayNext.antiflood, 'seconds',
    registry.PositiveInteger(
        20,
        _("""Determines how many seconds messages should be queued
示例#11
0
    registry.Boolean(
        True,
        _("""Determines whether the bot will strip strings like <XXX> at the beginning of messages."""
          )))
conf.registerChannelValue(
    Cobe, 'stripURL',
    registry.Boolean(
        True,
        _("""Determines whether the bot will strip URLs from messages.""")))
conf.registerChannelValue(
    Cobe, 'ignoreNicks',
    registry.SpaceSeparatedListOfStrings(
        [], _("""A list of nicks to be ignored by the bot""")))
conf.registerChannelValue(
    Cobe, 'ignorePattern',
    registry.Regexp("",
                    _("""Mesages matching this pattern will be ignored.""")))
conf.registerChannelValue(
    Cobe, 'stripPattern',
    registry.Regexp("", _("""Text matching this pattern will be stripped.""")))
conf.registerChannelValue(
    Cobe, 'stripNicks',
    registry.Boolean(
        False,
        _("""Strip all nicks, including the bots, when learning? This replaces a nick with the keyword MAGIC_NICK to use for random highlighting."""
          )))
conf.registerChannelValue(
    Cobe, 'probability',
    registry.NonNegativeInteger(
        0, _("""Determines the percent of messages the bot will answer.""")))
conf.registerChannelValue(
    Cobe, 'probabilityWhenAddressed',
示例#12
0
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

import supybot.conf as conf
import supybot.registry as registry


def configure(advanced):
    conf.registerPlugin('DebianDevelChanges', True)


DebianDevelChanges = conf.registerPlugin('DebianDevelChanges')

conf.registerChannelValue(
    DebianDevelChanges, 'package_regex',
    registry.Regexp(
        '',
        "Determines which package announcements should be printed to the channel",
    ))

conf.registerChannelValue(
    DebianDevelChanges, 'maintainer_regex',
    registry.Regexp(
        '',
        "Determines which maintainer announcements should be printed to the channel",
    ))

conf.registerChannelValue(
    DebianDevelChanges, 'distribution_regex',
    registry.Regexp(
        '',
        "Determines which distribution announcements should be printed to the channel",
    ))
示例#13
0
    registry.CommaSeparatedListOfStrings([
        "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.60 Safari/537.36",
        "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
        "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko"
    ], _("""Reported user agent when fetching links""")))

# Mime Types
conf.registerGlobalValue(
    SpiffyTitles, 'mimeTypes',
    registry.CommaSeparatedListOfStrings(
        ["text/html"], _("""Acceptable mime types for displaying titles""")))

# Ignored domain pattern
conf.registerGlobalValue(
    SpiffyTitles, 'ignoredDomainPattern',
    registry.Regexp("",
                    _("""Domains matching this patterns will be ignored""")))

# Channel whitelist
conf.registerGlobalValue(
    SpiffyTitles, 'channelWhitelist',
    registry.CommaSeparatedListOfStrings(
        [], _("""Only show titles on these channels, or all if empty""")))

# Channel blacklist
conf.registerGlobalValue(
    SpiffyTitles, 'channelBlacklist',
    registry.CommaSeparatedListOfStrings(
        [], _("""Never show titles on these channels""")))

# imgur API
conf.registerGlobalValue(SpiffyTitles, 'imgurClientID',