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


Python Element.attributes["to"]方法代码示例

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


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

示例1: send

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
    def send(self, to, body, subject=None, mtype=None, delay=None):
        print 'start sending'
        el = Element((None, "message"))
        el.attributes["to"] = to
        el.attributes["from"] = self.juser
        el.attributes["id"] = '111111'
        
        if(subject):
            subj = el.addElement("subject")
            subj.addContent(subject)
        
        if(mtype):
            el.attributes["type"] = mtype
        
        if(delay):
            x = el.addElement("x")
            x.attributes["xmlns"] = "jabber:x:delay"
            x.attributes["from"] = fro
            x.attributes["stamp"] = delay
        
        b = el.addElement("body")
        b.addContent(body)
              
        
        
        self.theXmlstream.send(el)    

        print 'done sending'
开发者ID:CuonDeveloper,项目名称:cuon,代码行数:30,代码来源:xmpp_client.py

示例2: componentConnected

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def componentConnected(self, xmlstream):
		LogEvent(INFO)
		self.xmlstream = xmlstream
		self.xmlstream.addObserver("/iq", self.iq.onIq)
		self.xmlstream.addObserver("/presence", self.onPresence)
		self.xmlstream.addObserver("/message", self.onMessage)
		self.xmlstream.addObserver("/bind", self.onBind)
		self.xmlstream.addObserver("/route", self.onRouteMessage)
		self.xmlstream.addObserver("/error[@xmlns='http://etherx.jabber.org/streams']", self.streamError)
		if config.useXCP and config.compjid:
			pres = Element((None, "presence"))
			pres.attributes["to"] = "[email protected]"
			pres.attributes["from"] = config.compjid
			x = pres.addElement("x")
			x.attributes["xmlns"] = globals.COMPPRESENCE
			x.attributes["xmlns:config"] = globals.CONFIG
			x.attributes["config:version"] = "1"
			x.attributes["protocol-version"] = "1.0"
			x.attributes["config-ns"] = legacy.url + "/component"
			self.send(pres)
		if config.useComponentBinding:
			LogEvent(INFO, msg="Component binding to %r" % config.jid)
			bind = Element((None,"bind"))
			bind.attributes["name"] = config.jid
			self.send(bind)
		if config.useRouteWrap:
			self.routewrap = 1

		self.sendInvitations()
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:31,代码来源:main.py

示例3: sendDiscoItemsResponse

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def sendDiscoItemsResponse(self, to, ID, ulang, jid):
		""" Send a service discovery disco#items stanza to the given 'to'. 'jid' is the JID that was queried. """
		LogEvent(INFO)
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = jid
		iq.attributes["to"] = to
		if ID:
			iq.attributes["id"] = ID
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_ITEMS

		searchjid = jid
		if jid.find('@') > 0: searchjid = "USER"

		for node in self.nodes.get(searchjid, []):
			handler, name, rootnode = self.nodes[jid][node]
			if rootnode:
				LogEvent(INFO, msg="Found node %r" % (node))
				name = lang.get(name, ulang)
				item = query.addElement("item")
				item.attributes["jid"] = jid
				item.attributes["node"] = node
				item.attributes["name"] = name

		if searchjid == "USER":
			# Add any user specific items
			for hndl in self.userItemHandlers:
				hndl(jid, query)
		
		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:33,代码来源:disco.py

示例4: pwdChangeResults

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def pwdChangeResults(self, results, el, sessionid, newpassword):
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "changepassword"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if results[3]:
			note.attributes["type"] = "error"
			note.addContent(lang.get("command_ChangePassword_Failed", ulang))
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_Done", ulang))
			(username, oldpassword) = self.pytrans.xdb.getRegistration(toj.userhost())
			self.pytrans.xdb.setRegistration(toj.userhost(), username, newpassword)

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:35,代码来源:ChangePassword.py

示例5: sendResponse

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def sendResponse(self, failure, el, sessionid=None):
		LogEvent(INFO)
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "confirmaccount"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if failure:
			note.attributes["type"] = "error"
			note.addContent(lang.get("command_ConfirmAccount_Failed", ulang))
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_ConfirmAccount_Complete", ulang))

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:34,代码来源:ConfirmAccount.py

示例6: sendTune

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def sendTune(self, to=None, fro=None, musicinfo=None, stop=False):
		"""
		send tune to user
		"""
		LogEvent(INFO)
		el = Element((None, "message"))
		el.attributes["id"] = self.pytrans.makeMessageID()
		if fro:
			el.attributes["from"] = fro
	
		e = el.addElement("event")
		e.attributes["xmlns"] = globals.PUBSUBEVENT
		
		items = e.addElement("items")
		items.attributes["node"] = globals.TUNE
		
		item = items.addElement("item")
		item.attributes["id"] = self.pytrans.makeMessageID()
			
		t = item.addElement("tune")
		t.attributes["xmlns"] = globals.TUNE
			
		if not stop:
			if musicinfo and len(musicinfo) > 0:
				for key in musicinfo:
					if key in ('artist', 'length', 'rating', 'source', 'title', 'track', 'uri'):
						value = musicinfo[key]
						if value:
							t_key = t.addElement(key)
							t_key.addContent(value)
		
		for res in self.pytrans.sessions[to].resourceList: # send to every resource
			el.attributes["to"] = to + '/' + res
			self.pytrans.send(el)
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:36,代码来源:pubsub.py

示例7: sendCommandInfoResponse

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def sendCommandInfoResponse(self, to, ID, node, ulang):
		LogEvent(INFO, msg="Replying to disco#info")
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = config.jid
		iq.attributes["to"] = to
		if ID: iq.attributes["id"] = ID
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.DISCO_INFO

		# Add identity
		identity = query.addElement("identity")
		identity.attributes["name"] = lang.get(self.commandNames[node], ulang)
		identity.attributes["category"] = "automation"
		identity.attributes["type"] = "command-node"

		# Add supported feature
		feature = query.addElement("feature")
		feature.attributes["var"] = globals.COMMANDS

		# Add supported feature
		feature = query.addElement("feature")
		feature.attributes["var"] = globals.XDATA

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:27,代码来源:adhoc.py

示例8: sendRegistrationFields

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
    def sendRegistrationFields(self, incoming):
        # Construct a reply with the fields they must fill out
        LogEvent(INFO)
        reply = Element((None, "iq"))
        reply.attributes["from"] = config.jid
        reply.attributes["to"] = incoming.getAttribute("from")
        reply.attributes["id"] = incoming.getAttribute("id")
        reply.attributes["type"] = "result"
        query = reply.addElement("query")
        query.attributes["xmlns"] = globals.IQREGISTER
        instructions = query.addElement("instructions")
        ulang = utils.getLang(incoming)
        instructions.addContent(lang.get("registertext", ulang))
        userEl = query.addElement("username")
        passEl = query.addElement("password")

        # Check to see if they're registered
        source = internJID(incoming.getAttribute("from")).userhost()
        result = self.pytrans.xdb.getRegistration(source)
        if result:
            username, password = result
            if username != "local":
                userEl.addContent(username)
                query.addElement("registered")

        self.pytrans.send(reply)
开发者ID:2mf,项目名称:pyicqt,代码行数:28,代码来源:register.py

示例9: sendError

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def sendError(self, node, el, errormsg, sessionid=None):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = node
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		note.attributes["type"] = "error"
		note.addContent(errormsg)

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:28,代码来源:adhoc.py

示例10: __getDiscoInfo

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
    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,代码行数:28,代码来源:iq.py

示例11: snfmtChangeResults

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def snfmtChangeResults(self, results, el, sessionid):
		to = el.getAttribute("from")
		toj = internJID(to)
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		if sessionid:
			command.attributes["sessionid"] = sessionid
		else:
			command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["node"] = "formatscreenname"
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		note = command.addElement("note")
		if results[3]:
			note.attributes["type"] = "error"
			note.addContent(results[3][1])
		else:
			note.attributes["type"] = "info"
			note.addContent(lang.get("command_Done", ulang))

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:33,代码来源:FormatScreenName.py

示例12: incomingIq

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def incomingIq(self, el):
		to = el.getAttribute("from")
		ID = el.getAttribute("id")
		ulang = utils.getLang(el)

		if config.admins.count(internJID(to).userhost()) == 0:
			self.pytrans.iq.sendIqError(to=to, fro=config.jid, ID=ID, xmlns=globals.COMMANDS, etype="cancel", condition="not-authorized")
			return

		self.sendProbes()

		iq = Element((None, "iq"))
		iq.attributes["to"] = to
		iq.attributes["from"] = config.jid
		if ID:
			iq.attributes["id"] = ID
		iq.attributes["type"] = "result"

		command = iq.addElement("command")
		command.attributes["sessionid"] = self.pytrans.makeMessageID()
		command.attributes["xmlns"] = globals.COMMANDS
		command.attributes["status"] = "completed"

		x = command.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "result"

		title = x.addElement("title")
		title.addContent(lang.get("command_ConnectUsers", ulang))

		field = x.addElement("field")
		field.attributes["type"] = "fixed"
		field.addElement("value").addContent(lang.get("command_Done", ulang))

		self.pytrans.send(iq)
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:37,代码来源:ConnectUsers.py

