当前位置: 首页>>代码示例>>Python>>正文


Python client.XMPPClient类代码示例

本文整理汇总了Python中wokkel.client.XMPPClient的典型用法代码示例。如果您正苦于以下问题:Python XMPPClient类的具体用法?Python XMPPClient怎么用?Python XMPPClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XMPPClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect

    def connect(self):
        application = service.Application('UniblabXMPP')

        xmppclient = XMPPClient(jid.internJID(self.xmpp_user), self.xmpp_pass)
        self.client=UniblabXMPPProtocol()
        self.client.transport = self
        self.client.setHandlerParent(xmppclient)
        xmppclient.setServiceParent(application)

        xmppclient.startService()
开发者ID:hogrewe,项目名称:uniblab,代码行数:10,代码来源:xmpp_transport.py

示例2: connect

    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
开发者ID:B-Rich,项目名称:Watson,代码行数:10,代码来源:gbot.py

示例3: StatusProxy

class StatusProxy(object):
    def __init__(self, username, password, host='talk.google.com'):
        self.client = XMPPClient(JID(username), password,host)
        self.presence = PresenceFetcher()
        self.presence.setHandlerParent(self.client)
        self.client.startService()

    def getStatuses(self, account):
        if isinstance(account, str):
            account = JID(account)
        return self.presence.doProbe(account)
开发者ID:stillinbeta,项目名称:statusbot,代码行数:11,代码来源:presence.py

示例4: setupConnection

    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
开发者ID:joaquincasares,项目名称:cassbot,代码行数:12,代码来源:xmppbot.py

示例5: makeService

    def makeService(self, options):
        """
        Make services to handle push event notifications.
        """
        # check confguration file is specified and exists
        if not options["config"]:
            raise ValueError('Configuration file not specified (try to check --help option)')
        cfgFileName = options["config"];
        if not os.path.isfile(cfgFileName):
            raise ValueError('Configuration file not found:', cfgFileName)

        # read configuration file
        cfg = ConfigParser()
        cfg.read(cfgFileName)

        # create Twisted application
        application = service.Application("gitlab-webhook-xmpp")
        serviceCollection = service.IServiceCollection(application)

        # create XMPP client
        client = XMPPClient(JID(cfg.get('xmpp', 'jid')), cfg.get('xmpp', 'password'))
#         client.logTraffic = True
        client.setServiceParent(application)
        # join to all MUC rooms
        nickname = cfg.get('xmpp', 'nickname') if cfg.has_option('xmpp', 'nickname') else DEFAULT_NICKNAME
        notifications = cfg.items('notifications')
        for room, repositoryMasks in notifications:
            mucHandler = MUCHandler(JID(room), nickname, repositoryMasks.split(','))
            mucHandler.setHandlerParent(client)
            self.mucHandlers.append(mucHandler)

        templateLoader = None
        if cfg.has_option('message', 'template'):
            templateFullName = cfg.get('message', 'template')
            templatePath, self.templateName = os.path.split(templateFullName)
            templateLoader = FileSystemLoader(templatePath)
        else:
            self.templateName = DEFAULT_TEMPLATE_NAME
            templateLoader = PackageLoader('xmpp_webhook', 'templates')
        self.templateEnvironment = Environment(loader=templateLoader, extensions=['jinja2.ext.i18n'])
        self.templateEnvironment.install_null_translations() # use i18n to pluralize only

        # create web hook handler
        rootHttpResource = Resource()
        rootHttpResource.putChild('', WebHookHandler(self))
        site = server.Site(rootHttpResource)
        httpPort = cfg.getint('http', 'port') if cfg.has_option('http', 'port') else DEFAULT_HTTP_PORT
        httpServer = internet.TCPServer(httpPort, site)
        httpServer.setServiceParent(serviceCollection)

        return serviceCollection
开发者ID:3cky,项目名称:gitlab-webhook-xmpp,代码行数:51,代码来源:xmpp_webhook_plugin.py

示例6: createService

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
开发者ID:Urthen,项目名称:Fritbot_Python,代码行数:14,代码来源:jabber.py

示例7: start_services

def start_services(config):
    client = XMPPClient(jid.internJID(config.credentials['jid']), config.credentials['password'])

    application = service.Application('commitbot')

    bot = CommitBot(config)
    bot.setHandlerParent(client)

    site = server.Site(WebHook(config, bot))
    tcp_server = reactor.listenTCP(8888, site)

    app.startApplication(application, None)
    client.startService()

    reactor.run()
开发者ID:pferreir,项目名称:commitbot,代码行数:15,代码来源:app.py

