mirror of
https://github.com/house-of-vanity/conf_bot.git
synced 2025-07-06 14:24:08 +00:00
Code has been formatted.
This commit is contained in:
committed by
Alexandr Bogomyakov
parent
7320a10b51
commit
31ce4d15cf
@ -1,5 +1,6 @@
|
|||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
|
||||||
|
|
||||||
class DataBase:
|
class DataBase:
|
||||||
def __init__(self, basefile, scheme):
|
def __init__(self, basefile, scheme):
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -10,6 +10,7 @@ import settings
|
|||||||
# fuckin dirty hack. idk the best way to inherit return func into
|
# fuckin dirty hack. idk the best way to inherit return func into
|
||||||
# RequestHandler class
|
# RequestHandler class
|
||||||
|
|
||||||
|
|
||||||
class RequestHandler(SimpleHTTPRequestHandler):
|
class RequestHandler(SimpleHTTPRequestHandler):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
request,
|
request,
|
||||||
@ -36,7 +37,6 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class WebHook:
|
class WebHook:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
certfile,
|
certfile,
|
||||||
|
@ -18,6 +18,7 @@ from pygments.lexers import guess_lexer, get_lexer_by_name
|
|||||||
from pygments.styles import get_style_by_name
|
from pygments.styles import get_style_by_name
|
||||||
from pygments.formatters import ImageFormatter
|
from pygments.formatters import ImageFormatter
|
||||||
|
|
||||||
|
|
||||||
class MessageWorker:
|
class MessageWorker:
|
||||||
def __init__(self, db, stop_words='assets/stop-word.ru', settings=settings):
|
def __init__(self, db, stop_words='assets/stop-word.ru', settings=settings):
|
||||||
self.stop_words = stop_words
|
self.stop_words = stop_words
|
||||||
@ -38,7 +39,8 @@ class MessageWorker:
|
|||||||
def handleUpdate(self, msg):
|
def handleUpdate(self, msg):
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
input_message = msg['message']['text'].replace('@' + self.me['result']['username'], '')
|
input_message = msg['message']['text'].replace(
|
||||||
|
'@' + self.me['result']['username'], '')
|
||||||
except:
|
except:
|
||||||
input_message = msg['message']['text']
|
input_message = msg['message']['text']
|
||||||
if input_message == '/scheme':
|
if input_message == '/scheme':
|
||||||
@ -175,12 +177,12 @@ class MessageWorker:
|
|||||||
for word in collection:
|
for word in collection:
|
||||||
self.db.add_relation(word=word, user_id=user_id, conf_id=chat_id)
|
self.db.add_relation(word=word, user_id=user_id, conf_id=chat_id)
|
||||||
|
|
||||||
|
|
||||||
def clean_text(self, s):
|
def clean_text(self, s):
|
||||||
file = open(self.stop_words, 'rt')
|
file = open(self.stop_words, 'rt')
|
||||||
sw = file.read().split('\n')
|
sw = file.read().split('\n')
|
||||||
file.close()
|
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)
|
print(s)
|
||||||
# dirty hack with dat fucking file
|
# dirty hack with dat fucking file
|
||||||
fh = open("tmp.txt", "w")
|
fh = open("tmp.txt", "w")
|
||||||
|
Reference in New Issue
Block a user