本文整理汇总了Python中supybot.questions.yn函数的典型用法代码示例。如果您正苦于以下问题:Python yn函数的具体用法?Python yn怎么用?Python yn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
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())
示例2: configure
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/"""
)
示例3: configure
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)
示例4: configure
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".""")
示例5: configure
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.""")
示例6: configure
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)
示例7: configure
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)
示例8: configure
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)
示例9: configure
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)
示例10: configure
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)
示例11: configure
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)
示例12: configure
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)
示例13: configure
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)
示例14: configure
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)
示例15: configure
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)