comparison libervia/backend/plugins/plugin_xep_0085.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents 4b842c1fb686
children
comparison
equal deleted inserted replaced
4269:64a85ce8be70 4270:0d7bb4df2343
98 } 98 }
99 99
100 def __init__(self, host): 100 def __init__(self, host):
101 log.info(_("Chat State Notifications plugin initialization")) 101 log.info(_("Chat State Notifications plugin initialization"))
102 self.host = host 102 self.host = host
103 self.map = {} # FIXME: would be better to use client instead of mapping profile to data 103 self.map = (
104 {}
105 ) # FIXME: would be better to use client instead of mapping profile to data
104 106
105 # parameter value is retrieved before each use 107 # parameter value is retrieved before each use
106 host.memory.update_params(self.params) 108 host.memory.update_params(self.params)
107 109
108 # triggers from core 110 # triggers from core
147 """ 149 """
148 client = self.host.get_client(profile) 150 client = self.host.get_client(profile)
149 if value == DELETE_VALUE: 151 if value == DELETE_VALUE:
150 self.host.memory.del_entity_datum(client, entity_jid, ENTITY_KEY) 152 self.host.memory.del_entity_datum(client, entity_jid, ENTITY_KEY)
151 else: 153 else:
152 self.host.memory.update_entity_data( 154 self.host.memory.update_entity_data(client, entity_jid, ENTITY_KEY, value)
153 client, entity_jid, ENTITY_KEY, value
154 )
155 if not value or value == DELETE_VALUE: 155 if not value or value == DELETE_VALUE:
156 # reinit chat state UI for this or these contact(s) 156 # reinit chat state UI for this or these contact(s)
157 self.host.bridge.chat_state_received(entity_jid.full(), "", profile) 157 self.host.bridge.chat_state_received(entity_jid.full(), "", profile)
158 158
159 def param_update_trigger(self, name, value, category, type_, profile): 159 def param_update_trigger(self, name, value, category, type_, profile):
258 @return: bool 258 @return: bool
259 """ 259 """
260 client = self.host.get_client(profile) 260 client = self.host.get_client(profile)
261 try: 261 try:
262 type_ = self.host.memory.get_entity_datum( 262 type_ = self.host.memory.get_entity_datum(
263 client, to_jid.userhostJID(), C.ENTITY_TYPE) 263 client, to_jid.userhostJID(), C.ENTITY_TYPE
264 )
264 if type_ == C.ENTITY_TYPE_MUC: 265 if type_ == C.ENTITY_TYPE_MUC:
265 return True 266 return True
266 except (exceptions.UnknownEntityError, KeyError): 267 except (exceptions.UnknownEntityError, KeyError):
267 pass 268 pass
268 return False 269 return False