From 0af83d2e2420c33711659c11c62ec283d26cf2e3 Mon Sep 17 00:00:00 2001 From: James Vega Date: Wed, 14 Dec 2005 04:20:04 +0000 Subject: [PATCH] src/conf, plugins/Owner, plugins/Network: Add support for specifying an ssl connection via Network.connect. --- plugins/Network/plugin.py | 12 +++++++----- plugins/Owner/plugin.py | 4 ++-- src/conf.py | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/Network/plugin.py b/plugins/Network/plugin.py index ef9e3d362..f280f2382 100644 --- a/plugins/Network/plugin.py +++ b/plugins/Network/plugin.py @@ -49,13 +49,14 @@ class Network(callbacks.Plugin): raise callbacks.Error, \ 'I\'m not currently connected to %s.' % network - def connect(self, irc, msg, args, network, server, password): - """ [] [] + def connect(self, irc, msg, args, opts, network, server, password): + """[--ssl] [] [] Connects to another network (which will be represented by the name provided in ) at . If port is not provided, it defaults to 6667, the default port for IRC. If password is - provided, it will be sent to the server in a PASS command. + provided, it will be sent to the server in a PASS command. If --ssl is + provided, an SSL connection will be attempted. """ try: otherIrc = self._getIrc(network) @@ -80,11 +81,12 @@ class Network(callbacks.Plugin): return Owner = irc.getCallback('Owner') newIrc = Owner._connect(network, serverPort=serverPort, - password=password) + password=password, ssl=ssl) conf.supybot.networks().add(network) assert newIrc.callbacks is irc.callbacks, 'callbacks list is different' irc.replySuccess('Connection to %s initiated.' % network) - connect = wrap(connect, ['owner', 'something', additional('something'), + connect = wrap(connect, ['owner', getopts({'ssl': ''}), 'something', + additional('something'), additional('something', '')]) def disconnect(self, irc, msg, args, otherIrc, quitMsg): diff --git a/plugins/Owner/plugin.py b/plugins/Owner/plugin.py index e231db70f..384958823 100644 --- a/plugins/Owner/plugin.py +++ b/plugins/Owner/plugin.py @@ -188,7 +188,7 @@ class Owner(callbacks.Plugin): callbacks.IrcObjectProxy._mores.clear() self.__parent.reset() - def _connect(self, network, serverPort=None, password=''): + def _connect(self, network, serverPort=None, password='', ssl=False): try: group = conf.supybot.networks.get(network) (server, port) = group.servers()[0] @@ -196,7 +196,7 @@ class Owner(callbacks.Plugin): if serverPort is None: raise ValueError, 'connect requires a (server, port) ' \ 'if the network is not registered.' - conf.registerNetwork(network, password) + conf.registerNetwork(network, password, ssl) serverS = '%s:%s' % serverPort conf.supybot.networks.get(network).servers.append(serverS) assert conf.supybot.networks.get(network).servers(), \ diff --git a/src/conf.py b/src/conf.py index 5035e051e..fbf3cd376 100644 --- a/src/conf.py +++ b/src/conf.py @@ -259,7 +259,7 @@ class SpaceSeparatedSetOfChannels(registry.SpaceSeparatedListOf): else: return ircmsgs.join(channel) -def registerNetwork(name, password=''): +def registerNetwork(name, password='', ssl=False): network = registerGroup(supybot.networks, name) registerGlobalValue(network, 'password', registry.String(password, """Determines what password will be used on %s. Yes, we know that @@ -271,7 +271,7 @@ def registerNetwork(name, password=''): completed.""" % name)) registerGlobalValue(network, 'channels', SpaceSeparatedSetOfChannels([], """Determines what channels the bot will join only on %s.""" % name)) - registerGlobalValue(network, 'ssl', registry.Boolean(False, + registerGlobalValue(network, 'ssl', registry.Boolean(ssl, """Determines whether the bot will attempt to connect with SSL sockets to %s.""" % name)) registerChannelValue(network.channels, 'key', registry.String('',