#!/usr/bin/env swipl /* print_features.pl Author: Gimenez, Christian. Copyright (C) 2025 Gimenez, Christian This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . 2025-07-07 */ :- module(print_features, []). /** print_features: A client that prints all server features. @author Christian Gimenez @license GPLv3 */ :- use_module(library(ansi_term)). :- use_module(library(xmpp/xmpp)). :- use_module(library(xmpp/xmpp_core)). :- use_module(library(xmpp/xmpp_auth)). :- initialization(main, main). :- dynamic all_done/0. print_feat(element(Feat, Attr, Contents)) :- ansi_format([bold], '* Feature: ~s\n', [Feat]), format('~q\n~q\n\n', [Attr, Contents]), !. print_feat(X) :- writeq(X), nl. receive_hook(Lst) :- member(data([element('stream:features', _, Content)]), Lst), % writeq(Content), nl, flush, maplist(print_feat, Content). connected_hook(_) :- asserta(all_done), write('- Connected -'), nl, flush. wait_until_end :- repeat, sleep(1), all_done, !. main(ArgV) :- argv_options(ArgV, [JID], _Options), % debug(xmpp), debug, format('~s password?', [JID]), nl, read_line_to_string(current_input, PasswordS), atom_string(Password, PasswordS), add_hook(received_xml, print_features:receive_hook), add_hook(after_connect, print_features:connected_hook), connect(JID, Password), wait_until_end, write('- Done -'), nl, flush.