Ejemplo n.º 1
0
def configure(advanced):
    # 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 output, expect, anything, something, yn

    output("To use the Acronym Finder, you must have obtained a license key.")
    if yn("Do you have a license key?"):
        key = something("What is it?")
        while len(key) != 36:
            output("That is not a valid Acronym Finder license key.")
            if yn("Are you sure you have a valid Acronym Finder license key?"):
                key = something("What is it?")
            else:
                key = ""
                break
        if key:
            conf.registerPlugin("AcronymFinder", True)
            conf.supybot.plugins.AcronymFinder.licenseKey.setValue(key)
    else:
        output(
            """You'll need to get a key before you can use this plugin.
                  You can apply for a key at http://www.acronymfinder.com/dontknowyet/"""
        )
Ejemplo n.º 2
0
def configure(advanced):
    from supybot.questions import expect, something, yn, output

    def anything(prompt, default=None):
        """Because supybot is pure fail"""
        from supybot.questions import expect
        return expect(prompt, [], default=default)

    Mess = conf.registerPlugin('Mess', True)

    def getDelay():
        output("What should be the minimum number of seconds between mess output?")
        delay = something("Enter an integer greater or equal to 0", default=Mess.delay._default)

        try:
            delay = int(delay)
            if delay < 0:
                raise TypeError
        except TypeError:
            output("%r is not a valid value, it must be an interger greater or equal to 0" % delay)
            return getDelay()
        else:
            return delay

    output("WARNING: This plugin is unmaintained, may have bugs and is potentially offensive to users")
    Mess.enabled.setValue(yn("Enable this plugin for all channels?", default=Mess.enabled._default))
    Mess.offensive.setValue(yn("Enable possibly offensive content?", default=Mess.offensive._default))
    Mess.delay.setValue(getDelay())
Ejemplo n.º 3
0
def configure(advanced):
    # 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
    Jira = conf.registerPlugin('Jira', True)
    server = something("""What is the URL for the Jira instance?""")
    user = something("""What is the username for the Jira user?""")
    password = something("""What is the password for the Jira user?""")
    template = something("""What output template would you like?""",
            default=template)
    lookup = yn("""Do you want to lookup Jira issues once they appear on a channel?""", default=True)
    snarfRegex = something("""What is the prefix for your Jira issue keys?""",
            default="CLB")
    snarfRegex = ''.join((snarfRegex, '-[0-9]+'))
    verifySSL = yn("""Would you like the plugin to verify your Jira instance's
            SSL certificate?""", default=False)
    OAuthConsumerName = something("""What is the consumer name as per the Jira linked applications?""")
    OAuthConsumerKey = something("""What is the consumer secret key as per the Jira linked applications?""")
    OAuthConsumerSSLKey = something("""What is the filename holding the SSL key bound with the Jira trusted cert?""")
    OAuthTokenDatabase = something("""What is the filename holding the yaml structure with OAuth tokens?""")

    Jira.server.setValue(server)
    Jira.user.setValue(user)
    Jira.password.setValue(password)
    Jira.template.setValue(template)
    Jira.lookup.setValue(lookup)
    Jira.snarfRegex.setValue(snarfRegex)
    Jira.verifySSL.setValue(verifySSL)
    Jira.OAuthConsumerName.setValue(OauthConsumerName)
    Jira.OAuthConsumerKey.setValue(OauthConsumerKey)
    Jira.OAuthTokenDatabase.setValue(OauthTokenDatabase)
Ejemplo n.º 4
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Sourceforge', True)
    output("""The Sourceforge plugin has the functionality to watch for URLs
              that match a specific pattern (we call this a snarfer). When
              supybot sees such a URL, he will parse the web page for
              information and reply with the results.""")
    if yn('Do you want this snarfer to be enabled by default?'):
        conf.supybot.plugins.Sourceforge.trackerSnarfer.setValue(True)

    output("""The bugs and rfes commands of the Sourceforge plugin can be set
              to query a default project when no project is specified.  If this
              project is not set, calling either of those commands will display
              the associated help.  With the default project set, calling
              bugs/rfes with no arguments will find the most recent bugs/rfes
              for the default project.""")
    if yn('Do you want to specify a default project?'):
        project = anything('Project name:')
        if project:
            conf.supybot.plugins.Sourceforge.defaultProject.set(project)

    output("""Sourceforge is quite the word to type, and it may get annoying
              typing it all the time because Supybot makes you use the plugin
              name to disambiguate calls to ambiguous commands (i.e., the bug
              command is in this plugin and the Bugzilla plugin; if both are
              loaded, you\'ll have you type "sourceforge bug ..." to get this
              bug command).  You may save some time by making an alias for
              "sourceforge".  We like to make it "sf".""")
Ejemplo n.º 5
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Sourceforge', True)
    output("""The Sourceforge plugin has the functionality to watch for URLs
              that match a specific pattern (we call this a snarfer). When
              supybot sees such a URL, he will parse the web page for
              information and reply with the results.""")
    if yn('Do you want this snarfer to be enabled by default?'):
        conf.supybot.plugins.Sourceforge.trackerSnarfer.setValue(True)

    output("""The bugs and rfes commands of the Sourceforge plugin can be set
              to query a default project when no project is specified.  If this
              project is not set, calling either of those commands will display
              the associated help.  With the default project set, calling
              bugs/rfes with no arguments will find the most recent bugs/rfes
              for the default project.""")
    if yn('Do you want to specify a default project?'):
        project = anything('Project name:')
        if project:
            conf.supybot.plugins.Sourceforge.defaultProject.set(project)

    output("""Sourceforge is quite the word to type, and it may get annoying
              typing it all the time because Supybot makes you use the plugin
              name to disambiguate calls to ambiguous commands (i.e., the bug
              command is in this plugin and the Bugzilla plugin; if both are
              loaded, you\'ll have you type "sourceforge bug ..." to get this
              bug command).  You may save some time by making an alias for
              "sourceforge".  We like to make it "sf".""")
Ejemplo n.º 6
0
def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('Relay', True)
    if yn(_('Would you like to relay between any channels?')):
        channels = anything(_('What channels?  Separated them by spaces.'))
        conf.supybot.plugins.Relay.channels.set(channels)
    if yn(_('Would you like to use color to distinguish between nicks?')):
        conf.supybot.plugins.Relay.color.setValue(True)
    output("""Right now there's no way to configure the actual connection to
    the server.  What you'll need to do when the bot finishes starting up is
    use the 'start' command followed by the 'connect' command.  Use the 'help'
    command to see how these two commands should be used.""")
Ejemplo n.º 7
0
def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('Relay', True)
    if yn(_('Would you like to relay between any channels?')):
        channels = anything(_('What channels?  Separate them by spaces.'))
        conf.supybot.plugins.Relay.channels.set(channels)
    if yn(_('Would you like to use color to distinguish between nicks?')):
        conf.supybot.plugins.Relay.color.setValue(True)
    output("""Right now there's no way to configure the actual connection to
    the server.  What you'll need to do when the bot finishes starting up is
    use the 'start' command followed by the 'connect' command.  Use the 'help'
    command to see how these two commands should be used.""")
