From: kaliko Date: Sat, 18 Mar 2023 07:59:44 +0000 (+0100) Subject: Add ban command to plugin base object X-Git-Tag: 0.3.0~16 X-Git-Url: https://git.kaliko.me/?p=sid.git;a=commitdiff_plain;h=38554203c36ceaaffd52e2781615caca608988fb Add ban command to plugin base object --- diff --git a/sid/plugin.py b/sid/plugin.py index 3f4e7da..d9ef0ae 100644 --- a/sid/plugin.py +++ b/sid/plugin.py @@ -67,6 +67,19 @@ class Plugin: to = rcv['mucroom'] self.send(to, msg, mtype=rcv['type']) + async def ban(self, jid, reason): + """Coroutine to ban a jid from the room + + :param str jid: JID to ban + :param str reason: Reason + """ + room = self.bot.room + try: + await self.bot['xep_0045'].set_affiliation(room, + jid=jid, affiliation='outcast', reason=reason) + except XMPPError as error: + self.log.error(error) + def shutdown(self): """Empty method to override. Called on bot shutdown""" pass