Start is now Mongo-ready
This commit is contained in:
parent
199f470192
commit
b185dff664
@ -2,23 +2,26 @@ 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:
|
if user is None:
|
||||||
return
|
|
||||||
except FileNotFoundError:
|
col_users.insert_one({
|
||||||
jsonSave(jsonLoad(f"{configGet('data', 'locations')}{sep}user_default.json"), f"{configGet('data', 'locations')}{sep}users{sep}{msg.from_user.id}.json")
|
"user": msg.from_user.id,
|
||||||
user_stage = configGet("stage", file=str(msg.from_user.id))
|
"link": None,
|
||||||
configSet(["telegram_id"], str(msg.from_user.username), file=str(msg.from_user.id))
|
"label": "",
|
||||||
configSet(["telegram_name"], f"{msg.from_user.first_name} {msg.from_user.last_name}", file=str(msg.from_user.id))
|
"tg_name": msg.from_user.first_name,
|
||||||
configSet(["telegram_phone"], str(msg.from_user.phone_number), file=str(msg.from_user.id))
|
"tg_phone": msg.from_user.phone_number,
|
||||||
configSet(["telegram_locale"], str(msg.from_user.language_code), file=str(msg.from_user.id))
|
"tg_locale": msg.from_user.language_code,
|
||||||
|
"tg_username": msg.from_user.username
|
||||||
|
})
|
||||||
|
|
||||||
logWrite(f"User {msg.from_user.id} started bot interaction")
|
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))
|
await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboard"), resize_keyboard=True))
|
||||||
|
Reference in New Issue
Block a user