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


Python jid.internJID函数代码示例

本文整理汇总了Python中twisted.words.protocols.jabber.jid.internJID函数的典型用法代码示例。如果您正苦于以下问题:Python internJID函数的具体用法?Python internJID怎么用?Python internJID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: resetHistory

 def resetHistory(self, room=None, frm=None):
     if room != None:
         # room needs to be a returned room hash from the backend
         if self.checkAdmin(room, jid.internJID(frm).userhost()):
             self.parent._clean_up_history(True, room['name'])
     elif jid.internJID(frm).userhost() in self.sadmins:
         self.HISTORY = {}
开发者ID:fritteli,项目名称:palaver,代码行数:7,代码来源:groupchat.py

示例2: _onDiscoItems

    def _onDiscoItems(self, iq):
        requestor = jid.internJID(iq["from"])
        target = jid.internJID(iq["to"])
        nodeIdentifier = iq.query.getAttribute("node", '')

        def toResponse(results):
            items = []
            for i in results:
                items.extend(i[1])

            response = domish.Element((NS_ITEMS, 'query'))

            for item in items:
                response.addChild(item)

            return response

        dl = []
        for handler in self.parent:
            if IDisco.providedBy(handler):
                dl.append(handler.getDiscoItems(requestor, target,
                                                nodeIdentifier))

        d = defer.DeferredList(dl, fireOnOneErrback=1, consumeErrors=1)
        d.addCallbacks(toResponse, self._error)
        return d
开发者ID:Urthen,项目名称:Legacy-FritBot,代码行数:26,代码来源:disco.py

示例3: cb

 def cb(subs):
     actual = [a.toElement().toXml() for a in subs]
     expected = [
         ps.Subscription(
             nodeIdentifier='node1',
             subscriber=jid.internJID('[email protected]').userhostJID(),
             state='subscribed'),
         ps.Subscription(
             nodeIdentifier='node2',
             subscriber=jid.internJID('[email protected]').userhostJID(),
             state='subscribed'),
         ps.Subscription(
             nodeIdentifier='node5',
             subscriber=jid.internJID('[email protected]').userhostJID(),
             state='unconfigured'),
         ps.Subscription(
             nodeIdentifier='node6',
             subscriber=jid.internJID('[email protected]').userhostJID(),
             state='subscribed',
             subscriptionIdentifier='123-abc'),
         ps.Subscription(
             nodeIdentifier='node6',
             subscriber=jid.internJID('[email protected]').userhostJID(),
             state='subscribed',
             subscriptionIdentifier='004-yyy'),
         ]
     self.assertEquals(len(actual), 5)
     for ex in expected:
         self.assertIn(ex.toElement().toXml(), actual)
     sendMock.assert_called_once_with(xs)
开发者ID:wyn,项目名称:collab,代码行数:30,代码来源:pubsubRequestWithAffiliationsTests.py

示例4: _onDiscoInfo

    def _onDiscoInfo(self, iq):
        """
        Called for incoming disco info requests.

        @param iq: The request iq element.
        @type iq: L{Element<twisted.words.xish.domish.Element>}
        """
        requestor = jid.internJID(iq["from"])
        target = jid.internJID(iq["to"])
        nodeIdentifier = iq.query.getAttribute("node", '')

        def toResponse(info):
            if nodeIdentifier and not info:
                raise error.StanzaError('item-not-found')
            else:
                response = DiscoInfo()
                response.nodeIdentifier = nodeIdentifier

                for item in info:
                    response.append(item)

            return response.toElement()

        d = self.info(requestor, target, nodeIdentifier)
        d.addCallback(toResponse)
        return d
开发者ID:B-Rich,项目名称:wokkel,代码行数:26,代码来源:disco.py

示例5: _onDiscoInfo

    def _onDiscoInfo(self, iq):
        requestor = jid.internJID(iq["from"])
        target = jid.internJID(iq["to"])
        nodeIdentifier = iq.query.getAttribute("node", '')

        def toResponse(results):
            info = []
            for i in results:
                info.extend(i[1])

            if nodeIdentifier and not info:
                raise error.StanzaError('item-not-found')
            else:
                response = domish.Element((NS_INFO, 'query'))

                for item in info:
                    response.addChild(item)

            return response

        dl = []
        for handler in self.parent:
            if IDisco.providedBy(handler):
                dl.append(handler.getDiscoInfo(requestor, target,
                                               nodeIdentifier))

        d = defer.DeferredList(dl, fireOnOneErrback=1, consumeErrors=1)
        d.addCallbacks(toResponse, self._error)
        return d
