src/conf, plugins/Owner, plugins/Network: Add support for specifying an ssl connection via Network.connect.

This commit is contained in:
James Vega 2005-12-14 04:20:04 +00:00
parent 97fdd164ae
commit 0af83d2e24
3 changed files with 11 additions and 9 deletions

View File

@ -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):
"""<network> [<host[:port]>] [<password>]
def connect(self, irc, msg, args, opts, network, server, password):
"""[--ssl] <network> [<host[:port]>] [<password>]
Connects to another network (which will be represented by the name
provided in <network>) at <host:port>. 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):

View File

@ -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(), \

View File

@ -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('',