xmpp: Better mirror channel name and description
This commit is contained in:
parent
27d1529e6d
commit
d754fe7725
@ -145,10 +145,34 @@ class BridgeComponent(ComponentXMPP):
|
||||
pfrom=self._bot_jid_full)
|
||||
|
||||
# Set the subject
|
||||
subject = dchannel.topic or ""
|
||||
self.plugin["xep_0045"].set_subject(muc,
|
||||
subject,
|
||||
mfrom=self._bot_jid_full)
|
||||
room_config = await self.plugin["xep_0045"].get_room_config(muc,
|
||||
ifrom=self._bot_jid_full)
|
||||
room_config_fields = room_config.get_values()
|
||||
should_update = False
|
||||
description = room_config_fields.get("muc#roomconfig_roomdesc", None)
|
||||
name = room_config_fields.get("muc#roomconfig_roomname", None)
|
||||
room_config.reply()
|
||||
if not description or description != (dchannel.topic or ""):
|
||||
should_update = True
|
||||
room_config.set_values({
|
||||
"muc#roomconfig_roomdesc": dchannel.topic or ""
|
||||
})
|
||||
self.plugin["xep_0045"].set_subject(muc,
|
||||
dchannel.topic or "",
|
||||
mfrom=self._bot_jid_full)
|
||||
|
||||
if not name or name != dchannel.name:
|
||||
should_update = True
|
||||
room_config.set_values({
|
||||
"muc#roomconfig_roomname": dchannel.name
|
||||
})
|
||||
|
||||
# NOTE: To prevent messages in clients that the roomconfig changed at every restart,
|
||||
# check first if we really have to change stuff
|
||||
if should_update:
|
||||
await self.plugin["xep_0045"].set_room_config(muc,
|
||||
room_config,
|
||||
ifrom=self._bot_jid_full)
|
||||
|
||||
# TODO: Is this working?
|
||||
# Mirror the guild's icon
|
||||
@ -158,6 +182,7 @@ class BridgeComponent(ComponentXMPP):
|
||||
vcard = self.plugin["xep_0054"].make_vcard()
|
||||
vcard["PHOTO"]["TYPE"] = "image/png"
|
||||
vcard["PHOTO"]["BINVAL"] = base64.b64encode(icon)
|
||||
# TODO: Replace with provided API
|
||||
self.send_raw("""
|
||||
<iq type="set" from="{}" to="{}">
|
||||
<vCard xmlns="vcard-temp">
|
||||
|
Loading…
Reference in New Issue
Block a user