开发者ID:Urthen,项目名称:Legacy-FritBot,代码行数:29,代码来源:disco.py

示例6: dispatch

    def dispatch(self, xs, stanza):
        """
        Send a stanza to the router, checking some stuff first.
        """

        log.debug("stanza from %s: %s" % (xs.otherEntity.full(), stanza.toXml()))
        util.resetNamespace(stanza, xs.namespace)
        stanzaFrom = stanza.getAttribute('from')
        stanzaTo = stanza.getAttribute('to')

        if not stanza.bind and not stanzaFrom or not stanzaTo:
            xs.sendStreamError(error.StreamError('improper-addressing'))
        else:
            try:
                sender = jid.internJID(stanzaFrom)
                jid.internJID(stanzaTo)
            except jid.InvalidFormat:
                log.debug("dropping stanza with malformed JID")

            log.debug("sender = %s, otherEntity = %s" % (sender.full(), xs.otherEntity.full()))

            try:
                unused, host = util.jid_component(sender.host)
                if host in self.keyring.hostlist():
                    self.router.send(stanza)
                else:
                    raise Exception()
            except:
                xs.sendStreamError(error.StreamError('invalid-from'))
开发者ID:MilanovicB,项目名称:xmppserver,代码行数:29,代码来源:net.py

示例7: test_identity

 def test_identity(self):
     """
     Test that two interned JIDs yield the same object.
     """
     j1 = jid.internJID("[email protected]")
     j2 = jid.internJID("[email protected]")
     self.assertIdentical(j1, j2)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:7,代码来源:test_jabberjid.py

示例8: incomingIq

	def incomingIq(self, el):
		itype = el.getAttribute("type")
		fro = el.getAttribute("from")
		froj = internJID(fro)
		to = el.getAttribute("to")
		toj = internJID(to)
		ID = el.getAttribute("id")
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:7,代码来源:pubsub.py

示例9: dispatch

    def dispatch(self, xs, stanza):
        """
        Send a stanza to the router, checking some stuff first.
        """

        log.debug("stanza from %s: %s" % (xs.otherEntity.full(), stanza.toXml()))
        util.resetNamespace(stanza, xs.namespace)
        stanzaFrom = stanza.getAttribute('from')
        stanzaTo = stanza.getAttribute('to')

        if not stanzaFrom or not stanzaTo:
            xs.sendStreamError(error.StreamError('improper-addressing'))
        else:
            try:
                sender = jid.internJID(stanzaFrom)
                jid.internJID(stanzaTo)
            except jid.InvalidFormat:
                log.debug("dropping stanza with malformed JID")

            log.debug("sender = %s, otherEntity = %s" % (sender.full(), xs.otherEntity.full()))
            if sender.host != xs.otherEntity.host and sender.host != self.defaultDomain:
                xs.sendStreamError(error.StreamError('invalid-from'))
            else:
                # replace to with destination
                destination = stanza.getAttribute('destination')
                if destination:
                    stanza['to'] = destination
                    del stanza['destination']
                self.router.send(stanza)
开发者ID:BillTheBest,项目名称:xmppserver,代码行数:29,代码来源:net.py

示例10: createRoom

    def createRoom(self, room, frm, nick, status = None, show = None, legacy = True, host=None):
        """
        Create and join the room
        """

        def created(rname):
            self.parent.HISTORY[room] = []
            return self.joinRoom(room, frm, nick,
                                 status = status,
                                 show   = show,
                                 legacy = legacy,
                                 host   = host,
                                 do_check = False)

        def create_room(doCreate, error_code=NotAllowed):
            if not doCreate:
                raise error_code

            d = self.parent.storage.createRoom(room, jid.internJID(frm).userhost(), legacy=legacy, host=host)
            d.addCallback(created)
            return d

        if self.create_rooms == 1 or jid.internJID(frm).userhost() in self.sadmins:
            if self.plugins and self.plugins.has_key('create-room'):
                d = self.plugins['create-room'].create(room, jid.internJID(frm).userhost(), legacy=legacy, host=host)
                d.addCallback(create_room, error_code = NotMember)
            else:
                d = create_room(True)

            return d
        else:
            raise NotAllowed
