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

mod_msg_xhtml.py « modules - github.com/mrDoctorWho/vk4xmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa12a740a2b6e6cc12fd51fb5084a87645b48b90 (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
# coding: utf-8
# This file is a part of VK4XMPP transport
# © simpleApps, 2013 — 2015.
# This module depends on mod_xhtml.

from __main__ import Users, logger
import xmpp
import mod_xhtml

def xhtml_handler(cl, msg):
	destination = msg.getTo().getStripped()
	source = msg.getFrom().getStripped()
	if source in Users and msg.getType() == "chat":
		user = Users[source]
		html = msg.getTag("html")
		if html and html.getTag("body"):  # XHTML-IM!
			logger.debug("fetched xhtml image from %s", source)
			try:
				xhtml = mod_xhtml.parseXHTML(user, html, source, destination)
			except Exception:
				xhtml = False
			if xhtml:
				raise xmpp.NodeProcessed()

MOD_TYPE = "message"
MOD_HANDLERS = ((xhtml_handler, "", "", True),)
MOD_FEATURES = [xmpp.NS_XHTML_IM]
MOD_FEATURES_USER = [xmpp.NS_XHTML_IM]