Ejemplo n.º 1
0
    def makeService(self, options):
        with open(options.config, "r") as config_file:
            config = json.load(config_file)

        root = resource.Resource()
        root.putChild('jsMath', static.File(config["global"]["jsmath"]))

        bot = service.MultiService()
        xmppclient = XMPPClient(JID(config["global"]["jid"]),
                                config["global"]["password"])
        xmppclient.logTraffic = options['verbose']
        xmppclient.setServiceParent(bot)
        xmppclient.dbpool = DatabaseRunner(config["global"]["database"])
        xmppclient.rooms = dict()

        xmlrpc_port = config["global"].get("xml-rpc-port", None)
        if xmlrpc_port is not None:
            xmlrpcinterface = XMLRPCInterface(xmppclient)
            rpc = internet.TCPServer(xmlrpc_port, server.Site(xmlrpcinterface))
            rpc.setName('XML-RPC')
            rpc.setServiceParent(bot)

        for muc_config in config["mucs"]:
            room_jid = JID(muc_config["jid"])
            mucbot = KITBot(room_jid, muc_config.get("password", None),
                            config["global"]["logpath"])
            mucbot.setHandlerParent(xmppclient)

            if "xml-rpc-id" in muc_config:
                xmppclient.rooms[muc_config["xml-rpc-id"]] = mucbot

            # Log resource
            portal = Portal(
                LogViewRealm(os.path.join(config["global"]['logpath'],
                                          room_jid.user + '.log')),
                [strcred.makeChecker(muc_config["log-auth"])]
            )
            credential_factory = DigestCredentialFactory('md5', 'Hello Kitty!')
            auth_resource = HTTPAuthSessionWrapper(portal, [credential_factory])
            root.putChild(room_jid.user, auth_resource)

        httpd_log_view = internet.TCPServer(config["global"]["http-port"],
                                            server.Site(root))
        httpd_log_view.setServiceParent(bot)

        # REPL over SSH
        def makeREPLProtocol():
            namespace = dict(bot=xmppclient)
            return insults.ServerProtocol(manhole.ColoredManhole, namespace)
        repl_realm = manhole_ssh.TerminalRealm()
        repl_realm.chainedProtocolFactory = makeREPLProtocol
        repl_checker = checkers.SSHPublicKeyDatabase()
        repl_portal = Portal(repl_realm, [repl_checker])
        repl_factory = manhole_ssh.ConchFactory(repl_portal)
        repl = internet.TCPServer(config["global"]["ssh-port"], repl_factory)
        repl.setServiceParent(bot)

        return bot
Ejemplo n.º 2
0
    def connect(self):
        application = service.Application("gbot")

        xmppclient = XMPPClient(jid.internJID(self.username), self.password)
        xmppclient.logTraffic = False
        self.protocol = GBotProtocol()
        self.protocol.bot = self
        self.protocol.setHandlerParent(xmppclient)
        xmppclient.setServiceParent(application)
        return application
Ejemplo n.º 3
0
    def connect(self):
        application = service.Application("gbot")

        xmppclient = XMPPClient(jid.internJID(self.username), self.password)
        xmppclient.logTraffic = False
        self.protocol = GBotProtocol()
        self.protocol.bot = self
        self.protocol.setHandlerParent(xmppclient)
        xmppclient.setServiceParent(application)
        return application
Ejemplo n.º 4
0
    def setupConnection(self):
        xmppclient = XMPPClient(self.jid, self.password, self.jabber_server)
        xmppclient.logTraffic = False

        xmppbot = XMPPCassBot(self, self.state['nickname'])
        xmppbot.conference_server = self.conference_server
        xmppbot.setHandlerParent(xmppclient)

        xmppclient.setServiceParent(self)

        self.xmppbot = xmppbot
        self.xmppclient = xmppclient
