Guest User

Untitled

a guest
Apr 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.34 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. ###
  4. # Copyright (c) 2003-2004, Jeremiah Fincher
  5. # Copyright (c) 2009, James Vega
  6. # All rights reserved.
  7. #
  8. # Redistribution and use in source and binary forms, with or without
  9. # modification, are permitted provided that the following conditions are met:
  10. #
  11. # * Redistributions of source code must retain the above copyright notice,
  12. # this list of conditions, and the following disclaimer.
  13. # * Redistributions in binary form must reproduce the above copyright notice,
  14. # this list of conditions, and the following disclaimer in the
  15. # documentation and/or other materials provided with the distribution.
  16. # * Neither the name of the author of this software nor the name of
  17. # contributors to this software may be used to endorse or promote products
  18. # derived from this software without specific prior written consent.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  24. # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. # POSSIBILITY OF SUCH DAMAGE.
  31. ###
  32.  
  33. import os
  34. import sys
  35.  
  36. def error(s):
  37. sys.stderr.write(s)
  38. if not s.endswith(os.linesep):
  39. sys.stderr.write(os.linesep)
  40. sys.exit(-1)
  41.  
  42. if sys.version_info < (2, 3, 0):
  43. error('This program requires Python >= 2.3.0')
  44.  
  45. import supybot
  46.  
  47. import re
  48. import sets
  49. import time
  50. import pydoc
  51. import pprint
  52. import socket
  53. import logging
  54. import optparse
  55.  
  56. import supybot.ansi as ansi
  57. import supybot.utils as utils
  58. import supybot.plugin as plugin
  59. import supybot.ircutils as ircutils
  60. import supybot.registry as registry
  61.  
  62. import supybot.questions as questions
  63. from supybot.questions import output, yn, anything, something, expect, getpass
  64.  
  65. def getPlugins(pluginDirs):
  66. plugins = set([])
  67. join = os.path.join
  68. for pluginDir in pluginDirs:
  69. try:
  70. for filename in os.listdir(pluginDir):
  71. fname = join(pluginDir, filename)
  72. if (filename.endswith('.py') or os.path.isdir(fname)) \
  73. and filename[0].isupper():
  74. plugins.add(os.path.splitext(filename)[0])
  75. except OSError:
  76. continue
  77. plugins.discard('Owner')
  78. plugins = list(plugins)
  79. plugins.sort()
  80. return plugins
  81.  
  82. def loadPlugin(name):
  83. import supybot.plugin as plugin
  84. try:
  85. module = plugin.loadPluginModule(name)
  86. if hasattr(module, 'Class'):
  87. return module
  88. else:
  89. output("""That plugin loaded fine, but didn't seem to be a real
  90. Supybot plugin; there was no Class variable to tell us what class
  91. to load when we load the plugin. We'll skip over it for now, but
  92. you can always add it later.""")
  93. return None
  94. except Exception, e:
  95. output("""We encountered a bit of trouble trying to load plugin %r.
  96. Python told us %r. We'll skip over it for now, you can always add it
  97. later.""" % (name, utils.gen.exnToString(e)))
  98. return None
  99.  
  100. def describePlugin(module, showUsage):
  101. if module.__doc__:
  102. output(module.__doc__, unformatted=False)
  103. elif hasattr(module.Class, '__doc__'):
  104. output(module.Class.__doc__, unformatted=False)
  105. else:
  106. output("""Unfortunately, this plugin doesn't seem to have any
  107. documentation. Sorry about that.""")
  108. if showUsage:
  109. if hasattr(module, 'example'):
  110. if yn('This plugin has a usage example. '
  111. 'Would you like to see it?', default=False):
  112. pydoc.pager(module.example)
  113. else:
  114. output("""This plugin has no usage example.""")
  115.  
  116. def clearLoadedPlugins(plugins, pluginRegistry):
  117. for plugin in plugins:
  118. try:
  119. pluginKey = pluginRegistry.get(plugin)
  120. if pluginKey():
  121. plugins.remove(plugin)
  122. except registry.NonExistentRegistryEntry:
  123. continue
  124.  
  125. _windowsVarRe = re.compile(r'%(\w+)%')
  126. def getDirectoryName(default, basedir=os.curdir, prompt=True):
  127. done = False
  128. while not done:
  129. if prompt:
  130. dir = something('What directory do you want to use?',
  131. default=os.path.join(basedir, default))
  132. else:
  133. dir = os.path.join(basedir, default)
  134. orig_dir = dir
  135. dir = os.path.expanduser(dir)
  136. dir = _windowsVarRe.sub(r'$\1', dir)
  137. dir = os.path.expandvars(dir)
  138. dir = os.path.abspath(dir)
  139. try:
  140. os.makedirs(dir)
  141. done = True
  142. except OSError, e:
  143. if e.args[0] != 17: # File exists.
  144. output("""Sorry, I couldn't make that directory for some
  145. reason. The Operating System told me %s. You're going to
  146. have to pick someplace else.""" % e)
  147. prompt = True
  148. else:
  149. done = True
  150. return (dir, os.path.dirname(orig_dir))
  151.  
  152. def main():
  153. import supybot.log as log
  154. import supybot.conf as conf
  155. log._stdoutHandler.setLevel(100) # *Nothing* gets through this!
  156. parser = optparse.OptionParser(usage='Usage: %prog [options]',
  157. version='Supybot %s' % conf.version)
  158. parser.add_option('', '--allow-root', action='store_true',
  159. dest='allowRoot',
  160. help='Determines whether the wizard will be allowed to '
  161. 'run as root. You don\'t want this. Don\'t do it.'
  162. ' Even if you think you want it, you don\'t. '
  163. 'You\'re probably dumb if you do this.')
  164. parser.add_option('', '--no-network', action='store_false',
  165. dest='network',
  166. help='Determines whether the wizard will be allowed to '
  167. 'run without a network connection.')
  168. (options, args) = parser.parse_args()
  169. if os.name == 'posix':
  170. if (os.getuid() == 0 or os.geteuid() == 0) and not options.allowRoot:
  171. error('Please, don\'t run this as root.')
  172.  
  173. filename = ''
  174. if args:
  175. parser.error('This program takes no non-option arguments.')
  176. output("""This is a wizard to help you start running supybot. What it
  177. will do is create the necessary config files based on the options you
  178. select here. So hold on tight and be ready to be interrogated :)""")
  179.  
  180.  
  181. output("""First of all, we can bold the questions you're asked so you can
  182. easily distinguish the mostly useless blather (like this) from the
  183. questions that you actually have to answer.""")
  184. if yn('Would you like to try this bolding?', default=True):
  185. questions.useBold = True
  186. if not yn('Do you see this in bold?'):
  187. output("""Sorry, it looks like your terminal isn't ANSI compliant.
  188. Try again some other day, on some other terminal :)""")
  189. questions.useBold = False
  190. else:
  191. output("""Great!""")
  192.  
  193. ###
  194. # Preliminary questions.
  195. ###
  196. output("""We've got some preliminary things to get out of the way before
  197. we can really start asking you questions that directly relate to what your
  198. bot is going to be like.""")
  199.  
  200. # Advanced?
  201. output("""We want to know if you consider yourself an advanced Supybot
  202. user because some questions are just utterly boring and useless for new
  203. users. Others might not make sense unless you've used Supybot for some
  204. time.""")
  205. advanced = yn('Are you an advanced Supybot user?', default=False)
  206.  
  207. ### Directories.
  208. # We set these variables in cache because otherwise conf and log will
  209. # create directories for the default values, which might not be what the
  210. # user wants.
  211. if advanced:
  212. output("""Now we've got to ask you some questions about where some of
  213. your directories are (or, perhaps, will be :)). If you're running this
  214. wizard from the directory you'll actually be starting your bot from and
  215. don't mind creating some directories in the current directory, then
  216. just don't give answers to these questions and we'll create the
  217. directories we need right here in this directory.""")
  218.  
  219. # conf.supybot.directories.log
  220. output("""Your bot will need to put his logs somewhere. Do you have
  221. any specific place you'd like them? If not, just press enter and we'll
  222. make a directory named "logs" right here.""")
  223. (logDir, basedir) = getDirectoryName('logs')
  224. conf.supybot.directories.log.setValue(logDir)
  225.  
  226. # conf.supybot.directories.data
  227. output("""Your bot will need to put various data somewhere. Things
  228. like databases, downloaded files, etc. Do you have any specific place
  229. you'd like the bot to put these things? If not, just press enter and
  230. we'll make a directory named "data" right here.""")
  231. (dataDir, basedir) = getDirectoryName('data', basedir=basedir)
  232. conf.supybot.directories.data.setValue(dataDir)
  233.  
  234. # conf.supybot.directories.conf
  235. output("""Your bot must know where to find his configuration files.
  236. It'll probably only make one or two, but it's gotta have some place to
  237. put them. Where should that place be? If you don't care, just press
  238. enter and we'll make a directory right here named "conf" where it'll
  239. store his stuff. """)
  240. (confDir, basedir) = getDirectoryName('conf', basedir=basedir)
  241. conf.supybot.directories.conf.setValue(confDir)
  242.  
  243. # conf.supybot.directories.backup
  244. output("""Your bot must know where to place backups of its conf and
  245. data files. Where should that place be? If you don't care, just press
  246. enter and we'll make a directory right here named "backup" where it'll
  247. store his stuff.""")
  248. (backupDir, basedir) = getDirectoryName('backup', basedir=basedir)
  249. conf.supybot.directories.backup.setValue(backupDir)
  250.  
  251. # pluginDirs
  252. output("""Your bot will also need to know where to find his plugins at.
  253. Of course, he already knows where the plugins that he came with are,
  254. but your own personal plugins that you write for will probably be
  255. somewhere else.""")
  256. pluginDirs = conf.supybot.directories.plugins()
  257. output("""Currently, the bot knows about the following directories:""")
  258. output(format('%L', pluginDirs + [plugin._pluginsDir]))
  259. while yn('Would you like to add another plugin directory? '
  260. 'Adding a local plugin directory is good style.',
  261. default=True):
  262. (pluginDir, _) = getDirectoryName('plugins', basedir=basedir)
  263. if pluginDir not in pluginDirs:
  264. pluginDirs.append(pluginDir)
  265. conf.supybot.directories.plugins.setValue(pluginDirs)
  266. else:
  267. output("""Your bot needs to create some directories in order to store
  268. the various log, config, and data files.""")
  269. basedir = something("""Where would you like to create these
  270. directories?""", default=os.curdir)
  271. # conf.supybot.directories.log
  272. (logDir, basedir) = getDirectoryName('logs', prompt=False)
  273. conf.supybot.directories.log.setValue(logDir)
  274. # conf.supybot.directories.data
  275. (dataDir, basedir) = getDirectoryName('data',
  276. basedir=basedir, prompt=False)
  277. conf.supybot.directories.data.setValue(dataDir)
  278. # conf.supybot.directories.conf
  279. (confDir, basedir) = getDirectoryName('conf',
  280. basedir=basedir, prompt=False)
  281. conf.supybot.directories.conf.setValue(confDir)
  282. # conf.supybot.directories.backup
  283. (backupDir, basedir) = getDirectoryName('backup',
  284. basedir=basedir, prompt=False)
  285. conf.supybot.directories.backup.setValue(backupDir)
  286. # pluginDirs
  287. pluginDirs = conf.supybot.directories.plugins()
  288. (pluginDir, _) = getDirectoryName('plugins',
  289. basedir=basedir, prompt=False)
  290. if pluginDir not in pluginDirs:
  291. pluginDirs.append(pluginDir)
  292. conf.supybot.directories.plugins.setValue(pluginDirs)
  293.  
  294. output("Good! We're done with the directory stuff.")
  295.  
  296. ###
  297. # Bot stuff
  298. ###
  299. output("""Now we're going to ask you things that actually relate to the
  300. bot you'll be running.""")
  301.  
  302. network = None
  303. while not network:
  304. output("""First, we need to know the name of the network you'd like to
  305. connect to. Not the server host, mind you, but the name of the
  306. network. If you plan to connect to irc.freenode.net, for instance, you
  307. should answer this question with 'freenode' (without the quotes).""")
  308. network = something('What IRC network will you be connecting to?')
  309. if '.' in network:
  310. output("""There shouldn't be a '.' in the network name. Remember,
  311. this is the network name, not the actual server you plan to connect
  312. to.""")
  313. network = None
  314. elif not registry.isValidRegistryName(network):
  315. output("""That's not a valid name for one reason or another. Please
  316. pick a simpler name, one more likely to be valid.""")
  317. network = None
  318.  
  319. conf.supybot.networks.setValue([network])
  320. network = conf.registerNetwork(network)
  321.  
  322. defaultServer = None
  323. server = None
  324. ip = None
  325. while not ip:
  326. serverString = something('What server would you like to connect to?',
  327. default=defaultServer)
  328. if options.network:
  329. try:
  330. output("""Looking up %s...""" % serverString)
  331. ip = socket.gethostbyname(serverString)
  332. except:
  333. output("""Sorry, I couldn't find that server. Perhaps you
  334. misspelled it? Also, be sure not to put the port in the
  335. server's name -- we'll ask you about that later.""")
  336. else:
  337. ip = 'no network available'
  338.  
  339. output("""Found %s (%s).""" % (serverString, ip))
  340. output("""IRC Servers almost always accept connections on port
  341. 6667. They can, however, accept connections anywhere their admin
  342. feels like he wants to accept connections from.""")
  343. if yn('Does this server require connection on a non-standard port?',
  344. default=False):
  345. port = 0
  346. while not port:
  347. port = something('What port is that?')
  348. try:
  349. i = int(port)
  350. if not (0 < i < 65536):
  351. raise ValueError
  352. except ValueError:
  353. output("""That's not a valid port.""")
  354. port = 0
  355. else:
  356. port = 6667
  357. server = ':'.join([serverString, str(port)])
  358. network.servers.setValue([server])
  359.  
  360. # conf.supybot.nick
  361. # Force the user into specifying a nick if he didn't have one already
  362. while True:
  363. nick = something('What nick would you like your bot to use?',
  364. default=None)
  365. try:
  366. conf.supybot.nick.set(nick)
  367. break
  368. except registry.InvalidRegistryValue:
  369. output("""That's not a valid nick. Go ahead and pick another.""")
  370.  
  371. # conf.supybot.user
  372. if advanced:
  373. output("""If you've ever done a /whois on a person, you know that IRC
  374. provides a way for users to show the world their full name. What would
  375. you like your bot's full name to be? If you don't care, just press
  376. enter and it'll be the same as your bot's nick.""")
  377. user = ''
  378. user = something('What would you like your bot\'s full name to be?',
  379. default=nick)
  380. conf.supybot.user.set(user)
  381. # conf.supybot.ident (if advanced)
  382. defaultIdent = 'supybot'
  383. if advanced:
  384. output("""IRC servers also allow you to set your ident, which they
  385. might need if they can't find your identd server. What would you like
  386. your ident to be? If you don't care, press enter and we'll use
  387. 'supybot'. In fact, we prefer that you do this, because it provides
  388. free advertising for Supybot when users /whois your bot. But, of
  389. course, it's your call.""")
  390. while True:
  391. ident = something('What would you like your bot\'s ident to be?',
  392. default=defaultIdent)
  393. try:
  394. conf.supybot.ident.set(ident)
  395. break
  396. except registry.InvalidRegistryValue:
  397. output("""That was not a valid ident. Go ahead and pick
  398. another.""")
  399. else:
  400. conf.supybot.ident.set(defaultIdent)
  401.  
  402. if advanced:
  403. # conf.supybot.networks.<network>.ssl
  404. output("""Some servers allow you to use a secure connection via SSL.
  405. This requires having pyOpenSSL installed. Currently, you also need
  406. Twisted installed as only the Twisted drivers supports SSL
  407. connections.""")
  408. if yn('Do you want to use an SSL connection?', default=False):
  409. network.ssl.setValue(True)
  410.  
  411. # conf.supybot.networks.<network>.password
  412. output("""Some servers require a password to connect to them. Most
  413. public servers don't. If you try to connect to a server and for some
  414. reason it just won't work, it might be that you need to set a
  415. password.""")
  416. if yn('Do you want to set such a password?', default=False):
  417. network.password.set(getpass())
  418.  
  419. # conf.supybot.networks.<network>.channels
  420. output("""Of course, having an IRC bot isn't the most useful thing in the
  421. world unless you can make that bot join some channels.""")
  422. if yn('Do you want your bot to join some channels when he connects?',
  423. default=True):
  424. defaultChannels = ' '.join(network.channels())
  425. output("""Separate channels with spaces. If the channel is locked
  426. with a key, follow the channel name with the key separated
  427. by a comma. For example:
  428. #supybot-bots #mychannel,mykey #otherchannel""");
  429. while True:
  430. channels = something('What channels?', default=defaultChannels)
  431. try:
  432. network.channels.set(channels)
  433. break
  434. except registry.InvalidRegistryValue, e:
  435. output(""""%s" is an invalid IRC channel. Be sure to prefix
  436. the channel with # (or +, or !, or &, but no one uses those
  437. channels, really). Be sure the channel key (if you are
  438. supplying one) does not contain a comma.""" % e.channel)
  439. else:
  440. network.channels.setValue([])
  441.  
  442. ###
  443. # Plugins
  444. ###
  445. def configurePlugin(module, advanced):
  446. if hasattr(module, 'configure'):
  447. output("""Beginning configuration for %s...""" %
  448. module.Class.__name__)
  449. module.configure(advanced)
  450. print # Blank line :)
  451. output("""Done!""")
  452. else:
  453. conf.registerPlugin(module.__name__, currentValue=True)
  454.  
  455. plugins = getPlugins(pluginDirs + [plugin._pluginsDir])
  456. for s in ('Admin', 'User', 'Channel', 'Misc', 'Config'):
  457. m = loadPlugin(s)
  458. if m is not None:
  459. configurePlugin(m, advanced)
  460. else:
  461. error('There was an error loading one of the core plugins that '
  462. 'under almost all circumstances are loaded. Go ahead and '
  463. 'fix that error and run this script again.')
  464. clearLoadedPlugins(plugins, conf.supybot.plugins)
  465.  
  466. output("""Now we're going to run you through plugin configuration. There's
  467. a variety of plugins in supybot by default, but you can create and
  468. add your own, of course. We'll allow you to take a look at the known
  469. plugins' descriptions and configure them
  470. if you like what you see.""")
  471.  
  472. # bulk
  473. addedBulk = False
  474. if advanced and yn('Would you like to add plugins en masse first?'):
  475. addedBulk = True
  476. output(format("""The available plugins are: %L.""", plugins))
  477. output("""What plugins would you like to add? If you've changed your
  478. mind and would rather not add plugins in bulk like this, just press
  479. enter and we'll move on to the individual plugin configuration.""")
  480. massPlugins = anything('Separate plugin names by spaces or commas:')
  481. for name in re.split(r',?\s+', massPlugins):
  482. module = loadPlugin(name)
  483. if module is not None:
  484. configurePlugin(module, advanced)
  485. clearLoadedPlugins(plugins, conf.supybot.plugins)
  486.  
  487. # individual
  488. if yn('Would you like to look at plugins individually?'):
  489. output("""Next comes your opportunity to learn more about the plugins
  490. that are available and select some (or all!) of them to run in your
  491. bot. Before you have to make a decision, of course, you'll be able to
  492. see a short description of the plugin and, if you choose, an example
  493. session with the plugin. Let's begin.""")
  494. # until we get example strings again, this will default to false
  495. #showUsage =yn('Would you like the option of seeing usage examples?')
  496. showUsage = False
  497. name = expect('What plugin would you like to look at?',
  498. plugins, acceptEmpty=True)
  499. while name:
  500. module = loadPlugin(name)
  501. if module is not None:
  502. describePlugin(module, showUsage)
  503. if yn('Would you like to load this plugin?', default=True):
  504. configurePlugin(module, advanced)
  505. clearLoadedPlugins(plugins, conf.supybot.plugins)
  506. if not yn('Would you like add another plugin?'):
  507. break
  508. name = expect('What plugin would you like to look at?', plugins)
  509.  
  510. ###
  511. # Sundry
  512. ###
  513. output("""Although supybot offers a supybot-adduser script, with which
  514. you can add users to your bot's user database, it's *very* important that
  515. you have an owner user for you bot.""")
  516. if yn('Would you like to add an owner user for your bot?', default=True):
  517. import supybot.ircdb as ircdb
  518. name = something('What should the owner\'s username be?')
  519. try:
  520. id = ircdb.users.getUserId(name)
  521. u = ircdb.users.getUser(id)
  522. if u._checkCapability('owner'):
  523. output("""That user already exists, and has owner capabilities
  524. already. Perhaps you added it before? """)
  525. if yn('Do you want to remove its owner capability?',
  526. default=False):
  527. u.removeCapability('owner')
  528. ircdb.users.setUser(id, u)
  529. else:
  530. output("""That user already exists, but doesn't have owner
  531. capabilities.""")
  532. if yn('Do you want to add to it owner capabilities?',
  533. default=False):
  534. u.addCapability('owner')
  535. ircdb.users.setUser(id, u)
  536. except KeyError:
  537. password = getpass('What should the owner\'s password be?')
  538. u = ircdb.users.newUser()
  539. u.name = name
  540. u.setPassword(password)
  541. u.addCapability('owner')
  542. ircdb.users.setUser(u)
  543.  
  544. output("""Of course, when you're in an IRC channel you can address the bot
  545. by its nick and it will respond, if you give it a valid command (it may or
  546. may not respond, depending on what your config variable replyWhenNotCommand
  547. is set to). But your bot can also respond to a short "prefix character,"
  548. so instead of saying "bot: do this," you can say, "@do this" and achieve
  549. the same effect. Of course, you don't *have* to have a prefix char, but
  550. if the bot ends up participating significantly in your channel, it'll ease
  551. things.""")
  552. if yn('Would you like to set the prefix char(s) for your bot? ',
  553. default=True):
  554. output("""Enter any characters you want here, but be careful: they
  555. should be rare enough that people don't accidentally address the bot
  556. (simply because they'll probably be annoyed if they do address the bot
  557. on accident). You can even have more than one. I (jemfinch) am quite
  558. partial to @, but that's because I've been using it since my ocamlbot
  559. days.""")
  560. import supybot.callbacks as callbacks
  561. c = ''
  562. while not c:
  563. try:
  564. c = anything('What would you like your bot\'s prefix '
  565. 'character(s) to be?')
  566. conf.supybot.reply.whenAddressedBy.chars.set(c)
  567. except registry.InvalidRegistryValue, e:
  568. output(str(e))
  569. c = ''
  570. else:
  571. conf.supybot.reply.whenAddressedBy.chars.set('')
  572.  
  573. ###
  574. # logging variables.
  575. ###
  576.  
  577. if advanced:
  578. # conf.supybot.log.stdout
  579. output("""By default, your bot will log not only to files in the logs
  580. directory you gave it, but also to stdout. We find this useful for
  581. debugging, and also just for the pretty output (it's colored!)""")
  582. stdout = not yn('Would you like to turn off this logging to stdout?',
  583. default=False)
  584. conf.supybot.log.stdout.setValue(stdout)
  585. if conf.supybot.log.stdout():
  586. # conf.something
  587. output("""Some terminals may not be able to display the pretty
  588. colors logged to stderr. By default, though, we turn the colors
  589. off for Windows machines and leave it on for *nix machines.""")
  590. if os.name is not 'nt':
  591. conf.supybot.log.stdout.colorized.setValue(
  592. not yn('Would you like to turn this colorization off?',
  593. default=False))
  594.  
  595. # conf.supybot.log.level
  596. output("""Your bot can handle debug messages at several priorities,
  597. CRITICAL, ERROR, WARNING, INFO, and DEBUG, in decreasing order of
  598. priority. By default, your bot will log all of these priorities except
  599. DEBUG. You can, however, specify that it only log messages above a
  600. certain priority level.""")
  601. priority = str(conf.supybot.log.level)
  602. logLevel = something('What would you like the minimum priority to be?'
  603. ' Just press enter to accept the default.',
  604. default=priority).lower()
  605. while logLevel not in ['debug','info','warning','error','critical']:
  606. output("""That's not a valid priority. Valid priorities include
  607. 'DEBUG', 'INFO', 'WARNING', 'ERROR', and 'CRITICAL'""")
  608. logLevel = something('What would you like the minimum priority to '
  609. 'be? Just press enter to accept the default.',
  610. default=priority).lower()
  611. conf.supybot.log.level.set(logLevel)
  612.  
  613. # conf.supybot.databases.plugins.channelSpecific
  614.  
  615. output("""Many plugins in Supybot are channel-specific. Their
  616. databases, likewise, are specific to each channel the bot is in. Many
  617. people don't want this, so we have one central location in which to
  618. say that you would prefer all databases for all channels to be shared.
  619. This variable, supybot.databases.plugins.channelSpecific, is that
  620. place.""")
  621.  
  622. conf.supybot.databases.plugins.channelSpecific.setValue(
  623. not yn('Would you like plugin databases to be shared by all '
  624. 'channels, rather than specific to each channel the '
  625. 'bot is in?'))
  626.  
  627. output("""There are a lot of options we didn't ask you about simply
  628. because we'd rather you get up and running and have time
  629. left to play around with your bot. But come back and see
  630. us! When you've played around with your bot enough to
  631. know what you like, what you don't like, what you'd like
  632. to change, then take a look at your configuration file
  633. when your bot isn't running and read the comments,
  634. tweaking values to your heart's desire.""")
  635.  
  636. # Let's make sure that src/ plugins are loaded.
  637. conf.registerPlugin('Admin', True)
  638. conf.registerPlugin('Channel', True)
  639. conf.registerPlugin('Config', True)
  640. conf.registerPlugin('Misc', True)
  641. conf.registerPlugin('User', True)
  642.  
  643. ###
  644. # Write the registry
  645. ###
  646.  
  647. # We're going to need to do a darcs predist thing here.
  648. #conf.supybot.debug.generated.setValue('...')
  649.  
  650. if not filename:
  651. filename = '%s.conf' % nick
  652. registry.close(conf.supybot, filename)
  653.  
  654. # Done!
  655. output("""All done! Your new bot configuration is %s. If you're running
  656. a *nix based OS, you can probably start your bot with the command line
  657. "supybot %s". If you're not running a *nix or similar machine, you'll
  658. just have to start it like you start all your other Python scripts.""" % \
  659. (filename, filename))
  660.  
  661. if __name__ == '__main__':
  662. try:
  663. main()
  664. except KeyboardInterrupt:
  665. # We may still be using bold text when exiting during a prompt
  666. if questions.useBold:
  667. import supybot.ansi as ansi
  668. print ansi.RESET
  669. print
  670. print
  671. output("""Well, it looks like you canceled out of the wizard before
  672. it was done. Unfortunately, I didn't get to write anything to file.
  673. Please run the wizard again to completion.""")
  674.  
  675. # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
Add Comment
Please, Sign In to add comment