Ejemplo n.º 1
0
 def getFactory(self):
     factory = protocol.ReconnectingClientFactory()
     factory.protocol = DjangoBotProtocol
     factory.channels = self.channels
     factory.nickname, factory.password = self.nickname, self.password
     # create a channel for private messages
     factory.channels.add(Channel(self.nickname, self.nickname,
                                  joined=True))
     return factory
Ejemplo n.º 2
0
def main():
    log.startLogging(sys.stdout)

    blinkenlights = protocol.ReconnectingClientFactory()
    blinkenlights.protocol = BlinkenlightsProtocol
    reactor.connectTCP("towel.blinkenlights.nl", 23, blinkenlights)

    reactor.listenTCP(8888, Application(), interface="127.0.0.1")
    reactor.run()
Ejemplo n.º 3
0
	def start(self):
		if not self.active:
			self.active = True
			factory = protocol.ReconnectingClientFactory()
			factory.initialDelay = 5
			factory.maxDelay = 5
			factory.protocol = TopicClientProtocol
			factory.owner = self
			self.connector = reactor.connectTCP(self.host, self.port, factory,
												timeout=self.timeout_connect)
Ejemplo n.º 4
0
    def createClient(self, endpoint):
        """
        Create an instance of the Client which connects to the
        destination server.
        """
        factory = protocol.ReconnectingClientFactory()
        factory.protocol = ClientProtocol
        factory.server = self

        # Connect client 'factory' to the destination
        logger.debug('Creating connection to endpoint.')
        d = endpoint.connect(factory)
        reactor.callLater(30, d.cancel)
Ejemplo n.º 5
0
def main():
    f = protocol.ReconnectingClientFactory()
    f.protocol = Doge

    reactor.connectTCP(serv_ip, serv_port, f)
    reactor.run()
Ejemplo n.º 6
0
def main():
    f = protocol.ReconnectingClientFactory()
    f.protocol = LoggingIRCClient
    reactor.connectTCP('irc.freenode.net', 6667, f)
    reactor.run()
Ejemplo n.º 7
0
 def main(self):
     f = protocol.ReconnectingClientFactory()
     f.protocol = burnBot
     serv_ip, serv_port = self.get_server_info()
     reactor.connectTCP(serv_ip, serv_port, f)
     reactor.run()
Ejemplo n.º 8
0
class Coriolis(irc.IRCClient):
    def connectionMade(self):
        irc.IRCClient.connectionMade(self)

    def connectionLost(self, reason):
        irc.IRCClient.connectionLost(self, reason)

    f = protocol.ReconnectingClientFactory()
    f.protocol = irc

    def signedOn(self):

        network = self.factory.network

        if network['identity']['nickserv_pw']:
            self.msg('NickServ',
                     'IDENTIFY %s' % network['identity']['nickserv_pw'])

        for channel in network['autojoin']:
            print('join channel %s' % channel)
            self.join(channel)

    def irc_MODE(self, user, params):
        """
        Parse a server mode change message, altered to support slack irc gateway
        """
        channel, modes, args = params[0], params[1], params[2:]

        if modes[0] not in '-+':
            modes = '+' + modes

        if channel == self.nickname:
            # This is a mode change to our individual user, not a channel mode
            # that involves us.
            paramModes = self.getUserModeParams()
        else:
            paramModes = self.getChannelModeParams()

        try:
            added, removed = _parseModes(modes, args, paramModes)
        except irc.IRCBadModes:
            log.err(
                None, 'An error occurred while parsing the following '
                'MODE message: MODE %s' % (' '.join(params), ))
        else:
            if added:
                modes, params = zip(*added)
                self.modeChanged(user, channel, True, ''.join(modes), params)

            if removed:
                modes, params = zip(*removed)
                self.modeChanged(user, channel, False, ''.join(modes), params)

    @profiler.time_execution
    def parseCommand(self, usr, msg, chan):

        plgname = msg.split()[0].replace("!", "")
        plugins = Loader()
        for plugin in plugins.load():
            plg = plugins.get(plugin)

            if msg.startswith(("!" + plugin["name"])):
                args = msg.replace(("!" + plugin["name"]), "")
                self.current_chan = chan
                result = plg.do(args, coriolis=self)
                if result:
                    self.msg(chan, result)

    def joined(self, channel):
        print('joined channel')

    def privmsg(self, user, channel, msg):
        print('[%s] <%s> %s' % (channel, user, msg))
        usr = user.split('!', 2)[0].replace('.', '')
        worker.do_work(self.parseCommand(usr, msg, channel))

    def alterCollidedNick(self, nickname):
        return nickname + '_'

    def _get_nickname(self):
        return self.factory.network['identity']['nickname']

    def _get_realname(self):
        return self.factory.network['identity']['realname']

    def _get_username(self):
        return self.factory.network['identity']['username']

    def _get_password(self):
        if self.factory.network['identity']['server_pw']:
            return self.factory.network['identity']['server_pw']
        else:
            return ""

    nickname = property(_get_nickname)
    realname = property(_get_realname)
    username = property(_get_username)
    password = property(_get_password)
Ejemplo n.º 9
0
def main():
    f = protocol.ReconnectingClientFactory()
    f.protocol = IRCLogger
    reactor.connectTCP('localhost', 6667, f)
    reactor.run()
Ejemplo n.º 10
0
 def getIRCBot(self, nickname):
     f = protocol.ReconnectingClientFactory()
     f.protocol = IRCReplyBot
     f.nickname = nickname
     f.getUser = self.getUser
     return f
Ejemplo n.º 11
0
def main():
    f = protocol.ReconnectingClientFactory()
    f.protocol = hangman
    
    reactor.connectTCP("coop.test.adtran.com", 6667, f)
    reactor.run()