Repair blocklist (#110)
* fixing blocklist * added logging of blocklist events * goodlist logging * twitter DMs are broken * fixed blocklist & tested it * disabling twitterDMs should be in a separate PR.master
parent
9b6c51ebd6
commit
be72923f07
13
user.py
13
user.py
|
@ -5,7 +5,9 @@ import jwt
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
from pylibscrypt import scrypt_mcf, scrypt_mcf_check
|
from pylibscrypt import scrypt_mcf, scrypt_mcf_check
|
||||||
from os import urandom
|
from os import urandom
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
def __init__(self, uid):
|
def __init__(self, uid):
|
||||||
|
@ -74,6 +76,7 @@ class User(object):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# no pattern matched
|
# no pattern matched
|
||||||
|
logger.error("Message didn't trigger goodlist: " + report.text)
|
||||||
return False
|
return False
|
||||||
default_badwords = """
|
default_badwords = """
|
||||||
bitch
|
bitch
|
||||||
|
@ -93,11 +96,13 @@ schlitz
|
||||||
db.execute("SELECT words FROM badwords WHERE user_id=?;",
|
db.execute("SELECT words FROM badwords WHERE user_id=?;",
|
||||||
(self.uid, ))
|
(self.uid, ))
|
||||||
badwords = db.cur.fetchone()
|
badwords = db.cur.fetchone()
|
||||||
for word in report.text.lower().splitlines():
|
for word in report.text.lower().split():
|
||||||
if word in badwords:
|
if word in badwords[0].splitlines():
|
||||||
|
logger.error("Word " + word + " triggered the spam filter on message: " + report.text)
|
||||||
return False
|
return False
|
||||||
for word in default_badwords.splitlines():
|
for word in report.text.lower().split():
|
||||||
if word in badwords:
|
if word in default_badwords.splitlines():
|
||||||
|
logger.error("Word " + word + " triggered the spam filter on message: " + report.text)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue