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


Python JID.userhost方法代码示例

本文整理汇总了Python中twisted.words.protocols.jabber.jid.JID.userhost方法的典型用法代码示例。如果您正苦于以下问题:Python JID.userhost方法的具体用法?Python JID.userhost怎么用?Python JID.userhost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.words.protocols.jabber.jid.JID的用法示例。


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

示例1: get_user

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
 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,代码行数:11,代码来源:protocol.py

示例2: get_user

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
 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,代码行数:11,代码来源:protocol.py

示例3: _cb_subscribe_default_users

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
    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,代码行数:12,代码来源:data.py

示例4: doProbe

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
    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,代码行数:14,代码来源:presence.py

示例5: sendPresence

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
	def sendPresence(self, destination: JID, presenceType: str, status: str = None, show: str = None,
					 priority: int = None, source: JID = None, nick: str = None):
		if not source:
			source = JID(self.config.JID)
		presence = Element((None, 'presence'))
		presence.attributes['to'] = destination.userhost()
		presence.attributes['from'] = source.userhost()
		presence.attributes['type'] = presenceType
		if status:
			presence.addElement('status').addContent(status)
		if show:
			presence.addElement('show').addContent(show)
		if priority:
			presence.addElement('priority').addContent(priority)
		if nick:
			nickElement = presence.addElement('nick', content=nick)
			nickElement.attributes["xmlns"] = "http://jabber.org/protocol/nick"
		print("PresenceSend: " + source.full() + " -> " + destination.full() + " : " + presenceType)
		self.send(presence)
开发者ID:vladamatena,项目名称:h2x,代码行数:21,代码来源:h2x.py

示例6: call_msg_handlers

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
 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,代码行数:13,代码来源:freq.py

示例7: get_forward_jids

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
    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,代码行数:14,代码来源:xmpp_protocol.py

示例8: failure

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
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,代码行数:14,代码来源:stupid_handler.py

示例9: forward_presence

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
    def forward_presence(self, presence):
        type = presence.getAttribute("type", "available")
        if type == "error":
            return

        entity_from = JID(presence["from"])
        entity_to = JID(presence["to"])

        new_jid_to, new_jid_from = self.get_forward_jids(presence)

        presence["to"] = new_jid_to
        presence["from"] = new_jid_from

        self.send(presence)

        if type == "subscribed":
            log.msg("Subscribed from %s" % entity_from.userhost())
            self.probe(entity_from.full(), entity_to.full())

        if type == "available" and entity_from.userhost() != self.jid_proxy_to:
            log.msg("Available from %s" % entity_from.full())
            self.probe(self.jid_proxy_to, new_jid_from)
开发者ID:tsing,项目名称:XMPP-Proxy,代码行数:24,代码来源:xmpp_protocol.py

示例10: idiotic

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
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,代码行数:48,代码来源:stupid_handler.py

示例11: iq

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
def iq(msg):
    """Process incoming IQ stanza."""
    try:
        iq_from = JID(msg['from'])
        iq_bare_from = iq_from.userhost()
        iq_user = (yield objs.User.find_one({'jids': iq_bare_from}))
        if not iq_user:
            iq_user = (yield objs.User.find_one({'jid': iq_bare_from}))

        for handler in iq_handlers.handlers:
            if (yield handler(msg, iq_user)):
                defer.returnValue(True)
        defer.returnValue(False)
    except Exception:
        raise
        print ("Error while processing iq:\n\n" +
               traceback.format_exc() + "\n" +
               "Command which caused this exception: " + iq)
开发者ID:hirthwork,项目名称:bnw,代码行数:20,代码来源:stupid_handler.py

示例12: __init__

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
    def __init__(self, h2x, jid: JID):
        self.h2x = h2x
        self.jid = jid
        self.user = User(jid.userhost())
        self.state = State.disconnected
        self.targetState = State.disconnected
        self.thread = None
        self.loop = None
        self.client = None
        self.userList = None

        # Track connected instances of XMPP clients, for presence control
        self.xmppClients = set()

        if not self.user.token:
            raise UserNotRegistered(jid)

        self.h2x.sendPresence(self.jid, "unavailable", "Client wrapper created")
开发者ID:vladamatena,项目名称:h2x,代码行数:20,代码来源:client.py

示例13: call_msg_handlers

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
 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,代码行数:20,代码来源:freq.py

示例14: __setRegister

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
    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,代码行数:20,代码来源:iq.py

示例15: call_msg_handlers

# 需要导入模块: from twisted.words.protocols.jabber.jid import JID [as 别名]
# 或者: from twisted.words.protocols.jabber.jid.JID import userhost [as 别名]
 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,
             )
             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,代码行数:21,代码来源:freq.py


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