JID = 'bot@example.org'
NICK = 'sid'
-PASS = getpass.getpass('Password for "{}": '.format(JID))
+PASS = getpass.getpass(f'Password for "{JID}": ')
ROOM = 'room@conf.example.org'
def main():
xmpp = MUCBot(JID, PASS, ROOM, NICK)
xmpp.register_bot_plugin(Feeds)
xmpp.register_bot_plugin(Ping)
- # Connect to the XMPP server and start processing XMPP stanzas.
- if xmpp.connect():
- # If you do not have the dnspython library installed, you will need
- # to manually specify the name of the server if it does not match
- # the one in the JID. For example, to use Google Talk you would
- # need to use:
- #
- # if xmpp.connect(('talk.google.com', 5222)):
- # ...
- xmpp.process(block=True)
+ try:
+ xmpp.connect()
+ xmpp.process()
+ except KeyboardInterrupt:
xmpp.shutdown_plugins()
- xmpp.log.info('Done')
- else:
- xmpp.log.info('Unable to connect.')
+ xmpp.log.info('Done')
# Script starts here
if __name__ == '__main__':