Skip to content

Commit

Permalink
some todos check
Browse files Browse the repository at this point in the history
  • Loading branch information
SivikGosh committed Feb 6, 2024
1 parent ada6426 commit 1b3b8d5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 45 deletions.
6 changes: 4 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
version: '3.8'

services:
server:
chat_watcher:
build:
context: src/
env_file:
- ./.env
command: '$START_DATE'
# command: '$START_DATE' - будет использоваться в режиме парсера
volumes:
- ./db.sqlite3:/app/db.sqlite3
File renamed without changes.
39 changes: 0 additions & 39 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from pyrogram import Client
# import time
import re
from dotenv import load_dotenv
import os
import sqlite3
# import sys

load_dotenv()

Expand All @@ -14,43 +12,6 @@
app = Client('parser', api_id, api_hash)


# def main():
# with app:
# start_date = sys.argv[1]

# count = 0

# for i in app.search_messages(os.getenv('SRC_CHAT_ID'), query='#нужно'):
# current_date = i.date.strftime("%Y-%m-%d")
# if (current_date != start_date):
# try:
# lower_mes = i.text.lower()
# except AttributeError:
# lower_mes = '_'
# mes = re.findall(r'[A-Яа-я0-9\/]+', lower_mes)
# con = sqlite3.connect('db.sqlite3')
# cur = con.cursor()
# res = cur.execute('SELECT * FROM addresses')
# for j in res.fetchall():
# alias = [j[1]]
# build = j[2].split(',')
# sett = set(alias + build)
# if len(sett.intersection(mes)) > 1:
# app.forward_messages(
# 'me',
# from_chat_id=os.getenv('SRC_CHAT_ID'),
# message_ids=i.id
# )
# count += 1
# else:
# break

# time.sleep(1)

# app.send_message('me', f'проверено {count} сообщений')
# app.read_chat_history(os.getenv('SRC_CHAT_ID'))


@app.on_message()
def test(client, message):
if (message.chat.id == int(os.getenv('SRC_CHAT_ID'))) and ('#нужно' in message.text):
Expand Down
39 changes: 39 additions & 0 deletions src/parse_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# import time
# import sys


# def main():
# with app:
# start_date = sys.argv[1]

# count = 0

# for i in app.search_messages(os.getenv('SRC_CHAT_ID'), query='#нужно'):
# current_date = i.date.strftime("%Y-%m-%d")
# if (current_date != start_date):
# try:
# lower_mes = i.text.lower()
# except AttributeError:
# lower_mes = '_'
# mes = re.findall(r'[A-Яа-я0-9\/]+', lower_mes)
# con = sqlite3.connect('db.sqlite3')
# cur = con.cursor()
# res = cur.execute('SELECT * FROM addresses')
# for j in res.fetchall():
# alias = [j[1]]
# build = j[2].split(',')
# sett = set(alias + build)
# if len(sett.intersection(mes)) > 1:
# app.forward_messages(
# 'me',
# from_chat_id=os.getenv('SRC_CHAT_ID'),
# message_ids=i.id
# )
# count += 1
# else:
# break

# time.sleep(1)

# app.send_message('me', f'проверено {count} сообщений')
# app.read_chat_history(os.getenv('SRC_CHAT_ID'))
5 changes: 1 addition & 4 deletions todo.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# TODO: настройка скрипта на прослушивание чата на новые сообщения ' old
# TODO: добавить ORM для работы с базой ' old
# TODO: добавить конвертацию xlsx в json (либо сразу писать в бд?) ' old
# TODO: выпилить bill.py для unique_addresses.py, получать адреса из бд ' old
# TODO: почистить неиспользуемые пакеты requirements.txt ' old
# TODO: переезд на Poetry ' old
# TODO: подобрать инструмент для readme (генерация?) ' old
# TODO: рефакт функции main (класс?) ' old
# TODO: нужна оптимизация файла Dockerfile ' old
# TODO: добавить версию файла compose.yml ' old
# TODO: добавить .env в отдельный volume ' old
# TODO: добавить режим парсинга

0 comments on commit 1b3b8d5

Please sign in to comment.