Ejemplo n.º 8
0
def configure(advanced):
    from supybot.questions import yn
    conf.registerPlugin('Minecraft', True)

    if yn(_("""Do you want to use list mode instead colorful mode?
             (colorful mode uses color per service, list mode prints
              two list, one with the onlines other with the offlines)"""),
          default=False):
        Minecraft.listMode.setValue(True)

    if not yn(_("""Do you want the plugin banner to be bold?"""),
              default=True):
        Minecraft.boldBanner.setValue(False)
Ejemplo n.º 9
0
def configure(advanced):
    from supybot.questions import yn
    conf.registerPlugin('Minecraft', True)

    if yn(_("""Do you want to use list mode instead colorful mode?
             (colorful mode uses color per service, list mode prints
              two list, one with the onlines other with the offlines)"""),
          default=False):
        Minecraft.listMode.setValue(True)

    if not yn(_("""Do you want the plugin banner to be bold?"""),
              default=True):
        Minecraft.boldBanner.setValue(False)
Ejemplo n.º 10
0
def configure(advanced):
    from supybot.questions import output, yn
    conf.registerPlugin('Google', True)
    output("""The Google plugin has the functionality to watch for URLs
              that match a specific pattern. (We call this a snarfer)
              When supybot sees such a URL, it will parse the web page
              for information and reply with the results.

              Google has two available snarfers: Google Groups link
              snarfing and a google search snarfer.""")
    if yn('Do you want the Google Groups link snarfer enabled by ' 'default?'):
        conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
    if yn('Do you want the Google search snarfer enabled by default?'):
        conf.supybot.plugins.Google.searchSnarfer.setValue(True)
Ejemplo n.º 11
0
def configure(advanced):
    # 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
    assembla = conf.registerPlugin('Assembla', True)
    if yn("Would you like to configure Assembla now?", default=False):
    	key = something("Please enter an API key", '')
    	secret = something("Please enter an API Secret", '')
    	assembla.apiKey.setValue(key)
    	assembla.apiSecret.setValue(Secret)
    if yn('Do you want the Assembla snarfer enabled by default?'):
        conf.supybot.plugins.Google.ticketSnarfer.setValue(True)
Ejemplo n.º 12
0
def configure(advanced):
    from supybot.questions import output, yn
    conf.registerPlugin('Google', True)
    output("""The Google plugin has the functionality to watch for URLs
              that match a specific pattern. (We call this a snarfer)
              When supybot sees such a URL, it will parse the web page
              for information and reply with the results.

              Google has two available snarfers: Google Groups link
              snarfing and a google search snarfer.""")
    if yn('Do you want the Google Groups link snarfer enabled by '
        'default?'):
        conf.supybot.plugins.Google.groupsSnarfer.setValue(True)
    if yn('Do you want the Google search snarfer enabled by default?'):
        conf.supybot.plugins.Google.searchSnarfer.setValue(True)
Ejemplo n.º 13
0
def configure(advanced):
    from supybot.questions import yn
    conf.registerPlugin('Gavyoutube', True)
    if not yn(_("""This plugin offers a snarfer that will try to fetch info about
             Youtube videos that it sees in the channel. Would you like this
             snarfer to be enabled?"""), default=True):
        Youtube.youtubeSnarfer.setValue(False)
Ejemplo n.º 14
0
def configure(advanced):
    from supybot.questions import expect, anything, something, yn
    WhatCD = conf.registerPlugin('WhatCD', True)
    if yn("""This plugin also offers a snarfer that will try to fetch the
             title of URLs that it sees in the channel.  Would like you this
             snarfer to be enabled?""", default=False):
        WhatCD.titleSnarfer.setValue(True)
Ejemplo n.º 15
0
def configure(advanced):
    from supybot.questions import expect, something, yn, output

    def anything(prompt, default=None):
        """Because supybot is pure fail"""
        from supybot.questions import expect
        return expect(prompt, [], default=default)

    Webcal = conf.registerPlugin('Webcal', True)

    output("Every option, except for the default channel and URL to a list of time zones, is channel-specific.")
    output("The values you enter here will be the defaults unless overridden by a channel-specific value")
    doTopic = yn("Manage the topic for all channels?", default=Webcal.doTopic._default)
    url = anything("What is the default URL to the iCal feed, for all channels?", default=Webcal.url._default)
    defaultChannel = anything("What channel should be default when none is given?", default=Webcal.defaultChannel._default)
    tzUrl = anything("What is the URL to the list of available time zonez?", default=Webcal.tzUrl._default)

    if advanced:
        filter = anything("What should the filter be for the iCal feed, for all channels?", default=Webcal.filter._default)
        topic = anything("What template should be used for the topic, for all channels", default=Webcal.topic._default)
    else:
        filter = Webcal.filter._default
        topic = Webcal.topic._default

    Webcal.doTopic.setValue(doTopic)
    Webcal.url.setValue(url)
    Webcal.defaultChannel.setValue(defaultChannel)
    Webcal.tzUrl.setValue(tzUrl)
    Webcal.filter.setValue(filter)
    Webcal.topic.setValue(topic)
Ejemplo n.º 16
0
def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('ShrinkUrl', True)
    if yn(_("""This plugin offers a snarfer that will go retrieve a shorter
             version of long URLs that are sent to the channel.  Would you
             like this snarfer to be enabled?"""), default=False):
        conf.supybot.plugins.ShrinkUrl.shrinkSnarfer.setValue(True)
Ejemplo n.º 17
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Debian', True)
    if not utils.findBinaryInPath('zgrep'):
        if not advanced:
            output("""I can't find zgrep in your path.  This is necessary
                      to run the file command.  I'll disable this command
                      now.  When you get zgrep in your path, use the command
                      'enable Debian.file' to re-enable the command.""")
            capabilities = conf.supybot.capabilities()
            capabilities.add('-Debian.file')
            conf.supybot.capabilities.set(capabilities)
        else:
            output("""I can't find zgrep in your path.  If you want to run
                      the file command with any sort of expediency, you'll
                      need it.  You can use a python equivalent, but it's
                      about two orders of magnitude slower.  THIS MEANS IT
                      WILL TAKE AGES TO RUN THIS COMMAND.  Don't do this.""")
            if yn('Do you want to use a Python equivalent of zgrep?'):
                conf.supybot.plugins.Debian.pythonZgrep.setValue(True)
            else:
                output('I\'ll disable file now.')
                capabilities = conf.supybot.capabilities()
                capabilities.add('-Debian.file')
                conf.supybot.capabilities.set(capabilities)
