#!/usr/bin/env python3 import base64 import json from lxml import etree from urllib.parse import quote WORK_DIR = "/var/www/tilde.chat" out = {} parser = etree.XMLParser(strip_cdata=False) root = etree.parse("http://localhost:8081/stats", parser) assert root.getroot().tag == "inspircdstats" with open(f"{WORK_DIR}/blacklist", "r") as f: BLACKLIST = f.read().splitlines() def unsanitize(node, default=""): # workaround for weird behavior in insp's xml output # https://github.com/inspircd/inspircd/blob/v3.7.0/src/modules/m_httpd_stats.cpp#L55 if node.text is None or node.text == "": return default elif str(etree.tostring(node)).startswith(f"b'<{node.tag}>