cleanup, discord filter

Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/chen/trunk@27 32723744-9b23-0b4a-b1da-9b2e968f9461
This commit is contained in:
yakumo.izuru 2023-11-02 15:18:34 +00:00
parent 040037ac70
commit 26d52f2098

16
main.py
View File

@ -105,14 +105,14 @@ class ChenBot(ClientXMPP):
else:
try:
lenght = 0
length = 0
outfile = io.BytesIO()
for chunk in r.iter_content(
chunk_size=512,
decode_unicode=False,
):
lenght += 512
if lenght >= data_limit:
length += 512
if length >= data_limit:
return
outfile.write(chunk)
@ -142,6 +142,8 @@ class ChenBot(ClientXMPP):
return
if "#nospoil" in msg["body"].lower():
return
if "cdn.discordapp.com" in msg["body"].lower():
msg.reply("Ew, discord! :<\n").send()
for u in urls:
if u in self.messages[sender]["links"]:
continue
@ -193,10 +195,6 @@ class ChenBot(ClientXMPP):
mtype = "chat"
sender = msg["from"].bare
edit = "urn:xmpp:message-correct:0" in str(msg)
if edit:
return
try:
if not msg["oob"]["url"]:
if urls := self.get_urls(msg):
@ -211,10 +209,6 @@ class ChenBot(ClientXMPP):
if msg["mucnick"] == self.nick:
return
edit = "urn:xmpp:message-correct:0" in str(msg)
if edit:
return
try:
if not msg["oob"]["url"]:
if urls := self.get_urls(msg):