Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - from twisted.application import internet, service
 - from twisted.internet import protocol, reactor, defer
 - from twisted.words.protocols import irc
 - from twisted.protocols import basic
 - from twisted.web import resource, server, static
 - from twisted.internet.protocol import Protocol
 - class ircProtocol(irc.IRCClient):
 - def _get_nickname(self):
 - return self.factory.nickname
 - nickname = property(_get_nickname)
 - def signedOn(self):
 - self.join(self.factory.channel)
 - # def privmsg(self, user, channel, msg):
 - # user = user.split('!')[0]
 - # d = self.factory.msgAlert(msg)
 - # def onError(err):
 - # return 'Internal error in server'
 - # d.addErrback(onError)
 - # def writeResponse(message):
 - # irc.IRCClient.msg(self, channel, msg+': '+message)
 - # d.addCallback(writeResponse)
 - # def msgAlert(self, alert):
 - # self.factory.
 - def dupa1(self, msg):
 - print msg
 - #irc.IRCClient.msg(self, '#asdf666', msg)
 - self.IRCClient.msg('#asdf666', msg)
 - class ircFactory(protocol.ClientFactory):
 - protocol = ircProtocol
 - def __init__(self, nickname, channel):
 - self.nickname = nickname
 - self.channel = channel
 - def dupa(self, msg):
 - self.protocol.dupa1(msg)
 - # def msgAlert(self, alert):
 - # print "alert=> " + alert
 - class nagiosProtocol(Protocol):
 - def connectionMade(self):
 - print "New connection from nagios"
 - def connectionLost(self, reason):
 - print "Lost connection from nagios: %s" % reason
 - def dataReceived(self, line):
 - self.factory.irc.dupa(line)
 - class nagiosFactory(protocol.ServerFactory):
 - protocol = nagiosProtocol
 - def __init__(self, irc):
 - self.irc = irc
 - # def sendAlert(self, alert):
 - # print "sendAlert"
 - # self.ircFactory.msgAlert(alert)
 - #b = internet.TCPServer(6666, nagiosFactory())
 - #b.setName('fnagios')
 - #b.setServiceParent(myservice)
 - #myservice.setServiceParent(application)
 - application = service.Application("dupa")
 - ircf = ircFactory('asdfasdf', '#asdf666')
 - irc = internet.TCPClient('irc.freenode.net', 6667, ircf)
 - irc.setName('irc')
 - irc.setServiceParent(application)
 - nagios = internet.TCPServer(6666, nagiosFactory(ircf))
 - nagios.setName("Nagios")
 - nagios.setServiceParent(application)
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment