Stopped using supybot.networks.default and just let Owner handle that crap.

This commit is contained in:
Jeremy Fincher 2004-08-23 12:29:43 +00:00
parent e757cb9750
commit 53b90674e4

View File

@ -61,6 +61,7 @@ started = time.time()
import supybot import supybot
import supybot.utils as utils import supybot.utils as utils
import supybot.registry as registry import supybot.registry as registry
import supybot.questions as questions
def main(): def main():
import supybot.conf as conf import supybot.conf as conf
@ -135,10 +136,6 @@ if __name__ == '__main__':
parser.add_option('-O', action='count', dest='optimize', parser.add_option('-O', action='count', dest='optimize',
help='-O optimizes asserts out of the code; ' \ help='-O optimizes asserts out of the code; ' \
'-OO optimizes asserts and uses psyco.') '-OO optimizes asserts and uses psyco.')
parser.add_option('', '--network', action='store',
dest='network', default='',
help='network the bot should connect to (instead of '
'using the configured default network')
parser.add_option('-n', '--nick', action='store', parser.add_option('-n', '--nick', action='store',
dest='nick', default='', dest='nick', default='',
help='nick the bot should use') help='nick the bot should use')
@ -226,19 +223,15 @@ if __name__ == '__main__':
user = options.user or conf.supybot.user() user = options.user or conf.supybot.user()
ident = options.ident or conf.supybot.ident() ident = options.ident or conf.supybot.ident()
defaultNetwork = conf.supybot.networks.default() networks = conf.supybot.networks()
if options.network: if not networks:
defaultNetwork = options.network questions.output("""No networks defined. Perhaps you should re-run the
try: wizard?""", fd=sys.stderr)
network = conf.supybot.networks.get(defaultNetwork) # XXX We should turn off logging here for a prettier presentation.
except registry.NonExistentRegistryEntry:
sys.stderr.write('No default network defined. Add a line to your ')
sys.stderr.write('registry that says (without the quotes), "supybot.')
sys.stderr.write('networks.default: <name>" where <name> is the name ')
sys.stderr.write('of the network you\'d like to connect to by ')
sys.stderr.write('default when the bot starts.')
sys.exit(-1) sys.exit(-1)
if options.optimize: if options.optimize:
# This doesn't work anymore. # This doesn't work anymore.
__builtins__.__debug__ = False __builtins__.__debug__ = False
@ -270,22 +263,14 @@ if __name__ == '__main__':
fd.close() fd.close()
registry.open(userdataFilename) registry.open(userdataFilename)
import supybot.Owner as Owner
import supybot.irclib as irclib import supybot.irclib as irclib
import supybot.ircmsgs as ircmsgs import supybot.ircmsgs as ircmsgs
import supybot.drivers as drivers import supybot.drivers as drivers
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
import supybot.Owner as Owner
irc = irclib.Irc(network=defaultNetwork) owner = Owner.Class()
callback = Owner.Class() irclib._callbacks.append(owner)
irc.addCallback(callback)
try:
driver = drivers.newDriver(irc)
except Exception, e:
log.error(utils.normalizeWhitespace("""I couldn't create a network
driver for connecting to IRC. The specific error was this: %s"""),
utils.exnToString(e))
sys.exit(-1)
if options.debug: if options.debug:
for (name, module) in sys.modules.iteritems(): for (name, module) in sys.modules.iteritems():