from twisted.internet.protocol import ServerFactory, ClientFactory
from twisted.application.internet import TCPServer, TCPClient, SSLClient
from twisted.application.service import Application
from twisted.internet.ssl import ClientContextFactory

from publishbot import Listener, Publisher
import config


application = Application("publishbot")

sf = ServerFactory()
sf.protocol = Listener

cf = ClientFactory()
cf.protocol = Publisher
cf.queued = []
cf.connection = None

sf.publisher = cf

TCPServer(config.LISTENER_PORT, sf).setServiceParent(application)
if config.SSL_IRC:
    ircservice = SSLClient(config.IRC_SERVER, config.IRC_PORT, cf,
                           ClientContextFactory())
else:
    ircservice = TCPClient(config.IRC_SERVER, config.IRC_PORT, cf)

ircservice.setServiceParent(application)

@@ -46,16 +46,28 @@
 actory, 
+Reconnecting
 ClientFa
@@ -402,16 +402,28 @@
 r%0A%0Acf = 
+Reconnecting
 ClientFa

use ReconnectingClientFactory for more resilient IRC connections.