From 7ca155d4114ec66bce7d6ff94425b3421a637305 Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 20 Oct 2022 15:08:46 +0200 Subject: [PATCH] Basic stuff works now --- main.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 2d75944..700da6e 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import asyncio +from time import time from os import getpid, listdir from modules.utils import * @@ -22,8 +23,12 @@ async def cmd_start(app, msg): except FileNotFoundError: jsonSave(jsonLoad(f"data{sep}user_default.json"), f"data{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)) - await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboards"))) + await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboards"), resize_keyboard=True)) @app.on_message(~ filters.scheduled & filters.command(["kill", "die", "reboot"], prefixes=["", "/"])) async def cmd_kill(app, msg): @@ -43,7 +48,31 @@ async def welcome_pass(app, msg): @app.on_message(~ filters.scheduled & (filters.regex(locale("welcome", "keyboards")[1][0]))) async def welcome_reject(app, msg): - await msg.reply_text(locale("goodbye", "message"), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboards"))) + await msg.reply_text(locale("goodbye", "message"), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboards"), resize_keyboard=True)) + + +@app.on_message(~ filters.scheduled) +async def any_stage(app, msg): + + user_stage = configGet("stage", file=str(msg.from_user.id)) + + if user_stage == 1: + await msg.reply_text(locale(f"question{user_stage+1}", "message"), reply_markup=ForceReply(placeholder="Enter shit")) + configSet(str(user_stage), str(msg.text), "application", file=str(msg.from_user.id)) + configSet("stage", user_stage+1, file=str(msg.from_user.id)) + else: + if user_stage <= 9: + await msg.reply_text(locale(f"question{user_stage+1}", "message"), reply_markup=ForceReply(placeholder="Enter shit")) + configSet(str(user_stage), str(msg.text), "application", file=str(msg.from_user.id)) + configSet("stage", user_stage+1, file=str(msg.from_user.id)) + else: + if not configGet("sent", file=str(msg.from_user.id)): + await msg.reply_text("You are fucking done, great job!") + configSet(str(user_stage), str(msg.text), "application", file=str(msg.from_user.id)) + configSet("sent", True, file=str(msg.from_user.id)) + configSet("application_date", int(time()), file=str(msg.from_user.id)) + else: + await msg.reply_text("You are already done, wait!") if __name__ == "__main__":