def main_iq_handler(cl, iq): source = iq.getFrom() if WhiteList: if source and source.getDomain() not in WhiteList: sender(cl, utils.buildIQError(iq, xmpp.ERR_BAD_REQUEST, "You're not in the white-list")) raise xmpp.NodeProcessed() ping = iq.getTag("ping") if ping and ping.getNamespace() == xmpp.NS_PING: jidTo = iq.getTo() if jidTo == TransportID: sender(cl, iq.buildReply("result"))
def main_iq_handler(cl, iq): source = iq.getFrom() if WhiteList: if source and source.getDomain() not in WhiteList: sender( cl, utils.buildIQError(iq, xmpp.ERR_BAD_REQUEST, "You're not in the white-list")) raise xmpp.NodeProcessed() ping = iq.getTag("ping") if ping and ping.getNamespace() == xmpp.NS_PING: jidTo = iq.getTo() if jidTo == TransportID: sender(cl, iq.buildReply("result"))
def captcha_handler(cl, iq): if iq.getTagAttr("captcha", "xmlns") == xmpp.NS_CAPTCHA: source = iq.getFrom().getStripped() result = iq.buildReply("result") if source in Users: destination = iq.getTo() if destination == TransportID: capTag = iq.getTag("captcha") xTag = capTag.getTag("x", {}, xmpp.NS_DATA) ocrTag = xTag.getTag("field", {"var": "ocr"}) value = ocrTag.getTagData("value") if mod_msg.acceptCaptcha(value, source, destination): cl.send(result) else: result = utils.buildIQError(iq, xmpp.ERR_NOT_ACCEPTABLE)
def disco_handler(cl, iq): source = iq.getFrom().getStripped() destination = iq.getTo().getStripped() ns = iq.getQueryNS() node = iq.getTagAttr("query", "node") result = iq.buildReply("result") payload = [] if node: if source in ADMIN_JIDS: users = [] if node == "Online users": users = Users.keys() elif node == "All users": users = getUsersList() users = [user[0] for user in users] for user in users: payload.append(xmpp.Node("item", {"name": user, "jid": user})) if node == xmpp.NS_COMMANDS: nodes = NODES["user"] if source in ADMIN_JIDS: nodes += NODES["admin"] for node in nodes: payload.append( xmpp.Node("item", { "node": node, "name": node, "jid": TransportID })) elif CAPS_NODE in node: payload = getFeatures(destination, source, ns) elif not payload: result = buildIQError(iq, xmpp.ERR_BAD_REQUEST) else: payload = getFeatures(destination, source, ns, True) if payload: result.setQueryPayload(payload) sender(cl, result)
def disco_handler(cl, iq): source = iq.getFrom().getStripped() destination = iq.getTo().getStripped() ns = iq.getQueryNS() node = iq.getTagAttr("query", "node") result = iq.buildReply("result") payload = [] if node: if source in ADMIN_JIDS: users = [] if node == "Online users": users = Users.keys() elif node == "All users": users = getUsersList() users = [user[0] for user in users] for user in users: payload.append(xmpp.Node("item", {"name": user, "jid": user})) if node == xmpp.NS_COMMANDS: nodes = NODES["user"] if source in ADMIN_JIDS: nodes += NODES["admin"] for node in nodes: payload.append(xmpp.Node("item", {"node": node, "name": node, "jid": TransportID})) elif CAPS_NODE in node: payload = getFeatures(destination, source, ns) elif not payload: result = buildIQError(iq, xmpp.ERR_BAD_REQUEST) else: payload = getFeatures(destination, source, ns, True) if payload: result.setQueryPayload(payload) sender(cl, result)