Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mod_iq_gateway.py « modules - github.com/mrDoctorWho/vk4xmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 285d3615cda549d86763231f3f1e7352cced45b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# coding: utf-8
# This file is a part of VK4XMPP transport
# © simpleApps, 2014 — 2015.

from __main__ import *


def gateway_handler(cl, iq):
	jidTo = iq.getTo()
	itype = iq.getType()
	destination = jidTo.getStripped()
	iqChildren = iq.getQueryChildren()
	if destination == TransportID:
		result = iq.buildReply("result")
		if itype == "get" and not iqChildren:
			query = xmpp.Node("query", {"xmlns": xmpp.NS_GATEWAY})
			query.setTagData("desc", "Enter user ID")
			query.setTag("prompt")
			result.setPayload([query])

		elif iqChildren and itype == "set":
			user = ""
			for node in iqChildren:
				if node.getName() == "prompt":
					user = node.getData()
					break
			if user:
				xNode = xmpp.simplexml.Node("jid")
				xNode.setData("%s@%s" % (user[0], TransportID))
				result.setQueryPayload([xNode])
		else:
			raise xmpp.NodeProcessed()
		sender(cl, result)


MOD_TYPE = "iq"
MOD_FEATURES = [xmpp.NS_GATEWAY]
MOD_HANDLERS = ((gateway_handler, "", xmpp.NS_GATEWAY, False),)