Added new options, more user-friendliness.

This commit is contained in:
Jeremy Fincher 2003-08-28 22:55:42 +00:00
parent 3c8a7c2387
commit 1b2b18c375

View File

@ -124,13 +124,14 @@ if __name__ == '__main__':
### ###
# Modules. # Modules.
### ###
if yn('Would you like to see a list of the available modules?') == 'y':
filenames = os.listdir(conf.pluginDir) filenames = os.listdir(conf.pluginDir)
plugins = [] plugins = []
for filename in filenames: for filename in filenames:
if filename.endswith('.py') and \ if filename.endswith('.py') and \
filename.lower() != filename: filename.lower() != filename:
plugins.append(os.path.splitext(filename)[0]) plugins.append(os.path.splitext(filename)[0])
plugins.sort()
if yn('Would you like to see a list of the available modules?') == 'y':
print 'The available plugins are:\n %s' % '\n '.join(plugins) print 'The available plugins are:\n %s' % '\n '.join(plugins)
while yn('Would you like to add a plugin?') == 'y': while yn('Would you like to add a plugin?') == 'y':
plugin = expect('What plugin?', plugins) plugin = expect('What plugin?', plugins)
@ -141,13 +142,24 @@ if __name__ == '__main__':
print 'Sorry, this plugin cannot be loaded. You need the ' \ print 'Sorry, this plugin cannot be loaded. You need the ' \
'python module %s to load it.' % e.args[0].split()[-1] 'python module %s to load it.' % e.args[0].split()[-1]
continue continue
if module.__doc__:
print module.__doc__ print module.__doc__
else:
print 'This plugin has no documentation.'
if hasattr(module, 'example'):
print
print 'Here\'s an example of usage of this module:'
print
print module.example
if yn('Would you like to add this plugin?') == 'y': if yn('Would you like to add this plugin?') == 'y':
if hasattr(module, 'configure'): if hasattr(module, 'configure'):
module.configure(onStart, afterConnect, advanced) module.configure(onStart, afterConnect, advanced)
else: else:
onStart.append('load %s' % plugin) onStart.append('load %s' % plugin)
if 'load %s' % plugin in onStart: for s in onStart:
if s.startswith('load'):
(_, plugin) = s.split()
if plugin in plugins:
plugins.remove(plugin) plugins.remove(plugin)
### ###
@ -160,7 +172,12 @@ if __name__ == '__main__':
'to run before the bot connects to the server?' 'to run before the bot connects to the server?'
onStart.append(anything('What command?')) onStart.append(anything('What command?'))
if yn('Do you want the bot to join any channels?') == 'y': if yn('Do you want the bot to join any channels?') == 'y':
channels = anything('What channels? (separate channels by spaces)') channels = something('What channels? (separate channels by spaces)')
while not all(ircutils.isChannel, channels.split()):
for channel in channels.split():
if not ircutils.isChannel(channel):
print '%r isn\'t a valid channel.' % channel
channels = something('What channels?')
afterConnect.append('join %s' % channels) afterConnect.append('join %s' % channels)
postConnect = 'Would you like any commands to run ' \ postConnect = 'Would you like any commands to run ' \
'when the bot is finished connecting to the server?' 'when the bot is finished connecting to the server?'
@ -169,33 +186,41 @@ if __name__ == '__main__':
'when the bot is finished connecting to the server?' 'when the bot is finished connecting to the server?'
afterConnect.append(anything('What command?')) afterConnect.append(anything('What command?'))
template = template.replace('%%onStart%%', pprint.pformat(onStart))
template = template.replace('%%afterConnect%%',
pprint.pformat(afterConnect))
### ###
# Set owner user. # Set owner user.
### ###
if yn('Would you like to add an owner user?') == 'y': if yn('Would you like to add an owner user?') == 'y':
owner = anything('What should the owner\'s username be?') owner = something('What should the owner\'s username be?')
password = anything('What should the owner\'s password be?') password = something('What should the owner\'s password be?')
user = ircdb.IrcUser() user = ircdb.IrcUser()
user.setPassword(password) user.setPassword(password)
user.addCapability('owner') user.addCapability('owner')
while yn('Would you like to add a hostmask for the owner?') == 'y': while yn('Would you like to add a hostmask for the owner?') == 'y':
user.addHostmask(anything('What hostmask?')) user.addHostmask(something('What hostmask?'))
ircdb.users.setUser(owner, user) ircdb.users.setUser(owner, user)
###
# Finito!
###
template = template.replace('%%onStart%%', pprint.pformat(onStart))
template = template.replace('%%afterConnect%%',
pprint.pformat(afterConnect))
### ###
# Configuration variables in conf.py. # Configuration variables in conf.py.
### ###
configVariables = {} configVariables = {}
if advanced and \ if advanced and \
yn('Would you like to modify the default config variables?')=='y': yn('Would you like to modify the default config variables?')=='y':
pass print 'Supybot can use various "drivers" for actually handling the '
print 'network connects the bot makes. One of the most robust of '
print 'these is the Twisted <http://www.twistedmatrix.com/> driver. '
if yn('Would you like to use the Twisted driver?') == 'y':
try:
import twistedDrivers
configVariables['driverModule'] = 'twistedDrivers'
except:
print 'Sorry, twisted doesn\'t seem to be installed.'
template = template.replace('%%configVariables%%', template = template.replace('%%configVariables%%',
pprint.pformat(configVariables)) pprint.pformat(configVariables))