Ejemplo n.º 18
0
def configure(advanced):
    # 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 output, expect, anything, something, yn

    conf.registerPlugin("Debian", True)
    if not utils.findBinaryInPath("zgrep"):
        if not advanced:
            output(
                """I can't find zgrep in your path.  This is necessary
                      to run the file command.  I'll disable this command
                      now.  When you get zgrep in your path, use the command
                      'enable Debian.file' to re-enable the command."""
            )
            capabilities = conf.supybot.capabilities()
            capabilities.add("-Debian.file")
            conf.supybot.capabilities.set(capabilities)
        else:
            output(
                """I can't find zgrep in your path.  If you want to run
                      the file command with any sort of expediency, you'll
                      need it.  You can use a python equivalent, but it's
                      about two orders of magnitude slower.  THIS MEANS IT
                      WILL TAKE AGES TO RUN THIS COMMAND.  Don't do this."""
            )
            if yn("Do you want to use a Python equivalent of zgrep?"):
                conf.supybot.plugins.Debian.pythonZgrep.setValue(True)
            else:
                output("I'll disable file now.")
                capabilities = conf.supybot.capabilities()
                capabilities.add("-Debian.file")
                conf.supybot.capabilities.set(capabilities)
Ejemplo n.º 19
0
def configure(advanced):
    from supybot.questions import expect, anything, something, yn
    conf.registerPlugin('Intranet', True)
    output('The default whois server is whois.verisign-grs.com.')
    if yn('Would you like to specify a different whois server?'):
        server = something('What server?')
        conf.plugins.Intranet.whoisServer.setValue(server)
Ejemplo n.º 20
0
def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('BadWords', True)
    if yn(_('Would you like to add some bad words?')):
        words = anything(_('What words? (separate individual words by '
                         'spaces)'))
        conf.supybot.plugins.BadWords.words.set(words)
Ejemplo n.º 21
0
def configure(advanced):
    # 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
    dtBot = conf.registerPlugin(PluginName, True)
    
    if yn("""The Digital-Tunes plugin rocks.  Would you like these commands to
             be enabled for everyone?""", default = False):
        dtBot.userLevelRequires.setValue("")
    else:
        cap = something("""What capability would you like to require for
                           this command to be used?""", default = "Admin")
        dtBot.userLevelRequires.setValue(cap)
    
    # 905872135d3b762556484e3256bdf17aa2ddcba0
    apiKey = something("""Digital-Tunes requires an API key to access their API.
                          If you don't have one, sign up at:
                          http://www.digital-tunes.net/affiliates/new""", default = False)
    dtBot.apiKey.setValue(apiKey)

    perPage = something("""How many results would you like returned per search?
                           """, default = 5)
    dtBot.numResults.setValue(perPage)
Ejemplo n.º 22
0
def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('Dict', True)
    output(_('The default dictd server is dict.org.'))
    if yn(_('Would you like to specify a different dictd server?')):
        server = something('What server?')
        conf.supybot.plugins.Dict.server.set(server)
Ejemplo n.º 23
0
def configure(advanced):
    # 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
    botPort = conf.registerPlugin(PluginName, True)
    
    if yn("""The Beatport plugin rocks.  Would you like these commands to
             be enabled for everyone?""", default = False):
        botPort.userLevelRequires.setValue("")
    else:
        cap = something("""What capability would you like to require for
                           this command to be used?""", default = "Admin")
        botPort.userLevelRequires.setValue(cap)
    
    perPage = something("""How many results would you like returned per search?
                           """, default = 5)
    botPort.numResults.setValue(perPage)
    
    sortBy = expect("""In what order would you like results displayed?
                       See http://api.beatport.com/catalog-search.html for
                       options.""",
                       ["releaseDate", "publishDate", "releaseId", "trackName",
                        "trackId", "labelName", "genreName"],
                       default = "releaseDate")
    botPort.sortBy.setValue(sortBy)
Ejemplo n.º 24
0
def configure(advanced):
    from supybot.questions import something, anything, yn, output
    output("""Here you can set which channels and who the bot has to send log
              messages to. Note that by default in order to log to a channel
              the channel has to have mode +s set. Logging to a user requires
              the user to have the Owner capability.""")
    targets = ''
    while not targets:
        try:
            targets = anything('Which channels or users would you like to '
                               'send log messages to?')
            conf.supybot.plugins.LogToIrc.targets.set(targets)
        except registry.InvalidRegistryValue as e:
            output(str(e))
            targets = ''
    colorized = yn('Would you like these messages to be colored?')
    conf.supybot.plugins.LogToIrc.color.setValue(colorized)
    if advanced:
        level = ''
        while not level:
            try:
                level = something('What would you like the minimum priority '
                                  'level to be which will be logged to IRC?')
                conf.supybot.plugins.LogToIrc.level.set(level)
            except registry.InvalidRegistryValue as e:
                output(str(e))
                level = ''
Ejemplo n.º 25
0
def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('ShrinkUrl', True)
    if yn(_("""This plugin offers a snarfer that will go retrieve a shorter
             version of long URLs that are sent to the channel.  Would you
             like this snarfer to be enabled?"""), default=False):
        conf.supybot.plugins.ShrinkUrl.shrinkSnarfer.setValue(True)
Ejemplo n.º 26
0
def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('BadWords', True)
    if yn(_('Would you like to add some bad words?')):
        words = anything(_('What words? (separate individual words by '
                         'spaces)'))
        conf.supybot.plugins.BadWords.words.set(words)
Ejemplo n.º 27
0
def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('Dict', True)
    output('The default dictd server is dict.org.')
    if yn('Would you like to specify a different dictd server?'):
        server = something('What server?')
        conf.supybot.plugins.Dict.server.set(server)
Ejemplo n.º 28
0
def configure(advanced):
    from supybot.questions import expect, anything, something, yn
    conf.registerPlugin('Webopedia', True)
    output("""The Webopedia plugin has the ability to watch for webopedia
              URLs and respond to them as though the user had asked for the 
              definition by name""")
    if yn('Do you want the Webopedia snarfer enabled by default?'):
        conf.supybot.plugins.Webopedia.geekSnarfer.setValue(True)
Ejemplo n.º 29
0
def configure(advanced):
    from supybot.questions import expect, anything, something, yn
    conf.registerPlugin('Webopedia', True)
    output("""The Webopedia plugin has the ability to watch for webopedia
              URLs and respond to them as though the user had asked for the 
              definition by name""")
    if yn('Do you want the Webopedia snarfer enabled by default?'):
        conf.supybot.plugins.Webopedia.geekSnarfer.setValue(True)
Ejemplo n.º 30
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Gameknot', True)
    if advanced:
        output("""The Gameknot plugin has the functionality to watch for URLs
                  that match a specific pattern (we call this a snarfer). When
                  supybot sees such a URL, he will parse the web page for
                  information and reply with the results.""")
        if yn('Do you want the Gameknot stats snarfer enabled by default?',
              default=False):
            conf.supybot.plugins.Gameknot.statSnarfer.setValue(True)
        if yn('Do you want the Gameknot Game links snarfer enabled by '
              'default?', default=False):
            conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True)
