當前位置: 首頁>>代碼示例>>Python>>正文


Python jid.JID類代碼示例

本文整理匯總了Python中twisted.words.protocols.jabber.jid.JID的典型用法代碼示例。如果您正苦於以下問題:Python JID類的具體用法?Python JID怎麽用?Python JID使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了JID類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __call__

 def __call__(self, user, prot, args):
     # For bare jids, we'll send what was requested,
     # but also look up the user and send it to any active resources
     self.ping(prot, user.jid, args)
     j = JID(args)
     if j.user and not j.resource:
         for rsrc in scheduling.resources(args):
             j.resource=rsrc
             self.ping(prot, user.jid, j.full())
開發者ID:Web5design,項目名稱:twitterspy,代碼行數:9,代碼來源:xmpp_commands.py

示例2: get_user

 def get_user(self, msg, session):
     jid = JID(msg["from"])
     try:
         rv = models.User.by_jid(jid.userhost(), session)
     except:
         print "Getting user without the jid in the DB (%s)" % jid.full()
         rv = models.User.update_status(jid.userhost(), None, session)
         self.subscribe(jid)
     return rv
開發者ID:pombredanne,項目名稱:whatsup,代碼行數:9,代碼來源:protocol.py

示例3: test_bosh_authentication

 def test_bosh_authentication(self):
     jid = JID('[email protected]')
     jid.resource = str(random.randint(0, 1000))
     client = BOSHClient(jid, 'admin', 'http://localhost:5280/http-bind/')
     self.assertTrue(client.startSession())
     rid = client.rid
     sid = client.sid
     self.assertTrue(rid is not None)
     self.assertTrue(sid is not None)
開發者ID:Blaastolen,項目名稱:jarn.xmpp.twisted,代碼行數:9,代碼來源:test_bosh.py

示例4: get_user

 def get_user(self, msg, session):
     jid = JID(msg['from'])
     try:
         user = models.User.by_jid(jid.userhost(), session)
     except:
         log.msg("Getting user without the jid in the DB (%s)" % jid.full())
         user = models.User.update_status(jid.userhost(), None, session)
         self.subscribe(jid)
     return user;
開發者ID:chanel5e,項目名稱:doubanbot,代碼行數:9,代碼來源:protocol.py

示例5: sendMessage

	def sendMessage(self, recipient: JID, sender: JID, text: str, messageType: str = "chat"):
		el = Element((None, "message"))
		el.attributes["to"] = recipient.full()
		el.attributes["from"] = sender.full()
		el.attributes["type"] = messageType

		body = el.addElement("body")
		body.addContent(escape(text))
		self.send(el)
開發者ID:vladamatena,項目名稱:h2x,代碼行數:9,代碼來源:h2x.py

示例6: _cb_subscribe_default_users

    def _cb_subscribe_default_users (self, r, ) :
        _dl = list()
        for i in constant.LDAP_USERS :
            _jid = JID("%[email protected]%s" % (i, self.parent.jid.host, ), )
            if _jid.userhost() == self.parent.jid.userhost() or _jid.userhost() in r :
                continue

            _dl.append(defer.maybeDeferred(self.subscribe, _jid, ), )

        return defer.DeferredList(_dl, )
開發者ID:srothan,項目名稱:io,代碼行數:10,代碼來源:data.py

示例7: __init__

 def __init__(self, context, request):
     super(MUCView, self).__init__(context, request)
     room = request.get('room', None)
     self.invitee = request.get('invitee', None)
     if room is not None:
         self.room_jid = JID(room)
     else:
         room = random.randint(0, 4294967295)
         registry = getUtility(IRegistry)
         self.room_jid = JID(registry['jarn.xmpp.conferenceJID'])
         self.room_jid.user = room
開發者ID:tkimnguyen,項目名稱:jarn.xmpp.core,代碼行數:11,代碼來源:muc.py

示例8: call_msg_handlers

 def call_msg_handlers(self, t, s, b, subject, stanza):
  if subject:
   j = JID(s)
   if not j.userhost() in self.g.keys():
    self.log.log('ignored subject from %s, stanza was %s' % (escape(s), escape(stanza.toXml())), 3)
   else:
    self.log.log('got subject from %s, stanza was %s, let\'s call topichandlers' % (escape(s), escape(stanza.toXml())), 1)
    for i in self.topichandlers: self.call(i, s, subject)
  else:
   for i in self.msghandlers:
    if (t == 'groupchat') or not i[1]: self.call(i[0], s, b)
開發者ID:BackupTheBerlios,項目名稱:freq-dev-svn,代碼行數:11,代碼來源:freq.py