开发者ID:fritteli,项目名称:palaver,代码行数:32,代码来源:groupchat.py

示例11: set_kick

        def set_kick(r, user):
            if self.checkAdmin(r, admin):
                kuser = None
                if self.checkOwner(r, user):
                    raise NotAllowed
                user_check = jid.internJID(user).userhost().lower()
                for u in r['roster'].values():
                    if jid.internJID(u['jid']).userhost().lower() == user_check \
                           or u['nick'] == user:
                        kuser = u['jid']
                        knick = u['nick']
                        if self.checkSelf(user, admin):
                            raise NotAllowed

                        if self.checkAdmin(r, user):
                            raise NotAllowed
                        r['roster'][u['jid'].lower()]['role'] = 'none'
                        r['roster'][u['jid'].lower()]['affiliation'] = 'none'
                        break
                if not kuser:
                    raise RoomNotFound
                d = self.parent.storage.partRoom(room, kuser, knick, host=host)
                d.addCallback(ret_kick, room, r['roster'])
                d.addErrback(lambda x: self.error(NotAllowed, x))
                return d
            else:
                raise NotAllowed
开发者ID:fritteli,项目名称:palaver,代码行数:27,代码来源:groupchat.py

示例12: _check_sadmin

 def _check_sadmin(self, room, user):
     juser = jid.internJID(user).userhost().lower()
     members = self.sadmins
     for m in members:
         if jid.internJID(m).userhost().lower() == juser:
             return True
     return False
开发者ID:fritteli,项目名称:palaver,代码行数:7,代码来源:groupchat.py

示例13: valid

 def valid(xs):
     reply('valid')
     if not self.xmlstream.thisEntity:
         self.xmlstream.thisEntity = jid.internJID(receivingServer)
     self.xmlstream.otherEntity = jid.internJID(originatingServer)
     self.xmlstream.dispatch(self.xmlstream,
                             xmlstream.STREAM_AUTHD_EVENT)
开发者ID:thepaul,项目名称:wokkel,代码行数:7,代码来源:server.py

示例14: incomingRegisterIq

 def incomingRegisterIq(self, incoming):
     # Check what type the Iq is..
     itype = incoming.getAttribute("type")
     LogEvent(INFO)
     if itype == "get":
         if config.authRegister:
             # Check to see if they're registered
             source = internJID(incoming.getAttribute("from")).userhost()
             result = self.pytrans.xdb.getRegistration(source)
             if result:
                 self.sendRegistrationFields(incoming)
             else:
                 # Must first submit local credentials
                 self.sendLocalRegistrationFields(incoming)
         else:
             # Send real registration form
             self.sendRegistrationFields(incoming)
     elif itype == "set":
         if config.authRegister:
             # Check to see if they're registered by local credentials
             source = internJID(incoming.getAttribute("from")).userhost()
             result = self.pytrans.xdb.getRegistration(source)
             username = ""
             password = ""
             if result:
                 username, password = result
             if username == "local" and password == "local":
                 # Update real credentials
                 self.updateRegistration(incoming)
             else:
                 # Must first validate local credentials
                 self.validateLocalRegistration(incoming)
         else:
             # Update real credentials
             self.updateRegistration(incoming)
开发者ID:2mf,项目名称:pyicqt,代码行数:35,代码来源:register.py

示例15: handle_action

    def handle_action(self, action):
        self.log.debug('XMPP ACTION : {0!r}'.format(action))

        if action.action_type != 'message':
            return

        body = str(action.meta.get('body'))
        if not body:
            return

        if not action.destination_rooms:
            return

        for room in action.destination_rooms:
            if action.scope == 'public':
                room_jid = jid.internJID(room)
                message = muc.GroupChat(recipient=room_jid, body=body)
                self.client.send(message.toElement())

            if action.scope == 'private':
                if room is not None:
                    msg = xmppim.Message(recipient=jid.internJID(room),
                                         sender=self.bot_jid,
                                         body=body)
                    self.client.send(msg.toElement())
开发者ID:xlcteam,项目名称:brutal-ng,代码行数:25,代码来源:xmpp.py


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