示例8: __init__

    def __init__(self, root, parent):
        self.root = root
        self.parent = parent
        self.logger = logging.getLogger("xmppClient")
        self.config = self.root.getServiceNamed('config')
        self.config.set("enabled", False, "main", network="xmpp")
        service.MultiService.__init__(self)
        self.protocol=None
        try:
            self.myjid=self.config.get("jid", "", "main.xmppClient")
            password=self.config.get("password", "", "main.xmppClient")
            if not (self.myjid and password):
                self.logger.warn("please set main.xmppClient.jid "+\
                    "and main.xmppClient.password")
                return
            self.client = XMPPClient(jid.internJID(self.myjid+"/otfbot"), password)
            self.client.logTraffic = False
            self.protocol=Bot(root, self)
            self.messageProtocol=myMessageProtocol(self.protocol)
            self.messageProtocol.setHandlerParent(self.client)
            self.presenceClientProtocol=myPresenceClientProtocol(self.protocol)
            self.presenceClientProtocol.setHandlerParent(self.client)
            self.rosterClientProtocol=myRosterClientProtocol(self.protocol)
            self.rosterClientProtocol.setHandlerParent(self.client)

            self.protocol.messageProtocol=self.messageProtocol
            self.protocol.rosterClientProtocol=self.rosterClientProtocol
            self.protocol.presenceClientProtocol=self.presenceClientProtocol

            self.client.setServiceParent(self)
        except Exception, e:
            self.logger.error(e)
开发者ID:otfbot,项目名称:otfbot,代码行数:32,代码来源:xmppClient.py

示例9: makeService

    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
开发者ID:our-city-app,项目名称:mobicage-xmpp-service-forwarder,代码行数:17,代码来源:forwarder_plugin.py

示例10: __init__

 def __init__(self):
     self.client = XMPPClient(JID(config.JABBER_CLIENT_USER),
                              config.JABBER_CLIENT_PASS,
                              config.JABBER_CLIENT_HOST)
     self.presenceFetcher = PresenceFetcher()
     self.presenceFetcher.setHandlerParent(self.client)
     self.tweeter = Tweeter()
     self.loopingCall = LoopingCall(self.makeRequest)
开发者ID:stillinbeta,项目名称:statusbot,代码行数:8,代码来源:service.py

示例11: makeService

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
开发者ID:mediamatic,项目名称:ikdisplay,代码行数:18,代码来源:xmpp.py

示例12: initIrcJabberRelay

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)
开发者ID:atorkhov,项目名称:ircjabberrelay,代码行数:18,代码来源:manager.py

示例13: StatusBotService

class StatusBotService(service.Service):
    def __init__(self):
        self.client = XMPPClient(JID(config.JABBER_CLIENT_USER),
                                 config.JABBER_CLIENT_PASS,
                                 config.JABBER_CLIENT_HOST)
        self.presenceFetcher = PresenceFetcher()
        self.presenceFetcher.setHandlerParent(self.client)
        self.tweeter = Tweeter()
        self.loopingCall = LoopingCall(self.makeRequest)

    def startService(self):
        service.Service.startService(self)
        self.client.startService()
        self.loopingCall.start(config.REFRESH_INTERVAL_SECS)

    def stopService(self):
        service.Service.stopService(self)
        self.loopingCall.stop()
        self.client.stopService()

    def makeRequest(self):
        d = self.presenceFetcher.doProbe(config.JABBER_TARGET)
        d.addCallbacks(self._sendTweet, log.err)
        return d

    def _sendTweet(self, statuses):
        if not statuses:
            log.msg("No statuses received")
            return succeed(None)
        else:
            d = self.tweeter.tweet(statuses[0])
            d.addCallback(self._receiveTweetResponse)
            return d

    def _receiveTweetResponse(self, result):
        code, body = result
        # 403 is probably a duplicate tweet
        if code == 200:
            decoded = json.loads(body)
            log.msg("Tweeted new status: " + decoded['text'])
        elif code == 403:
            log.msg("Duplicate tweet, ignoring")
        else:
            log.err("Error tweeting {}: {}".format(code, body))
开发者ID:stillinbeta,项目名称:statusbot,代码行数:44,代码来源:service.py

示例14: make_client

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
开发者ID:mahmoudimus,项目名称:ircer,代码行数:19,代码来源:hipbot.py

示例15: makeService

    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
开发者ID:lorenzhs,项目名称:kitbot,代码行数:58,代码来源:kitbot_plugin.py


注:本文中的wokkel.client.XMPPClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。