remove debug
This commit is contained in:
parent
c922bed060
commit
a2d419d29c
19
bot.py
19
bot.py
@ -16,11 +16,9 @@ import os
|
||||
from model import User, Message, MessageHide, UserBan, session
|
||||
from time import strftime
|
||||
import re
|
||||
import json
|
||||
import unidecode
|
||||
from mwt import MWT
|
||||
from googletrans import Translator
|
||||
from textblob import TextBlob
|
||||
|
||||
class TelegramMonitorBot:
|
||||
|
||||
@ -28,12 +26,12 @@ class TelegramMonitorBot:
|
||||
def __init__(self):
|
||||
self.debug = (
|
||||
(os.environ.get('DEBUG') is not None) and
|
||||
(os.environ.get('DEBUG').lower() != "false"))
|
||||
(os.environ.get('DEBUG').upper() != "false"))
|
||||
|
||||
# Are admins exempt from having messages checked?
|
||||
self.admin_exempt = (
|
||||
(os.environ.get('ADMIN_EXEMPT') is not None) and
|
||||
(os.environ.get('ADMIN_EXEMPT').lower() != "false"))
|
||||
(os.environ.get('ADMIN_EXEMPT').upper() != "false"))
|
||||
|
||||
if (self.debug):
|
||||
print("🔵 debug:", self.debug)
|
||||
@ -285,7 +283,6 @@ class TelegramMonitorBot:
|
||||
print("👮♂️ Skipping checks. User is admin: {}".format(user.id))
|
||||
else:
|
||||
# Security checks
|
||||
print(json.dumps(update))
|
||||
self.attachment_check(bot, update)
|
||||
self.security_check_username(bot, update)
|
||||
self.security_check_message(bot, update)
|
||||
@ -306,26 +303,20 @@ class TelegramMonitorBot:
|
||||
|
||||
return bool_set
|
||||
|
||||
|
||||
def log_message(self, user_id, user_message, chat_id):
|
||||
try:
|
||||
s = session()
|
||||
language_code = english_message = ""
|
||||
polarity = subjectivity = 0.0
|
||||
try:
|
||||
# translate to English & log the original language
|
||||
translator = Translator()
|
||||
translated = translator.translate(user_message)
|
||||
language_code = translated.src
|
||||
english_message = translated.text
|
||||
# run basic sentiment analysis on the translated English string
|
||||
analysis = TextBlob(english_message)
|
||||
polarity = analysis.sentiment.polarity
|
||||
subjectivity = analysis.sentiment.subjectivity
|
||||
except Exception as e:
|
||||
print(e.message)
|
||||
msg1 = Message(user_id=user_id, message=user_message, chat_id=chat_id,
|
||||
language_code=language_code, english_message=english_message, polarity=polarity,
|
||||
subjectivity=subjectivity)
|
||||
msg1 = Message(user_id=user_id, message=user_message,
|
||||
chat_id=chat_id, language_code=language_code, english_message=english_message)
|
||||
s.add(msg1)
|
||||
s.commit()
|
||||
s.close()
|
||||
|
Loading…
Reference in New Issue
Block a user