From: kaliko Date: Sat, 25 Mar 2023 14:07:47 +0000 (+0100) Subject: rtbl: some cleanup X-Git-Tag: 0.4.0~3 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=1aea0b1d518984cc82c616c584a4fa7d20b81ec5;p=sid.git rtbl: some cleanup --- diff --git a/sid/rtbl.py b/sid/rtbl.py index 6b33344..424a179 100644 --- a/sid/rtbl.py +++ b/sid/rtbl.py @@ -52,7 +52,6 @@ class BL: def get_reason(self, jid: JID) -> Optional[str]: """Check the presence of the JID in the blocklist""" jidhash = jid_to_sha256(jid) - # Raises if item does not exist return self.sha256_jids[jidhash] def __len__(self): @@ -146,9 +145,9 @@ class RTBL(Plugin): for jid in [pres['muc']['jid'] for pres in self.presences.values()]: await self.rtbl_ban(jid) - async def rtbl_ban(self, jid): + async def rtbl_ban(self, jid: JID): """Ban jid in RTBL""" - if not self.moderator: + if not self.moderator or not jid.bare: return if self.blocklist is None: self.log.info('Not checking %s, block list not populated yet', jid) @@ -174,13 +173,12 @@ class RTBL(Plugin): else: self.log.info('Got moderator permissions.') self.moderator = True + #TODO: purge presences cache sid.MUCBot.muc_presences? async def got_online(self, pres): """Handler method for new MUC participants""" fjid = pres['muc']['jid'] - nick = pres['muc']['nick'] - user = fjid if fjid.full else nick - await self.rtbl_ban(user) + await self.rtbl_ban(fjid) @botcmd(name="rtbl-info") def rtbl_info(self, rcv, _):