Start is now Mongo-ready
This commit is contained in:
parent
199f470192
commit
b185dff664
@ -2,24 +2,27 @@ from app import app
|
|||||||
from os import sep
|
from os import sep
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import ReplyKeyboardMarkup
|
from pyrogram.types import ReplyKeyboardMarkup
|
||||||
from modules.utils import jsonLoad, jsonSave, configGet, configSet, locale, logWrite
|
from modules.utils import locale, logWrite
|
||||||
|
from modules.database import col_users
|
||||||
|
|
||||||
# Start command ================================================================================================================
|
# Start command ================================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]))
|
||||||
async def cmd_start(app, msg):
|
async def cmd_start(app, msg):
|
||||||
|
|
||||||
try:
|
user = col_users.find_one({"user": msg.from_user.id})
|
||||||
user_stage = configGet("stage", file=str(msg.from_user.id))
|
|
||||||
if user_stage != 0:
|
|
||||||
return
|
|
||||||
except FileNotFoundError:
|
|
||||||
jsonSave(jsonLoad(f"{configGet('data', 'locations')}{sep}user_default.json"), f"{configGet('data', 'locations')}{sep}users{sep}{msg.from_user.id}.json")
|
|
||||||
user_stage = configGet("stage", file=str(msg.from_user.id))
|
|
||||||
configSet(["telegram_id"], str(msg.from_user.username), file=str(msg.from_user.id))
|
|
||||||
configSet(["telegram_name"], f"{msg.from_user.first_name} {msg.from_user.last_name}", file=str(msg.from_user.id))
|
|
||||||
configSet(["telegram_phone"], str(msg.from_user.phone_number), file=str(msg.from_user.id))
|
|
||||||
configSet(["telegram_locale"], str(msg.from_user.language_code), file=str(msg.from_user.id))
|
|
||||||
|
|
||||||
logWrite(f"User {msg.from_user.id} started bot interaction")
|
if user is None:
|
||||||
await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboard"), resize_keyboard=True))
|
|
||||||
|
col_users.insert_one({
|
||||||
|
"user": msg.from_user.id,
|
||||||
|
"link": None,
|
||||||
|
"label": "",
|
||||||
|
"tg_name": msg.from_user.first_name,
|
||||||
|
"tg_phone": msg.from_user.phone_number,
|
||||||
|
"tg_locale": msg.from_user.language_code,
|
||||||
|
"tg_username": msg.from_user.username
|
||||||
|
})
|
||||||
|
|
||||||
|
logWrite(f"User {msg.from_user.id} started bot interaction")
|
||||||
|
await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboard"), resize_keyboard=True))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
Reference in New Issue
Block a user