mirror of
https://github.com/house-of-vanity/conf_bot.git
synced 2025-07-06 14:24:08 +00:00
test
This commit is contained in:
18
worker.py
Normal file → Executable file
18
worker.py
Normal file → Executable file
@ -8,6 +8,7 @@ import os
|
||||
import urllib.request
|
||||
from urllib.parse import urlencode
|
||||
import settings
|
||||
import re
|
||||
|
||||
class MessageWorker:
|
||||
def __init__(self, db, stop_words = 'assets/stop-word.ru'):
|
||||
@ -31,6 +32,21 @@ class MessageWorker:
|
||||
message += '*%s*: %s\n' % (word[1], word[0])
|
||||
self.send(id=conf_id, msg=message)
|
||||
return True
|
||||
if msg['message']['text'] == '@here':
|
||||
conf_id = msg['message']['chat']['id']
|
||||
user_id = msg['message']['from']['id']
|
||||
chat_title = msg['message']['chat']['title']
|
||||
self.db.add_conf(conf_id, chat_title)
|
||||
|
||||
message = """I summon you!\n"""
|
||||
users = self.db.here(
|
||||
user_id=user_id,
|
||||
conf_id=conf_id
|
||||
)
|
||||
for user in users:
|
||||
message += '@%s ' % (user[0])
|
||||
self.send(id=conf_id, msg=message)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
try:
|
||||
@ -68,6 +84,8 @@ class MessageWorker:
|
||||
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)
|
||||
print(s)
|
||||
# dirty hack with dat fucking file
|
||||
fh = open("tmp.txt","w")
|
||||
fh.write(s)
|
||||
|
Reference in New Issue
Block a user