Ejemplo n.º 31
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    Lookup = conf.registerPlugin('Lookup', True)
    lookups = Lookup.lookups
    output("""This module allows you to define commands that do a simple key
              lookup and return some simple value.  It has a command "add"
              that takes a command name and a file from the data dir and adds a
              command with that name that responds with the mapping from that
              file. The file itself should be composed of lines
              of the form key:value.""")
    while yn('Would you like to add a file?'):
        filename = something('What\'s the filename?')
        try:
            fd = file(filename)
        except EnvironmentError, e:
            output('I couldn\'t open that file: %s' % e)
            continue
        counter = 1
        try:
            try:
                for line in fd:
                    line = line.rstrip('\r\n')
                    if not line or line.startswith('#'):
                        continue
                    (key, value) = line.split(':', 1)
                    counter += 1
            except ValueError:
                output('That\'s not a valid file; '
                       'line #%s is malformed.' % counter)
                continue
        finally:
            fd.close()
        command = something('What would you like the command to be?')
        conf.registerGlobalValue(lookups,command, registry.String(filename,''))
        nokeyVal = yn('Would you like the key to be shown for random '
                      'responses?')
        conf.registerGlobalValue(lookups.get(command), 'nokey',
                                    registry.Boolean(nokeyVal, ''))
Ejemplo n.º 32
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Gameknot', True)
    if advanced:
        output("""The Gameknot plugin has the functionality to watch for URLs
                  that match a specific pattern (we call this a snarfer). When
                  supybot sees such a URL, he will parse the web page for
                  information and reply with the results.""")
        if yn('Do you want the Gameknot stats snarfer enabled by default?',
              default=False):
            conf.supybot.plugins.Gameknot.statSnarfer.setValue(True)
        if yn(
                'Do you want the Gameknot Game links snarfer enabled by '
                'default?',
                default=False):
            conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True)
Ejemplo n.º 33
0
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
    QuranFinder = conf.registerPlugin('QuranFinder', True)
    if yn("""Split long verses?""", default=True):
        QuranFinder.splitMessages.setValue(True)
    else:
        QuranFinder.splitMessages.setValue(False)
Ejemplo n.º 34
0
def configure(advanced):
    # 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('Bugzilla', True)
    if yn("""This plugin can show data about bug URLs and numbers mentioned
             in the channel. Do you want this bug snarfer enabled by
             default?""", default=False):
        conf.supybot.plugins.Bugzilla.bugSnarfer.setValue(True)
Ejemplo n.º 35
0
def configure(advanced):
    # 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('Python', True)
    if yn("""This plugin provides a snarfer for ASPN Python Recipe URLs;
             it will output the name of the Recipe when it sees such a URL.
             Would you like to enable this snarfer?"""):
        conf.supybot.plugins.Python.aspnSnarfer.setValue(True)
Ejemplo n.º 36
0
def configure(advanced):
    # 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('Python', True)
    if yn("""This plugin provides a snarfer for ASPN Python Recipe URLs;
             it will output the name of the Recipe when it sees such a URL.
             Would you like to enable this snarfer?"""):
        conf.supybot.plugins.Python.aspnSnarfer.setValue(True)
Ejemplo n.º 37
0
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
    Web = conf.registerPlugin('Web', True)
    if yn("""This plugin also offers a snarfer that will try to fetch the
             title of URLs that it sees in the channel.  Would like you this
             snarfer to be enabled?""", default=False):
        Web.titleSnarfer.setValue(True)
Ejemplo n.º 38
0
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
    Rweb = conf.registerPlugin('Rweb', True)
    if yn("""This plugin also offers a snarfer that will try to fetch the
             title of URLs that it sees in the channel.  Would like you this
             snarfer to be enabled?""", default=False):
        Rweb.titleSnarfer.setValue(True)
Ejemplo n.º 39
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Geekquote', True)
    output("""The Geekquote plugin has the ability to watch for geekquote
              (bash.org / qdb.us) URLs and respond to them as though the user
              had asked for the geekquote by ID""")
    if yn('Do you want the Geekquote snarfer enabled by default?'):
        conf.supybot.plugins.Geekquote.geekSnarfer.setValue(True)
Ejemplo n.º 40
0
def configure(advanced):
    # 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('Bugzilla', True)
    if yn("""This plugin can show data about bug URLs and numbers mentioned
             in the channel. Do you want this bug snarfer enabled by 
             default?""",
          default=False):
        conf.supybot.plugins.Bugzilla.bugSnarfer.setValue(True)
Ejemplo n.º 41
0
def configure(advanced):
    # 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, something, yn

    def anything(prompt, default=None):
        """Because supybot is pure fail"""
        from supybot.questions import expect
        return expect(prompt, [], default=default)

    Lart = conf.registerPlugin('Lart', True)

    enabled = yn("Enable Lart for all channels?", default=Lart.enabled._default)
    if advanced:
        showIds = yn("Show the ID of a lart when it is shown?", default=Lart.showIds._default)
    else:
        showIds = Lart.showIds._default

    Lart.enabled.setValue(enabled)
    Lart.showIds.setValue(showIds)
Ejemplo n.º 42
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    output('To use the Acronym Finder, you must have obtained a license key.')
    if yn('Do you have a license key?'):
        key = something('What is it?')
        while len(key) != 36:
            output('That is not a valid Acronym Finder license key.')
            if yn('Are you sure you have a valid Acronym Finder license key?'):
                key = something('What is it?')
            else:
                key = ''
                break
        if key:
            conf.registerPlugin('AcronymFinder', True)
            conf.supybot.plugins.AcronymFinder.licenseKey.setValue(key)
    else:
        output("""You'll need to get a key before you can use this plugin.
                  You can apply for a key at http://www.acronymfinder.com/dontknowyet/""")
Ejemplo n.º 43
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Insult', True)
    if advanced:
        output("""The Insult plugin constructs an insult in the form of \"You
        are nothing but a(n) {adjective} {amount} of {adjective} {noun}.\"
        """)
        if yn("""Include foul language in pools of randomly chosen adjective,
            amount and noun words?""", default=True):
            conf.supybot.plugins.Insult.allowFoul.setValue(True)
Ejemplo n.º 44
0
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
    Mittag = conf.registerPlugin('Mittag', True)

    Mittag.apiKey.setValue(something("Please enter your API Key:"))
    Mittag.latitude.setValue(something("Latitude:"))
    Mittag.longitude.setValue(something("Longitude:"))
    Mittag.distance.setValue(something("Distance:", default=2.5))
    Mittag.prefixNick.setValue(yn("Prefix nickname in replies?",
                                  default=False))
