Basic stuff works now

This commit is contained in:
Profitroll 2022-10-20 15:08:46 +02:00
parent eb0712f793
commit 7ca155d411

33
main.py
View File

@ -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__":