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):
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)
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, _):