Added multiuser branch
This commit is contained in:
@@ -4,6 +4,7 @@ import threading
|
|||||||
import logging
|
import logging
|
||||||
import prettytable
|
import prettytable
|
||||||
import helpers
|
import helpers
|
||||||
|
import walladb
|
||||||
|
|
||||||
from worker import Worker
|
from worker import Worker
|
||||||
from telegram import Update
|
from telegram import Update
|
||||||
@@ -127,6 +128,7 @@ async def list_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||||||
await update.message.reply_markdown_v2(f'```{(table)}```')
|
await update.message.reply_markdown_v2(f'```{(table)}```')
|
||||||
|
|
||||||
def main()->None:
|
def main()->None:
|
||||||
|
walladb.setup_db()
|
||||||
products = parse_json_file()
|
products = parse_json_file()
|
||||||
|
|
||||||
for product in products:
|
for product in products:
|
||||||
|
|||||||
16
wallamanta/walladb.py
Normal file
16
wallamanta/walladb.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import sqlite3
|
||||||
|
|
||||||
|
DB = "/app/data/wallamanta.db"
|
||||||
|
|
||||||
|
def setup_db():
|
||||||
|
con = sqlite3.connect(DB)
|
||||||
|
cur = con.cursor()
|
||||||
|
cur.execute("CREATE TABLE IF NOT EXISTS users(telegram_user_id, telegram_user, active)")
|
||||||
|
cur.execute("CREATE TABLE IF NOT EXISTS products(product_name, distance, latitude, longitude, condition, min_price, max_price, title_keyword_exclude, exclude, telegram_user_id)")
|
||||||
|
con.close()
|
||||||
|
|
||||||
|
def is_user_valid(telegram_user_id):
|
||||||
|
con = sqlite3.connect(DB)
|
||||||
|
cur = con.cursor()
|
||||||
|
res = cur.execute(f"SELECT * FROM users WHERE telegram_user_id={telegram_user_id}")
|
||||||
|
return res.fetchone() is None
|
||||||
Reference in New Issue
Block a user