Ejemplo n.º 5
0
    def __init__(self, myjid, mysecret):

        application = service.Application("Xmpp XiVO CTI")

        xmppclient = XMPPClient(jid.internJID(myjid), mysecret)
        xmppclient.setServiceParent(application)
        xmppclient.startService()
        xmppclient.logTraffic = DEBUG

        self.factory = xmppProtocol()
        self.factory.setHandlerParent(xmppclient)

        self.pubsub_factory = ctiPubSubClient(CONFIG["xmpp"]["jid"])
        self.pubsub_factory.setHandlerParent(xmppclient)
Ejemplo n.º 6
0
def createService():
    bot_jid = "{0}@{1}/{2}".format(cfg.connect.jabber.jid, cfg.connect.jabber.server, cfg.connect.jabber.resource)
    xmppclient = XMPPClient(jid.internJID(bot_jid), cfg.connect.jabber.password, cfg.connect.jabber.server)
    xmppclient.logTraffic = cfg.connect.jabber.log_traffic

    # Send some whitespace every once in a while to stay alive
    KeepAlive().setHandlerParent(xmppclient)

    # Hook chat instance into main app
    connection = JabberConnector()
    FritBot.bot.registerConnector(connection)
    connection.setHandlerParent(xmppclient)
    
    return xmppclient
    def makeService(self, options):
        """
        Construct a TCPServer from a factory defined in myproject.
        """

        multi_service = MultiService()
        from wokkel.client import XMPPClient
        from twisted.words.protocols.jabber import jid
        import forwarder

        xmppclient = XMPPClient(jid.internJID(options["account"]), options["password"])
        xmppclient.logTraffic = False
        bot = forwarder.ForwarderProtocol(options["uri"])
        bot.setHandlerParent(xmppclient)
        multi_service.addService(xmppclient)

        return multi_service
Ejemplo n.º 8
0
def initIrcJabberRelay(application):
    manager = RelayManager()

    # Configure IRC
    ircfactory = IrcBotFactory(manager, cfg["ircchannel"], cfg["ircnick"], manager.sendJabber)
    # point = TCP4ClientEndpoint(reactor, 'irc.freenode.net', 6667)
    # d = point.connect(ircfactory)
    # d.addCallback(gotProtocol)
    connector = internet.TCPClient(cfg["ircserver"], cfg["ircport"], ircfactory)
    connector.setServiceParent(application)

    # Configure Jabber
    xmppclient = XMPPClient(jid.internJID(cfg["jabberjid"]), cfg["jabberpass"])
    jabberbot = JabberBot(manager, cfg["jabberserver"], cfg["jabberchannel"], cfg["jabbernick"], manager.sendIRC)
    xmppclient.logTraffic = False
    jabberbot.setHandlerParent(xmppclient)
    xmppclient.setServiceParent(application)
    manager.setJabber(jabberbot)
Ejemplo n.º 9
0
def makeService(config):
    if IQ.timeout is None:
        IQ.timeout = 30

    xmppService = XMPPClient(config['jid'], config['secret'],
                             config.get('xmpp-host'),
                             config.get('xmpp-port', 5222))
    if config['verbose']:
        xmppService.logTraffic = True

    presenceHandler = PresenceHandler()
    presenceHandler.setHandlerParent(xmppService)

    pinger = Pinger(config['service'])
    pinger.setHandlerParent(xmppService)
    pinger.verbose = config['verbose']

    return xmppService
Ejemplo n.º 10
0
def make_client(config):

    keepalive = KeepAlive()
    keepalive.interval = config.getint('hipchat', 'keepalive.interval')
    xmppclient = XMPPClient(
        jid.internJID(config.get('hipchat', 'jabber_id')),
        config.get('hipchat', 'password')
    )
    xmppclient.logTraffic = config.getboolean('hipchat', 'logtraffic')

    mucbot = HipBot(
        config.get('hipchat', 'server'),
        config.get('hipchat', 'channel'),
        config.get('hipchat', 'botnick'),
        config.get('hipchat', 'stfu_minutes'))
    mucbot.setHandlerParent(xmppclient)
    keepalive.setHandlerParent(xmppclient)

    return xmppclient
