本文整理汇总了Python中twisted.words.protocols.jabber.jid.JID类的典型用法代码示例。如果您正苦于以下问题:Python JID类的具体用法?Python JID怎么用?Python JID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JID类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: componentIq
def componentIq(self, element: Element, sender: JID, identifier: str, iqType: str):
for query in element.elements():
xmlns = query.uri
node = query.getAttribute("node")
if xmlns == "http://jabber.org/protocol/disco#info" and iqType == "get":
self.__getDiscoInfo(sender, identifier, node)
return
if xmlns == "http://jabber.org/protocol/disco#items" and iqType == "get":
self.__getDiscoItems(sender, identifier, node)
return
if xmlns == "jabber:iq:register" and iqType == "get":
self.__getRegister(sender, identifier)
return
if xmlns == "jabber:iq:register" and iqType == "set":
self.__setRegister(element, sender, identifier)
return
if xmlns == "http://jabber.org/protocol/commands" and query.name == "command" and iqType == "set":
self.__command(query, sender, identifier, node)
return
self.__sendIqError(
recipient=sender.full(),
sender=self.h2x.config.JID,
identification=identifier,
errorType="cancel",
condition="feature-not-implemented",
)
开发者ID:vladamatena,项目名称:h2x,代码行数:32,代码来源:iq.py
示例17: idiotic
def idiotic(msg):
"""Suck some cocks."""
# return str(request.body)
message_from = JID(msg['from'])
message_bare_from = message_from.userhost()
message_user = (yield objs.User.find_one({'jids': message_bare_from}))
if not message_user:
message_user = (yield objs.User.find_one({'jid': message_bare_from}))
# if message.body is None:
# return ''
if msg.bnw_s2s:
bnw_s2s = msg.bnw_s2s
print 'GOT AN s2s MESSAGE', bnw_s2s
try:
s2s_type = bnw_s2s['type']
except KeyError:
s2s_type = None
handler = handlers.s2s_handlers.get(s2s_type)
if not handler:
print 'NO HANDLER FOR THIS TYPE (%s)' % (s2s_type)
else:
_ = yield handler(msg, bnw_s2s)
defer.returnValue(None)
message_body = unicode(msg.body)
if message_body is None:
defer.returnValue('')
message_body = message_body.strip()
if type(message_body) != unicode:
message_body = unicode(message_body, 'utf-8', 'replace')
xmsg = XmppMessage(
message_body, JID(msg['to']), message_from, message_user)
if message_user:
message_user.activity()
try:
iparser = 'redeye'
if message_user:
if 'interface' in message_user:
iparser = message_user['interface']
result = yield handlers.parsers[iparser].handle(xmsg)
except CommandParserException, exc:
result = yield exc.args[0]
开发者ID:UndeRus,项目名称:bnw,代码行数:46,代码来源:stupid_handler.py
示例18: onIq
def onIq(self, element: Element):
source = JID(element.getAttribute("from"))
recipient = JID(element.getAttribute("to"))
identification = element.getAttribute("id")
iqType = element.getAttribute("type")
print("IqReceived " + source.full() + " -> " + recipient.full() + ": " + iqType)
# Process component iq
if recipient.full() == self.h2x.config.JID:
self.componentIq(element, source, identification, iqType)
return
# Process user iq
if self.h2x.isHangUser(recipient):
self.userIq(element, source, recipient, identification, iqType)
return
# TODO: Can we send something like wrong request?
self.__sendIqError(
recipient=source.full(),
sender=recipient.full(),
identification=identification,
errorType="cancel",
condition="service-unavailable",
)
开发者ID:vladamatena,项目名称:h2x,代码行数:26,代码来源:iq.py
示例19: call_msg_handlers
def call_msg_handlers(self, t, s, b, subject, stanza):
if t == 'error': return
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)
if j.resource:
for i in self.topichandlers: self.call(i, s, subject)
else:
for i in self.topichandlers: self.call(i, s, b)
else:
delayed = [i for i in stanza.children if (i.__class__==domish.Element) and ((i.name=='delay') or ((i.name=='x') and (i.uri=='jabber:x:delay')))]
if delayed: dl = True
else: dl = False
for i in self.msghandlers:
if (t == 'groupchat') or not i[1]: self.call(i[0], s, b, dl)
开发者ID:setazer,项目名称:freq-bot,代码行数:18,代码来源:freq.py
示例20: __setRegister
def __setRegister(self, data: Element, sender: JID, identifier: str):
try:
user = sender.userhost()
token = data.firstChildElement().firstChildElement().firstChildElement().firstChildElement().__str__()
except Exception as e:
# Fail registration
print("Register reponse processing failed: " + e.__str__())
# FIXME: Send negative response here !!!
self.__sendIqResult(sender.full(), self.h2x.config.JID, identifier, "jabber:iq:register")
return
self.h2x.registerUser(user, token)
# Send registration done
self.__sendIqResult(sender.full(), self.h2x.config.JID, identifier, "jabber:iq:register")
# Request subscription
self.h2x.sendPresence(sender, "subscribe")
开发者ID:vladamatena,项目名称:h2x,代码行数:18,代码来源:iq.py
注:本文中的twisted.words.protocols.jabber.jid.JID类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论