xmpp: Better mirror channel name and description
This commit is contained in:
parent
27d1529e6d
commit
d754fe7725
@ -145,11 +145,35 @@ class BridgeComponent(ComponentXMPP):
|
|||||||
pfrom=self._bot_jid_full)
|
pfrom=self._bot_jid_full)
|
||||||
|
|
||||||
# Set the subject
|
# Set the subject
|
||||||
subject = dchannel.topic or ""
|
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,
|
self.plugin["xep_0045"].set_subject(muc,
|
||||||
subject,
|
dchannel.topic or "",
|
||||||
mfrom=self._bot_jid_full)
|
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?
|
# TODO: Is this working?
|
||||||
# Mirror the guild's icon
|
# Mirror the guild's icon
|
||||||
icon = await dchannel.guild.icon_url_as(static_format="png",
|
icon = await dchannel.guild.icon_url_as(static_format="png",
|
||||||
@ -158,6 +182,7 @@ class BridgeComponent(ComponentXMPP):
|
|||||||
vcard = self.plugin["xep_0054"].make_vcard()
|
vcard = self.plugin["xep_0054"].make_vcard()
|
||||||
vcard["PHOTO"]["TYPE"] = "image/png"
|
vcard["PHOTO"]["TYPE"] = "image/png"
|
||||||
vcard["PHOTO"]["BINVAL"] = base64.b64encode(icon)
|
vcard["PHOTO"]["BINVAL"] = base64.b64encode(icon)
|
||||||
|
# TODO: Replace with provided API
|
||||||
self.send_raw("""
|
self.send_raw("""
|
||||||
<iq type="set" from="{}" to="{}">
|
<iq type="set" from="{}" to="{}">
|
||||||
<vCard xmlns="vcard-temp">
|
<vCard xmlns="vcard-temp">
|
||||||
|
Loading…
Reference in New Issue
Block a user