Ejemplo n.º 45
0
def configure(advanced):
    # 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("Shift", True)
    if yn(
        """ This allows the ability to get all: in a channel and 
                translate it to names""",
        default=True,
    ):
        conf.supybot.plugins.Shift.shiftSnarfer.setValue(True)
Ejemplo n.º 46
0
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 output, expect, anything, something, yn
    conf.registerPlugin('Unix', True)
    output(_("""The "progstats" command can reveal potentially sensitive
              information about your machine. Here's an example of its output:

              %s\n""") % progstats())
    if yn(_('Would you like to disable this command for non-owner users?'),
          default=True):
        conf.supybot.commands.disabled().add('Unix.progstats')
Ejemplo n.º 47
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Unix', True)
    output("""The "progstats" command can reveal potentially sensitive
              information about your machine. Here's an example of its output:

              %s\n""" % progstats())
    if yn('Would you like to disable this command for non-owner users?',
          default=True):
        conf.supybot.commands.disabled().add('Unix.progstats')
Ejemplo n.º 48
0
def describePlugin(module, showUsage):
    if module.__doc__:
        output(module.__doc__, unformatted=False)
    elif hasattr(module.Class, '__doc__'):
        output(module.Class.__doc__, unformatted=False)
    else:
        output("""Unfortunately, this plugin doesn't seem to have any
        documentation.  Sorry about that.""")
    if showUsage:
        if hasattr(module, 'example'):
            if yn('This plugin has a usage example.  '
                  'Would you like to see it?', default=False):
                pydoc.pager(module.example)
        else:
            output("""This plugin has no usage example.""")
Ejemplo n.º 49
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    output('To use Amazon\'s Web Services, you must have a license key.')
    if yn('Do you have a license key?'):
        key = anything('What is it?')
        conf.registerPlugin('Amazon', True)
        conf.supybot.plugins.Amazon.licenseKey.set(key)
    else:
        output("""You'll need to get a key before you can use this plugin.
                  You can apply for a key at
                  http://www.amazon.com/webservices/""")
Ejemplo n.º 50
0
def configure(advanced):
    # 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 output, expect, anything, something, yn
    conf.registerPlugin('Insult', True)
    if advanced:
        output("""The Insult plugin constructs an insult in the form of \"You
        are nothing but a(n) {adjective} {amount} of {adjective} {noun}.\"
        """)
        if yn("""Include foul language in pools of randomly chosen adjective,
            amount and noun words?""",
              default=True):
            conf.supybot.plugins.Insult.allowFoul.setValue(True)
Ejemplo n.º 51
0
def describePlugin(module, showUsage):
    if module.__doc__:
        output(module.__doc__, unformatted=False)
    elif hasattr(module.Class, '__doc__'):
        output(module.Class.__doc__, unformatted=False)
    else:
        output("""Unfortunately, this plugin doesn't seem to have any
        documentation.  Sorry about that.""")
    if showUsage:
        if hasattr(module, 'example'):
            if yn(
                    'This plugin has a usage example.  '
                    'Would you like to see it?',
                    default=False):
                pydoc.pager(module.example)
        else:
            output("""This plugin has no usage example.""")
Ejemplo n.º 52
0
def configure(advanced):
    # 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
    Jira = conf.registerPlugin('Jira', True)
    server = something("""What is the URL for the Jira instance?""")
    lookup = yn(
        """Do you want to lookup Jira issues once they appear on a channel?""",
        default=True)
    snarfRegex = something("""What is the prefix for your Jira issue keys?""",
                           default="AR")
    snarfRegex = ''.join((snarfRegex, '-[0-9]+'))
    snarfChannel = something(
        """What channel you'd like to snarf for issues?""", default="#armbian")
    channel = something("""Where to send anouncements for new issues to?""")

    Jira.server.setValue(server)
    Jira.lookup.setValue(lookup)
    Jira.snarfRegex.setValue(snarfRegex)
    Jira.channel.setValue(channel)
    Jira.snarfChannel.setValue(snarfChannel)
Ejemplo n.º 53
0
def configure(advanced):
    """Configures the plugin by asking questions."""
    from supybot.questions import yn
    conf.registerPlugin('Youtube', True)
    if not yn(_("""This plugin offers a snarfer that will try to fetch
                   info about Youtube videos that it sees in the channel.
                   Would you like this snarfer to be enabled?
                   IMPORTANT:
                   You also need to edit plugin.py and enter your Google
                   Developers YouTube Data API key which you can obtain by
                   following the instructions on the following url before
                   the plugin will work correctly:
                   https://developers.google.com/youtube/v3/getting-started
                """),
              default=True):
        Youtube.youtubeSnarfer.setValue(False)

    if not yn(_("""Do you want to show the number of views?"""), default=True):
        Youtube.showViews.setValue(False)

    if not yn(_("""Do you want to show the duration?"""), default=True):
        Youtube.showDuration.setValue(False)

    if not yn(_("""Do you want to show likes/dislikes?"""), default=True):
        Youtube.showLikes.setValue(False)

    if yn(_("""Do you want to show the channel name?"""), default=False):
        Youtube.showChannel.setValue(True)

    if yn(_("""Do you want to show the video publish date?"""), default=False):
        Youtube.showDate.setValue(True)

    if yn(_("""Do you want the bot to prefix its reply with the nickname
               that posted the video URL?
            """),
          default=False):
        Youtube.prefixNick.setValue(True)
