diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2020-12-27 02:42:49 +0100 |
---|---|---|
committer | Link Mauve <linkmauve@linkmauve.fr> | 2020-12-28 19:10:53 +0100 |
commit | c38538f6b52fa8a3ff0a023559235fcc49135201 (patch) | |
tree | febddcfe623d5dd4de9aabf25b2a799b8eade20c /poezio/tabs/muctab.py | |
parent | 4b0e481902084970e89eafd23acd535b0e6187bc (diff) | |
download | poezio-c38538f6b52fa8a3ff0a023559235fcc49135201.tar.gz poezio-c38538f6b52fa8a3ff0a023559235fcc49135201.tar.bz2 poezio-c38538f6b52fa8a3ff0a023559235fcc49135201.tar.xz poezio-c38538f6b52fa8a3ff0a023559235fcc49135201.zip |
Rework set_role() to use slixmpp.
Also remove a safeJID().
Diffstat (limited to 'poezio/tabs/muctab.py')
-rw-r--r-- | poezio/tabs/muctab.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index 31b6d845..feb498fa 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -276,12 +276,6 @@ class MucTab(ChatTab): Change the role of a nick """ - def callback(iq: Iq) -> None: - if iq['type'] == 'error': - self.core.information( - "Could not set role '%s' for '%s'." % (role, nick), - "Warning") - valid_roles = ('none', 'visitor', 'participant', 'moderator') if not self.joined or role not in valid_roles: @@ -296,8 +290,15 @@ class MucTab(ChatTab): self.core.information('Invalid nick', 'Info') return - muc.set_user_role( - self.core.xmpp, self.jid.bare, nick, reason, role, callback=callback) + async def do_set_role(room: JID, nick: str, role: str, reason: str): + try: + await self.core.xmpp['xep_0045'].set_role(room, nick, role, reason=reason) + except (IqError, IqTimeout) as e: + self.core.information( + "Could not set role '%s' for '%s': %s" % (role, nick, e), + "Warning") + + asyncio.ensure_future(do_set_role(self.jid.bare, nick, role, reason)) @refresh_wrapper.conditional def print_info(self, nick: str) -> bool: |