From b9a2e5adcda82bcf14e6a6ec3b504aec7908ec42 Mon Sep 17 00:00:00 2001 From: mightyBroccoli Date: Fri, 20 Jul 2018 23:16:59 +0200 Subject: XEP-0157 finally finished * fixed XEP 0157 functionality * updated README.MD --- README.MD | 2 +- main.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index 32e5add..f7e4385 100644 --- a/README.MD +++ b/README.MD @@ -6,11 +6,11 @@ Do not opperate this bot on foreign servers. ### functions - query xmpp server software and version [XEP-0092](https://xmpp.org/extensions/xep-0092.html) - query xmpp server uptime [XEP-0012](https://xmpp.org/extensions/xep-0012.html) +- query xmpp server contact addresses [XEP-0157](https://xmpp.org/extensions/xep-0157.html) - display help output - respond to username being mentioned ### todo -- [ ] extract xmpp server contact addresses [XEP-0157](https://xmpp.org/extensions/xep-0157.html) from result - [ ] Github Webhook ### install diff --git a/main.py b/main.py index b476c80..84d7a72 100644 --- a/main.py +++ b/main.py @@ -157,12 +157,16 @@ class QueryBot(slixmpp.ClientXMPP): if field['type'] == 'hidden' and var == 'FORM_TYPE': title = field['value'][0] continue - sep = '\n ' + len(var) * ' ' + sep = ', ' field_value = field.get_value(convert=False) value = sep.join(field_value) if isinstance(field_value, list) else field_value server_info.append('%s: %s' % (var, value)) - self.send_message(mto=msg['from'].bare, mbody=server_info, mtype=msg['type']) + text = "contact addresses for %s are" % (line[1]) + for count in range(len(server_info)): + text += "\n" + server_info[count] + + self.send_message(mto=msg['from'].bare, mbody=text, mtype=msg['type']) except NameError: pass except XMPPError: @@ -221,6 +225,7 @@ if __name__ == '__main__': xmpp.register_plugin('xep_0060') # PubSub xmpp.register_plugin('xep_0085') # Chat State Notifications xmpp.register_plugin('xep_0092') # Software Version + xmpp.register_plugin('xep_0128') # Service Discovery Extensions xmpp.register_plugin('xep_0199') # XMPP Ping # connect and start receiving stanzas -- cgit v1.2.3-54-g00ecf