示例13: sendErrorMessage

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
def sendErrorMessage(pytrans, to, fro, etype, condition, explanation, body=None, el=None):
    if el is None:
        el = Element((None, "message"))
    el.attributes["to"] = to
    el.attributes["from"] = fro
    el.attributes["type"] = "error"
    error = el.addElement("error")
    error.attributes["type"] = etype
    error.attributes["code"] = str(utils.errorCodeMap[condition])
    if condition:
        desc = error.addElement(condition)
        desc.attributes["xmlns"] = globals.XMPP_STANZAS
    text = error.addElement("text")
    text.attributes["xmlns"] = globals.XMPP_STANZAS
    text.addContent(explanation)

    bodywritten = False  # no <body/> in message
    for child in el.elements():  # try find in el
        if child.name == 'body':  # <body/> already in el
            if body and len(body) > 0:  # necessary add other info to it
                body_txt = child.__str__()
                child.addContent(body_txt + '\n' + body)
            bodywritten = True
    if not bodywritten and body and len(body) > 0:  # <body/> in el don't found
        b = el.addElement('body')
        b.addContent(body)
    pytrans.send(el)
开发者ID:2mf,项目名称:pyicqt,代码行数:29,代码来源:jabw.py

示例14: sendMood

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def sendMood(self, to=None, fro=None, mood=None, text=None, action=None):
		"""
		send mood to user
		"""
		LogEvent(INFO)
		el = Element((None, "message"))
		el.attributes["id"] = self.pytrans.makeMessageID()
		if fro:
			el.attributes["from"] = fro
	
		e = el.addElement("event")
		e.attributes["xmlns"] = globals.PUBSUBEVENT
		
		items = e.addElement("items")
		items.attributes["node"] = globals.MOOD
		
		if action == 'retract':
			r = items.addElement("retract")
			r.attributes["id"] = self.pytrans.makeMessageID()
		else:
			item = items.addElement("item")
			item.attributes["id"] = self.pytrans.makeMessageID()
			
			m = item.addElement("mood")
			m.attributes["xmlns"] = globals.MOOD
			
			if mood:
				m.addElement(mood)
			if text:
				t = m.addElement("text")
				t.addContent(text)

		for res in self.pytrans.sessions[to].resourceList: # send to every resource
			el.attributes["to"] = to + '/' + res
			self.pytrans.send(el)
开发者ID:anton-ryzhov,项目名称:pyicqt_auto_reconnect,代码行数:37,代码来源:pubsub.py

示例15: sendSearchForm

# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes["to"] [as 别名]
	def sendSearchForm(self, el):
		LogEvent(INFO)
		ulang = utils.getLang(el)
		iq = Element((None, "iq"))
		iq.attributes["type"] = "result"
		iq.attributes["from"] = el.getAttribute("to")
		iq.attributes["to"] = el.getAttribute("from")
		if el.getAttribute("id"):
			iq.attributes["id"] = el.getAttribute("id")
		query = iq.addElement("query")
		query.attributes["xmlns"] = globals.IQSEARCH
		forminstr = query.addElement("instructions")
		forminstr.addContent(lang.get("searchnodataform", ulang))
		x = query.addElement("x")
		x.attributes["xmlns"] = globals.XDATA
		x.attributes["type"] = "form"
		title = x.addElement("title")
		title.addContent(lang.get("searchtitle", ulang))
		instructions = x.addElement("instructions")
		instructions.addContent(lang.get("searchinstructions", ulang))
		x.addChild(utils.makeDataFormElement("hidden", "FORM_TYPE", value="jabber:iq:search"))
		x.addChild(utils.makeDataFormElement("text-single", "email", "E-Mail Address"))
		x.addChild(utils.makeDataFormElement("text-single", "first", "First Name"))
		x.addChild(utils.makeDataFormElement("text-single", "middle", "Middle Name"))
		x.addChild(utils.makeDataFormElement("text-single", "last", "Last Name"))
		x.addChild(utils.makeDataFormElement("text-single", "maiden", "Maiden Name"))
		x.addChild(utils.makeDataFormElement("text-single", "nick", "Nickname"))
		x.addChild(utils.makeDataFormElement("text-single", "address", "Street Address"))
		x.addChild(utils.makeDataFormElement("text-single", "city", "City"))
		x.addChild(utils.makeDataFormElement("text-single", "state", "State"))
		x.addChild(utils.makeDataFormElement("text-single", "zip", "Zip Code"))
		x.addChild(utils.makeDataFormElement("text-single", "country", "Country"))
		x.addChild(utils.makeDataFormElement("text-single", "interest", "Interest"))

		self.pytrans.send(iq)
开发者ID:Ashaman-,项目名称:pyaimt,代码行数:37,代码来源:SearchFactory.py


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