示例9: __getVersion

 def __getVersion(self, sender: JID, recipient: JID, identifier: str):
     iq = Element((None, "iq"))
     iq.attributes["type"] = "result"
     iq.attributes["from"] = recipient.full()
     iq.attributes["to"] = sender.full()
     if identifier:
         iq.attributes["id"] = identifier
     query = iq.addElement("query")
     query.attributes["xmlns"] = "jabber:iq:version"
     query.addElement("name", content="h2x transport")
     query.addElement("version", content=0)
     self.h2x.send(iq)
開發者ID:vladamatena,項目名稱:h2x,代碼行數:12,代碼來源:iq.py

示例10: setUp

    def setUp(self):
        self.stub = XmlStreamStub()
        self.protocol = muc.MUCClient()
        self.protocol.xmlstream = self.stub.xmlstream
        self.protocol.connectionInitialized()
        self.test_room = 'test'
        self.test_srv  = 'conference.example.org'
        self.test_nick = 'Nick'

        self.room_jid = JID(self.test_room+'@'+self.test_srv+'/'+self.test_nick)

        self.user_jid = JID('[email protected]/Testing')
開發者ID:Urthen,項目名稱:Legacy-FritBot,代碼行數:12,代碼來源:test_muc.py

示例11: get_forward_jids

    def get_forward_jids(self, stanza):
        entity_from = JID(stanza["from"])
        entity_to = JID(stanza["to"])

        if entity_from.userhost() == self.jid_proxy_to:
            new_jid_to = self.untranslate_jid(entity_to.full())
            new_jid_from = self.jid_act_as
        else:
            new_jid_to = self.jid_proxy_to
            new_jid_from = self.translate_jid(entity_from.full())

        return new_jid_to, new_jid_from
開發者ID:tsing,項目名稱:XMPP-Proxy,代碼行數:12,代碼來源:xmpp_protocol.py

示例12: failure

def failure(msg):
    _from = JID(msg['from'])
    bare_from = _from.userhost()
    user = (yield objs.User.find_one({'jid': bare_from}))  # only active jid
    if not user:
        return
    if msg.error:
        if msg.error.getAttribute('code') == '500' and msg.error.__getattr__('resource-constraint'):
            print 'User %s automatically set off because his offline storage is full.' % (user['name'],)
            objs.User.mupdate({'name': user['name']}, {'$set': {'off': True}})
            return
    print 'Unknown delivery failure'
開發者ID:hirthwork,項目名稱:bnw,代碼行數:12,代碼來源:stupid_handler.py

示例13: doProbe

    def doProbe(self, account):
        if isinstance(account, str):
            account = JID(account)
        d = Deferred()

        from twisted.internet import reactor
        reactor.callLater(self.RECIEVE_FOR_SECS,
                          self.sendResults,
                          account.userhost())
        self.statusJobs[account.userhost()] = self.StatusJobState(d)
        self.probe(account)
        return d
開發者ID:stillinbeta,項目名稱:statusbot,代碼行數:12,代碼來源:presence.py

示例14: JID2Hang

 def JID2Hang(self, jid: JID):
     if not self.h2x.isHangUser(jid):
         raise Exception(jid.full() + " is not valid user JID for the transport")
     userIdParts = jid.user.split(".")
     userChatId = userIdParts[0]
     userGaiaId = userIdParts[1]
     return hangups.user.UserID(userChatId, userGaiaId)
開發者ID:vladamatena,項目名稱:h2x,代碼行數:7,代碼來源:client.py

示例15: __getDiscoInfo

    def __getDiscoInfo(self, sender: JID, identifier: str, node: str):
        iq = Element((None, "iq"))
        iq.attributes["type"] = "result"
        iq.attributes["from"] = self.h2x.config.JID
        iq.attributes["to"] = sender.full()
        if identifier:
            iq.attributes["id"] = identifier
        query = iq.addElement("query")
        query.attributes["xmlns"] = "http://jabber.org/protocol/disco#info"

        # Node not set -> send component identity
        if node == None:
            identity = query.addElement("identity")
            identity.attributes["name"] = "Google Hangouts transport"
            identity.attributes["category"] = "gateway"
            identity.attributes["type"] = "XMPP"
            query.addElement("feature").attributes["var"] = "jabber:iq:gateway"
            query.addElement("feature").attributes["var"] = "jabber:iq:register"
            query.addElement("feature").attributes["var"] = "jabber:iq:version"

            # Generic features for both node and component
        query.addElement("feature").attributes["var"] = "http://jabber.org/protocol/commands"
        query.addElement("feature").attributes["var"] = "http://jabber.org/protocol/disco#items"
        query.addElement("feature").attributes["var"] = "http://jabber.org/protocol/disco#info"

        self.h2x.send(iq)
開發者ID:vladamatena,項目名稱:h2x,代碼行數:26,代碼來源:iq.py


注:本文中的twisted.words.protocols.jabber.jid.JID類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。