Code has been formatted.

This commit is contained in:
Alexandr
2018-08-03 15:15:35 +03:00
committed by Alexandr Bogomyakov
parent 7320a10b51
commit 31ce4d15cf
4 changed files with 74 additions and 71 deletions

View File

@ -1,5 +1,6 @@
import datetime as dt
class DataBase:
def __init__(self, basefile, scheme):
import sqlite3

View File

@ -10,6 +10,7 @@ import settings
# fuckin dirty hack. idk the best way to inherit return func into
# RequestHandler class
class RequestHandler(SimpleHTTPRequestHandler):
def __init__(self,
request,
@ -36,7 +37,6 @@ class RequestHandler(SimpleHTTPRequestHandler):
pass
class WebHook:
def __init__(self,
certfile,

View File

@ -18,6 +18,7 @@ from pygments.lexers import guess_lexer, get_lexer_by_name
from pygments.styles import get_style_by_name
from pygments.formatters import ImageFormatter
class MessageWorker:
def __init__(self, db, stop_words='assets/stop-word.ru', settings=settings):
self.stop_words = stop_words
@ -38,7 +39,8 @@ class MessageWorker:
def handleUpdate(self, msg):
try:
try:
input_message = msg['message']['text'].replace('@' + self.me['result']['username'], '')
input_message = msg['message']['text'].replace(
'@' + self.me['result']['username'], '')
except:
input_message = msg['message']['text']
if input_message == '/scheme':
@ -175,12 +177,12 @@ class MessageWorker:
for word in collection:
self.db.add_relation(word=word, user_id=user_id, conf_id=chat_id)
def clean_text(self, s):
file = open(self.stop_words, 'rt')
sw = file.read().split('\n')
file.close()
s = re.sub(r'(https?:\/\/)?([\da-z\.-]+)\.([\/\w\.-]*)*\/?\S','',s,flags=re.MULTILINE)
s = re.sub(
r'(https?:\/\/)?([\da-z\.-]+)\.([\/\w\.-]*)*\/?\S', '', s, flags=re.MULTILINE)
print(s)
# dirty hack with dat fucking file
fh = open("tmp.txt", "w")