главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
path: root/echoz.sed
diff options
context:
space:
mode:
authorJonas Wielicki <j.wielicki@sotecware.net>2018-04-20 13:25:59 +0200
committerJonas Wielicki <j.wielicki@sotecware.net>2018-04-20 13:25:59 +0200
commitf700936ac80f44220d04562bb2cd2500111cfcbd (patch)
treedb471c47a1d8ddef8c113826c54e2d60d437bf5d /echoz.sed
parent7d2270ad9f8b58c485a0bbcf9ccacb8a637ea8f6 (diff)
Support for replying to IQs
Diffstat (limited to 'echoz.sed')
-rwxr-xr-xechoz.sed36
1 files changed, 36 insertions, 0 deletions
diff --git a/echoz.sed b/echoz.sed
index 2a156be..2f665ea 100755
--- a/echoz.sed
+++ b/echoz.sed
@@ -61,6 +61,9 @@ bmain-loop;
:main-loop;
/<message/bhandle-message;
+/<iq/bhandle-iq;
+# no handler, convert to single space, emit and continue
+s#^.+$# #;p;
n;
bmain-loop;
@@ -100,3 +103,36 @@ g;
s#^(.+)$#\1</message>#;
p;n;
bmain-loop;
+
+:handle-iq;
+# prepare header; store it in hold space first
+h;
+# extract new to address
+s#^.*from=(['"][^'"]+?['"]).*$#to=\1\n#;
+# add copy of header and extract new from address
+G;
+s#^(.+)\n.+to=(['"][^'"]+?['"]).*$#\1 from=\2#;
+# add copy of header and extract id
+G;
+s#^(.+)\n.+id=(['"][^'"]+?['"]).*$#\1 id=\2#;
+# compose header
+s#^(.+)$#<iq \1>#;
+# store result in hold space and fetch original header for further processing
+x;
+
+/type='get'/bsend-error;
+/type='set'/bsend-error;
+bmain-loop;
+
+:send-error;
+# load composed header from hold space
+g;
+s#^<iq (.+)>$#<iq type='error' \1><error><service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Feature not implemented by sedbot.</text></error></iq>#;
+p;n;
+bskip-iq;
+
+:skip-iq;
+# skip remainder of IQ payload until done
+/<\/iq/bmain-loop;
+n;
+bskip-iq;