comparison src/core/xmpp.py @ 1480:8d61160ee4b8

core, plugin watched: new plugin, show an alert when a watched entity goes online
author Goffi <goffi@goffi.org>
date Thu, 20 Aug 2015 18:43:56 +0200
parents 7797dda847ae
children 7d7e57a84792
comparison
equal deleted inserted replaced
1479:057f0714f27e 1480:8d61160ee4b8
348 statuses = {} 348 statuses = {}
349 349
350 if None in statuses: # we only want string keys 350 if None in statuses: # we only want string keys
351 statuses[C.PRESENCE_STATUSES_DEFAULT] = statuses.pop(None) 351 statuses[C.PRESENCE_STATUSES_DEFAULT] = statuses.pop(None)
352 352
353 if not self.host.trigger.point("presenceReceived", entity, show, priority, statuses, self.parent.profile):
354 return
355
353 self.host.memory.setPresenceStatus(entity, show or "", 356 self.host.memory.setPresenceStatus(entity, show or "",
354 int(priority), statuses, 357 int(priority), statuses,
355 self.parent.profile) 358 self.parent.profile)
356 359
357 # now it's time to notify frontends 360 # now it's time to notify frontends
365 if not statuses: 368 if not statuses:
366 statuses = {} 369 statuses = {}
367 370
368 if None in statuses: # we only want string keys 371 if None in statuses: # we only want string keys
369 statuses[C.PRESENCE_STATUSES_DEFAULT] = statuses.pop(None) 372 statuses[C.PRESENCE_STATUSES_DEFAULT] = statuses.pop(None)
370 self.host.memory.setPresenceStatus(entity, "unavailable", 0, statuses, self.parent.profile)
371 373
372 if not self.host.trigger.point("presenceReceived", entity, "unavailable", 0, statuses, self.parent.profile): 374 if not self.host.trigger.point("presenceReceived", entity, "unavailable", 0, statuses, self.parent.profile):
373 return 375 return
376
377 self.host.memory.setPresenceStatus(entity, C.PRESENCE_UNAVAILABLE, 0, statuses, self.parent.profile)
374 378
375 # now it's time to notify frontends 379 # now it's time to notify frontends
376 self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses, self.parent.profile) 380 self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses, self.parent.profile)
377 381
378 def available(self, entity=None, show=None, statuses=None, priority=None): 382 def available(self, entity=None, show=None, statuses=None, priority=None):