Store online contacts in presence_notify.py

This commit is contained in:
James Booth
2016-08-03 23:26:36 +01:00
parent 217f4e3c99
commit c02c159e24

View File

@@ -1,5 +1,6 @@
import prof import prof
online = set()
def _show_settings(): def _show_settings():
prof.cons_show("Presence notify plugin settings:") prof.cons_show("Presence notify plugin settings:")
@@ -97,10 +98,18 @@ def _do_notify(barejid, presence):
if mode == "all": if mode == "all":
return True return True
elif mode == "online": elif mode == "online":
if presence == "online" or presence == "offline": if barejid in online:
return True if presence == "offline":
online.remove(barejid)
return True
else:
return False
else: else:
return False if presence != "offline":
online.add(barejid)
return True
else:
return False
else: # off else: # off
return False return False