XMPP/Jabber echo bot (written in sed)
Do you know that situation, you really really need an XMPP echo bot, but you don’t have access to high-level tools like
Python_ to write one? All you have is
sed? Then this tool is for you.
This is an XMPP echo bot written in (mostly) sed. Bash is used to do the pre-authentication setup (look up DNS records, establish TLS via
openssl s_client). sed processes the XML stream and handles all interaction with the server on the XMPP level. Yes, this kinda parses XML in sed.
Tested to work against Prosody 0.9.
./echoz.sh [email protected] password
XEP-0092 (Software Version)_
XEP-0199 (XMPP Ping)_
\n-- since sed is line (or NUL) based, there’s not really another way to parse XMPP XML (which generally never contains newlines) with sed.
xml2to convert the XML stream into events; however, it turns out that
2xm[doesn’t like stream resets. Also, using the
trapproach also allows us to detect the end of elements, which is useful for various purposes.