Ejemplo n.º 54
0
def configure(advanced):
    from supybot.questions import yn, something, output
    from supybot.utils.str import format
    import os
    import sqlite
    import re

    def anything(prompt, default=None):
        """Because supybot is pure fail"""
        from supybot.questions import expect
        return expect(prompt, [], default=default)

    Encyclopedia = conf.registerPlugin('Encyclopedia', True)

    enabled = yn("Enable Encyclopedia for all channels?", default=Encyclopedia.enabled._default)
    if advanced:
        datadir = something("Which directory should the factoids database be in?", default=Encyclopedia.datadir._default)
        database = something("What should be the name of the default database (without the .db extension)?", default=Encyclopedia.database._default)
        prefixchar = something("What prefix character should the bot respond to factoid requests with?", default=Encyclopedia.prefixchar._default)
        ignores = set([])
        output("This plugin can be configured to always ignore certain factoid requests, this is useful when you want another plugin to handle them")
        output("For instance, the PackageInfo plugin responds to !info and !find, so those should be ignored in Encyclopedia to allow this to work")
        ignores_i = anything("Which factoid requets should the bot always ignore?", default=', '.join(Encyclopedia.ignores._default))
        for name in re.split(r',?\s', ignores_i):
            ignores.add(name.lower())

        curStable = something("What is short name of the current stable release?", default=Encyclopedia.curStable._default)
        curStableLong = something("What is long name of the current stable release?", default=Encyclopedia.curStableLong._default)
        curStableNum = something("What is version number of the current stable release?", default=Encyclopedia.curStableNum._default)

        curDevel = something("What is short name of the current development release?", default=Encyclopedia.curDevel._default)
        curDevelLong = something("What is long name of the current development release?", default=Encyclopedia.curDevelLong._default)
        curDevelNum = something("What is version number of the current development release?", default=Encyclopedia.curDevelNum._default)

        curLTS = something("What is short name of the current LTS release?", default=Encyclopedia.curLTS._default)
        curLTSLong = something("What is long name of the current LTS release?", default=Encyclopedia.curLTSLong._default)
        curLTSNum = something("What is version number of the current LTS release?", default=Encyclopedia.curLTSNum._default)
    else:
        datadir = Encyclopedia.datadir._default
        database = Encyclopedia.database._default
        prefixchar = Encyclopedia.prefixchar._default
        ignores = Encyclopedia.ignores._default
        curStable = Encyclopedia.curStable._default
        curStableLong = Encyclopedia.curStableLong._default
        curStableNum = Encyclopedia.curStableNum._default
        curDevel = Encyclopedia.curDevel._default
        curDevelLong = Encyclopedia.curDevelLong._default
        curDevelNum = Encyclopedia.curDevelNum._default
        curLTS = Encyclopedia.curLTS._default
        curLTSLong = Encyclopedia.curLTSLong._default
        curLTSNum = Encyclopedia.curLTSNum._default

    relaychannel = anything("What channel/nick should the bot forward alter messages to?", default=Encyclopedia.relaychannel._default)
    output("What message should the bot reply with when a factoid can not be found?")
    notfoundmsg = something("If you include a '%s' in the message, it will be replaced with the requested factoid", default=Encyclopedia.notfoundmsg._default)
    output("When certain factoids are called an alert can be forwarded to a channel/nick")
    output("Which factoids should the bot forward alert calls for?")
    alert = set([])
    alert_i = anything("Separate types by spaces or commas:", default=', '.join(Encyclopedia.alert._default))
    for name in re.split(r',?\s+', alert_i):
        alert.add(name.lower())
    remotedb = anything("Location of a remote database to sync with (used with @sync)", default=Encyclopedia.remotedb._default)
    privateNotFound = yn("Should the bot reply in private when a factoid is not found, as opposed to in the channel?", default=Encyclopedia.privateNotFound._default)
    ignorePrefix = yn('Should the bot respond to factoids whether or not its nick or the prefix character is mentioned?', default=Encyclopedia.ignorePrefix._default)

    Encyclopedia.enabled.setValue(enabled)
    Encyclopedia.datadir.setValue(datadir)
    Encyclopedia.database.setValue(database)
    Encyclopedia.prefixchar.setValue(prefixchar)
    Encyclopedia.ignores.setValue(ignores)
    Encyclopedia.curStable.setValue(curStable)
    Encyclopedia.curStableLong.setValue(curStableLong)
    Encyclopedia.curStableNum.setValue(curStableNum)
    Encyclopedia.curDevel.setValue(curDevel)
    Encyclopedia.curDevelLong.setValue(curDevelLong)
    Encyclopedia.curDevelNum.setValue(curDevelNum)
    Encyclopedia.curLTS.setValue(curLTS)
    Encyclopedia.curLTSLong.setValue(curLTSLong)
    Encyclopedia.curLTSNum.setValue(curLTSNum)
    Encyclopedia.relaychannel.setValue(relaychannel)
    Encyclopedia.notfoundmsg.setValue(notfoundmsg)
    Encyclopedia.alert.setValue(alert)
    Encyclopedia.privateNotFound.setValue(privateNotFound)
    Encyclopedia.ignorePrefix.setValue(ignorePrefix)

    # Create the initial database
    db_dir = Encyclopedia.datadir()
    db_file = Encyclopedia.database()

    if not db_dir:
        db_dir = conf.supybot.directories.data()
        output("supybot.plugins.Encyclopedia.datadir will be set to %r" % db_dir)
        Encyclopedia.datadir.setValue(db_dir)

    if not db_file:
        db_file = 'ubuntu'
        output("supybot.plugins.Encyclopedia.database will be set to %r" % db_file)
        Encyclopedia.database.setValue(db_dir)

    if os.path.exists(os.path.join(db_dir, db_file + '.db')):
        return

    con = sqlite.connect(os.path.join(db_dir, db_file + '.db'))
    cur = con.cursor()

    try:
        cur.execute("""CREATE TABLE facts (
    id INTEGER PRIMARY KEY,
    author VARCHAR(100) NOT NULL,
    name VARCHAR(20) NOT NULL,
    added DATETIME,
    value VARCHAR(200) NOT NULL,
    popularity INTEGER NOT NULL DEFAULT 0
)""")
#"""
        cur.execute("""CREATE TABLE log (
    id INTEGER PRIMARY KEY,
    author VARCHAR(100) NOT NULL,
    name VARCHAR(20) NOT NULL,
    added DATETIME,
    oldvalue VARCHAR(200) NOT NULL
)""")

    except:
        con.rollback()
        raise
    else:
        con.commit()
    finally:
        cur.close()
        con.close()
Ejemplo n.º 55
0
 def configure(self, plugin, advanced):
     if yn(_('Enable for Twitter links? (needs API key)')):
         plugin.twitter_enabled.setValue(True)
         token = something(_('Enter Twitter OAuth Bearer token'))
         plugin.twitter_api_token.setValue(token)
