This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/modules/commands/start.py

29 lines
1.4 KiB
Python
Raw Normal View History

2022-12-05 19:49:51 +02:00
from app import app
from pyrogram import filters
2022-12-27 14:36:54 +02:00
from pyrogram.types import ReplyKeyboardMarkup, Message
from pyrogram.client import Client
2022-12-11 20:52:14 +02:00
from modules.utils import locale, logWrite
from modules.database import col_users
2023-01-03 21:34:13 +02:00
from modules import custom_filters
2022-12-05 19:49:51 +02:00
# Start command ================================================================================================================
2023-01-03 21:34:13 +02:00
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]))
2022-12-27 14:36:54 +02:00
async def cmd_start(app: Client, msg: Message):
2022-12-05 19:49:51 +02:00
2022-12-11 20:52:14 +02:00
user = col_users.find_one({"user": msg.from_user.id})
2022-12-05 19:49:51 +02:00
2022-12-11 20:52:14 +02:00
if user is None:
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")
2022-12-17 01:58:33 +02:00
await msg.reply_text(locale("start", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboard", locale=msg.from_user), resize_keyboard=True))
2022-12-05 19:49:51 +02:00
# ==============================================================================================================================