Ejemplo n.º 11
0
def make_client(bot, config, password):
    keepalive = KeepAlive()
    keepalive.interval = 30
    xmppclient = XMPPClient(jid.internJID(config.get("hipchat", "jid")), password)
    xmppclient.logTraffic = True

    team_members = [n.strip() for n in config.get("team", "members").decode("utf-8").strip().split(u",")]

    mucbot = HipchatBot(
        bot,
        config.get("hipchat", "room_server"),
        config.get("hipchat", "room_jid"),
        config.get("team", "room_name"),
        config.get("hipchat", "nickname"),
        config.get("hipchat", "stfu_minutes"),
        team_members,
    )
    mucbot.setHandlerParent(xmppclient)
    keepalive.setHandlerParent(xmppclient)

    return xmppclient
Ejemplo n.º 12
0
# Configuration parameters
config = ConfigParser.RawConfigParser()
config.read('bot.conf')

myJID = JID(config.get('Connection', 'my_jid'))
roomJID = JID(config.get('Connection', 'room_jid'))
roomPassword = config.get('Connection', 'room_password')

my_nick = config.get('Connection', 'my_nick')
my_secret = config.get('Connection', 'my_secret')

rt_url = config.get('RT', 'url')
rt_display_url = config.get('RT','display_url')
rt_user = config.get('RT', 'user')
rt_pwd = config.get('RT', 'pwd')
rt_default_queue = config.get('RT','default_queue')

LOG_TRAFFIC = False
#LOG_TRAFFIC = True

# Set up the Twisted application
application = service.Application("MUC Client")

client = XMPPClient(myJID, my_secret)
client.logTraffic = LOG_TRAFFIC
client.setServiceParent(application)

mucHandler = RTBot(roomJID, my_nick, rt_url, rt_user, rt_pwd, roomPassword, rt_display_url, output_format)
mucHandler.setHandlerParent(client)
Ejemplo n.º 13
0
            output = (self.PACKET.get_packet(packet_id), None)  # Return status.

        return output

    def abort_job(self, vm_jid, job_id):
        """ Terminate a job. """

        self.__send__(self.abort_job_packet(vm_jid, job_id))

    def terminate_vm(self, vm_jid):
        """ Terminate a VM. """

        self.__send__(packet)


# Misc.

if __name__ == "__main__":
    FARM_JID = raw_input("Farm JID: ")
    MY_JID = raw_input("My JID: ")
    PASSWORD = raw_input("My password: "******"TestVillein")

    test_villein = villein(MY_JID, PASSWORD, FARM_JID)
    xmpp_client = XMPPClient(test_villein.JID, PASSWORD)
    xmpp_client.logTraffic = False
    test_villein.setHandlerParent(xmpp_client)
    xmpp_client.setServiceParent(app)
Ejemplo n.º 14
0
               self.__send__(packet)

               output = (self.PACKET.get_packet(packet_id), None) # Return status.

          return output

     def abort_job(self, vm_jid, job_id):
          """ Terminate a job. """

          self.__send__(self.abort_job_packet(vm_jid, job_id))

     def terminate_vm(self, vm_jid):
          """ Terminate a VM. """

          self.__send__(packet)

# Misc.

if __name__ == "__main__":
     FARM_JID = raw_input("Farm JID: ")
     MY_JID = raw_input("My JID: ")
     PASSWORD = raw_input("My password: "******"TestVillein")

     test_villein = villein(MY_JID, PASSWORD, FARM_JID)
     xmpp_client = XMPPClient(test_villein.JID, PASSWORD)
     xmpp_client.logTraffic = False
     test_villein.setHandlerParent(xmpp_client)
     xmpp_client.setServiceParent(app)