Ejemplo n.º 56
0
            configurePlugin(m, advanced)
        else:
            error('There was an error loading one of the core plugins that '
                  'under almost all circumstances are loaded.  Go ahead and '
                  'fix that error and run this script again.')
    clearLoadedPlugins(plugins, conf.supybot.plugins)

    output("""Now we're going to run you through plugin configuration. There's
           a variety of plugins in supybot by default, but you can create and
           add your own, of course. We'll allow you to take a look at the known
           plugins' descriptions and configure them
           if you like what you see.""")

    # bulk
    addedBulk = False
    if advanced and yn('Would you like to add plugins en masse first?'):
        addedBulk = True
        output(format("""The available plugins are: %L.""", plugins))
        output("""What plugins would you like to add?  If you've changed your
        mind and would rather not add plugins in bulk like this, just press
        enter and we'll move on to the individual plugin configuration.""")
        massPlugins = anything('Separate plugin names by spaces or commas:')
        for name in re.split(r',?\s+', massPlugins):
            module = loadPlugin(name)
            if module is not None:
                configurePlugin(module, advanced)
                clearLoadedPlugins(plugins, conf.supybot.plugins)

    # individual
    if yn('Would you like to look at plugins individually?'):
        output("""Next comes your opportunity to learn more about the plugins
Ejemplo n.º 57
0
def configure(advanced):

    from supybot.questions import expect, anything, something, yn
    conf.registerPlugin('Phabricator', True)

    Phabricator.phabricatorURL.setValue(
        something("Specify the URL of the Phabricator location.",
                  default="code.wildfiregames.com"))

    Phabricator.phabricatorToken.setValue(
        something("Specify the token to access the Phabricator conduit API.",
                  default="code.wildfiregames.com"))

    Phabricator.acceptInvalidSSLCert.setValue(
        something("Accept invalid SSL certificates?", default=False))

    Phabricator.httpTimeout.setValue(something("HTTP timeout", default=40))

    Phabricator.channels.setValue(
        anything(
            "On which irc channels the bot should post Phabricator updates. If empty, prints on each joined channel.",
            default="",
            acceptEmpty=True))

    Phabricator.storyLimit.setValue(
        something("Number of stories to pull at most per HTTP request",
                  default=5))

    Phabricator.historyForwards.setValue(
        yn("Traverse history chronologically forwards (or backwards)?",
           default=True))

    Phabricator.timestampAfter.setValue(
        anything("To ignore messages after this date, type a timestamp",
                 default=0))

    Phabricator.timestampBefore.setValue(
        anything("To ignore messages before this date, type a timestamp",
                 default=0))

    Phabricator.sleepTime.setValue(
        something(
            "Number of seconds between consecutive HTTP request for phabricator stories",
            default=30))

    Phabricator.newsPrefix.setValue(
        anything("Enter string to be preceeeded with Phabricator updates"),
        default="News from the project:")

    Phabricator.printDate.setValue(yn(
        "Whether to print a human readable timestamp in front of each update notification"
    ),
                                   default=False)

    Phabricator.chronokeyFile.setValue(
        something(
            "Filename to store the most recently processed chronological key",
            default="chronokey.txt"))

    Phabricator.ignoredUsers.setValue(
        anything("Updates of these usernames will remain hidden.",
                 default="Harbormaster Vulcan",
                 acceptEmpty=True))

    Phabricator.filteredUsers.setValue(
        anything("Only updates of these usernames will be shown.",
                 default="Harbormaster Vulcan",
                 acceptEmpty=True))

    Phabricator.notifyRetitle.setValue(
        yn("Notify if differentials are retitled?", default=True))

    Phabricator.notifyCommit.setValue(
        yn("Notify if a developer committed a patch?", default=True))

    Phabricator.obscureUsernames.setValue(
        yn("Prevent the bot from pinging irc users in updates by inserting invisible whitespace in the username?",
           default=True))

    Phabricator.verbose.setValue(
        yn("Display spammy, verbose debug output?", default=False))
Ejemplo n.º 58
0
def main():
    import supybot.log as log
    import supybot.conf as conf
    log._stdoutHandler.setLevel(100)  # *Nothing* gets through this!
    parser = optparse.OptionParser(usage='Usage: %prog [options]',
                                   version='Supybot %s' % conf.version)
    parser.add_option('',
                      '--allow-root',
                      action='store_true',
                      dest='allowRoot',
                      help='Determines whether the wizard will be allowed to '
                      'run as root.  You don\'t want this.  Don\'t do it.'
                      '  Even if you think you want it, you don\'t.  '
                      'You\'re probably dumb if you do this.')
    parser.add_option('',
                      '--no-network',
                      action='store_false',
                      dest='network',
                      help='Determines whether the wizard will be allowed to '
                      'run without a network connection.')
    (options, args) = parser.parse_args()
    if os.name == 'posix':
        if (os.getuid() == 0 or os.geteuid() == 0) and not options.allowRoot:
            error('Please, don\'t run this as root.')

    filename = ''
    if args:
        parser.error('This program takes no non-option arguments.')
    output("""This is a wizard to help you start running supybot.  What it
    will do is create the necessary config files based on the options you
    select here.  So hold on tight and be ready to be interrogated :)""")

    output("""First of all, we can bold the questions you're asked so you can
    easily distinguish the mostly useless blather (like this) from the
    questions that you actually have to answer.""")
    if yn('Would you like to try this bolding?', default=True):
        questions.useBold = True
        if not yn('Do you see this in bold?'):
            output("""Sorry, it looks like your terminal isn't ANSI compliant.
            Try again some other day, on some other terminal :)""")
            questions.useBold = False
        else:
            output("""Great!""")

    ###
    # Preliminary questions.
    ###
    output("""We've got some preliminary things to get out of the way before
    we can really start asking you questions that directly relate to what your
    bot is going to be like.""")

    # Advanced?
    output("""We want to know if you consider yourself an advanced Supybot
    user because some questions are just utterly boring and useless for new
    users.  Others might not make sense unless you've used Supybot for some
    time.""")
    advanced = yn('Are you an advanced Supybot user?', default=False)

    ### Directories.
    # We set these variables in cache because otherwise conf and log will
    # create directories for the default values, which might not be what the
    # user wants.
    if advanced:
        output("""Now we've got to ask you some questions about where some of
        your directories are (or, perhaps, will be :)).  If you're running this
        wizard from the directory you'll actually be starting your bot from and
        don't mind creating some directories in the current directory, then
        just don't give answers to these questions and we'll create the
        directories we need right here in this directory.""")

        # conf.supybot.directories.log
        output("""Your bot will need to put his logs somewhere.  Do you have
        any specific place you'd like them?  If not, just press enter and we'll
        make a directory named "logs" right here.""")
        (logDir, basedir) = getDirectoryName('logs')
        conf.supybot.directories.log.setValue(logDir)

        # conf.supybot.directories.data
        output("""Your bot will need to put various data somewhere.  Things
        like databases, downloaded files, etc.  Do you have any specific place
        you'd like the bot to put these things?  If not, just press enter and
        we'll make a directory named "data" right here.""")
        (dataDir, basedir) = getDirectoryName('data', basedir=basedir)
        conf.supybot.directories.data.setValue(dataDir)

        # conf.supybot.directories.conf
        output("""Your bot must know where to find his configuration files.
        It'll probably only make one or two, but it's gotta have some place to
        put them.  Where should that place be?  If you don't care, just press
        enter and we'll make a directory right here named "conf" where it'll
        store his stuff. """)
        (confDir, basedir) = getDirectoryName('conf', basedir=basedir)
        conf.supybot.directories.conf.setValue(confDir)

        # conf.supybot.directories.backup
        output("""Your bot must know where to place backups of its conf and
        data files.  Where should that place be?  If you don't care, just press
        enter and we'll make a directory right here named "backup" where it'll
        store his stuff.""")
        (backupDir, basedir) = getDirectoryName('backup', basedir=basedir)
        conf.supybot.directories.backup.setValue(backupDir)

        # pluginDirs
        output("""Your bot will also need to know where to find his plugins at.
        Of course, he already knows where the plugins that he came with are,
        but your own personal plugins that you write for will probably be
        somewhere else.""")
        pluginDirs = conf.supybot.directories.plugins()
        output("""Currently, the bot knows about the following directories:""")
        output(format('%L', pluginDirs + [plugin._pluginsDir]))
        while yn(
                'Would you like to add another plugin directory?  '
                'Adding a local plugin directory is good style.',
                default=True):
            (pluginDir, _) = getDirectoryName('plugins', basedir=basedir)
            if pluginDir not in pluginDirs:
                pluginDirs.append(pluginDir)
        conf.supybot.directories.plugins.setValue(pluginDirs)
    else:
        output("""Your bot needs to create some directories in order to store
        the various log, config, and data files.""")
        basedir = something("""Where would you like to create these
                            directories?""",
                            default=os.curdir)
        # conf.supybot.directories.log
        (logDir, basedir) = getDirectoryName('logs', prompt=False)
        conf.supybot.directories.log.setValue(logDir)
        # conf.supybot.directories.data
        (dataDir, basedir) = getDirectoryName('data',
                                              basedir=basedir,
                                              prompt=False)
        conf.supybot.directories.data.setValue(dataDir)
        # conf.supybot.directories.conf
        (confDir, basedir) = getDirectoryName('conf',
                                              basedir=basedir,
                                              prompt=False)
        conf.supybot.directories.conf.setValue(confDir)
        # conf.supybot.directories.backup
        (backupDir, basedir) = getDirectoryName('backup',
                                                basedir=basedir,
                                                prompt=False)
        conf.supybot.directories.backup.setValue(backupDir)
        # pluginDirs
        pluginDirs = conf.supybot.directories.plugins()
        (pluginDir, _) = getDirectoryName('plugins',
                                          basedir=basedir,
                                          prompt=False)
        if pluginDir not in pluginDirs:
            pluginDirs.append(pluginDir)
        conf.supybot.directories.plugins.setValue(pluginDirs)

    output("Good!  We're done with the directory stuff.")

    ###
    # Bot stuff
    ###
    output("""Now we're going to ask you things that actually relate to the
    bot you'll be running.""")

    network = None
    while not network:
        output("""First, we need to know the name of the network you'd like to
        connect to.  Not the server host, mind you, but the name of the
        network.  If you plan to connect to irc.freenode.net, for instance, you
        should answer this question with 'freenode' (without the quotes).""")
        network = something('What IRC network will you be connecting to?')
        if '.' in network:
            output("""There shouldn't be a '.' in the network name.  Remember,
            this is the network name, not the actual server you plan to connect
            to.""")
            network = None
        elif not registry.isValidRegistryName(network):
            output(
                """That's not a valid name for one reason or another.  Please
            pick a simpler name, one more likely to be valid.""")
            network = None

    conf.supybot.networks.setValue([network])
    network = conf.registerNetwork(network)

    defaultServer = None
    server = None
    ip = None
    while not ip:
        serverString = something('What server would you like to connect to?',
                                 default=defaultServer)
        if options.network:
            try:
                output("""Looking up %s...""" % serverString)
                ip = socket.gethostbyname(serverString)
            except:
                output("""Sorry, I couldn't find that server.  Perhaps you
                misspelled it?  Also, be sure not to put the port in the
                server's name -- we'll ask you about that later.""")
        else:
            ip = 'no network available'

    output("""Found %s (%s).""" % (serverString, ip))
    output("""IRC Servers almost always accept connections on port
    6667.  They can, however, accept connections anywhere their admin
    feels like he wants to accept connections from.""")
    if yn('Does this server require connection on a non-standard port?',
          default=False):
        port = 0
        while not port:
            port = something('What port is that?')
            try:
                i = int(port)
                if not (0 < i < 65536):
                    raise ValueError
            except ValueError:
                output("""That's not a valid port.""")
                port = 0
    else:
        port = 6667
    server = ':'.join([serverString, str(port)])
    network.servers.setValue([server])

    # conf.supybot.nick
    # Force the user into specifying a nick if he didn't have one already
    while True:
        nick = something('What nick would you like your bot to use?',
                         default=None)
        try:
            conf.supybot.nick.set(nick)
            break
        except registry.InvalidRegistryValue:
            output("""That's not a valid nick.  Go ahead and pick another.""")

    # conf.supybot.user
    if advanced:
        output("""If you've ever done a /whois on a person, you know that IRC
        provides a way for users to show the world their full name.  What would
        you like your bot's full name to be?  If you don't care, just press
        enter and it'll be the same as your bot's nick.""")
        user = ''
        user = something('What would you like your bot\'s full name to be?',
                         default=nick)
        conf.supybot.user.set(user)
    # conf.supybot.ident (if advanced)
    defaultIdent = 'supybot'
    if advanced:
        output("""IRC servers also allow you to set your ident, which they
        might need if they can't find your identd server.  What would you like
        your ident to be?  If you don't care, press enter and we'll use
        'supybot'.  In fact, we prefer that you do this, because it provides
        free advertising for Supybot when users /whois your bot.  But, of
        course, it's your call.""")
        while True:
            ident = something('What would you like your bot\'s ident to be?',
                              default=defaultIdent)
            try:
                conf.supybot.ident.set(ident)
                break
            except registry.InvalidRegistryValue:
                output("""That was not a valid ident.  Go ahead and pick
                another.""")
    else:
        conf.supybot.ident.set(defaultIdent)

    if advanced:
        # conf.supybot.networks.<network>.ssl
        output("""Some servers allow you to use a secure connection via SSL.
        This requires having pyOpenSSL installed.  Currently, you also need
        Twisted installed as only the Twisted drivers supports SSL
        connections.""")
        if yn('Do you want to use an SSL connection?', default=False):
            network.ssl.setValue(True)

    # conf.supybot.networks.<network>.password
    output("""Some servers require a password to connect to them.  Most
    public servers don't.  If you try to connect to a server and for some
    reason it just won't work, it might be that you need to set a
    password.""")
    if yn('Do you want to set such a password?', default=False):
        network.password.set(getpass())

    # conf.supybot.networks.<network>.channels
    output("""Of course, having an IRC bot isn't the most useful thing in the
    world unless you can make that bot join some channels.""")
    if yn('Do you want your bot to join some channels when he connects?',
          default=True):
        defaultChannels = ' '.join(network.channels())
        output("""Separate channels with spaces.  If the channel is locked
                  with a key, follow the channel name with the key separated
                  by a comma. For example:
                  #supybot-bots #mychannel,mykey #otherchannel""")
        while True:
            channels = something('What channels?', default=defaultChannels)
            try:
                network.channels.set(channels)
                break
            except registry.InvalidRegistryValue, e:
                output(""""%s" is an invalid IRC channel.  Be sure to prefix
                the channel with # (or +, or !, or &, but no one uses those
                channels, really).  Be sure the channel key (if you are
                supplying one) does not contain a comma.""" % e.channel)