diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2017-11-13 10:09:12 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2017-11-13 10:09:12 +0100 |
commit | 1eba5e9ea7990162bfc407dc557df14bf25d41d7 (patch) | |
tree | e88094a53523b4d703b8a50ae1b0b05db32a5ee3 | |
parent | 7b41c5dc809159028566367fbf1f60df67eba1cb (diff) | |
download | finanzstatus-1eba5e9ea7990162bfc407dc557df14bf25d41d7.tar.gz finanzstatus-1eba5e9ea7990162bfc407dc557df14bf25d41d7.zip |
don't send presence and only connect xmpp if there are new transactions
-rwxr-xr-x | transfers.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/transfers.py b/transfers.py index e3ee1a1..fbf72b6 100755 --- a/transfers.py +++ b/transfers.py @@ -80,19 +80,19 @@ for t in transactions: logging.info("Created %s", record.id) record.save() -cl = ClientXMPP(config['jabber']['jid'], config['jabber']['password']) +if len(new_transactions) > 0: + cl = ClientXMPP(config['jabber']['jid'], config['jabber']['password']) -def session_start(event): - cl.send_presence() - for t in new_transactions: - message = t.format_message() - cl.send_message(config['jabber']['recipient'], message, mtype='chat') - logging.info("Sent info %s", message) - cl.disconnect() + def session_start(event): + for t in new_transactions: + message = t.format_message() + cl.send_message(config['jabber']['recipient'], message, mtype='chat') + logging.info("Sent info %s", message) + cl.disconnect() -cl.add_event_handler('session_start', session_start) -cl.add_event_handler('killed', lambda *_: cl.loop.stop()) -cl.connect() -cl.process() + cl.add_event_handler('session_start', session_start) + cl.add_event_handler('killed', lambda *_: cl.loop.stop()) + cl.connect() + cl.process() |