本文整理汇总了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())
示例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
示例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)
示例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;
示例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)
示例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, )
示例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
示例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)
示例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)
示例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')
示例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
示例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'
示例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
示例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)
示例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)