add new features

This commit is contained in:
behruz-dev
2025-09-04 17:28:34 +05:00
parent 9579dff3fb
commit f94947768c

29
main.py
View File

@@ -1,19 +1,44 @@
import asyncio, logging, sys, os, requests
from aiogram import Bot, Dispatcher, types, filters
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, WebAppInfo
import asyncio, logging, sys
from aiogram.fsm.state import StatesGroup, State
from aiogram.fsm.context import FSMContext
TOKEN = "8147952177:AAEsR2ejafoKVb_OFcm6rEJAzUt_BKiOr5A"
bot = Bot(token=TOKEN)
dp = Dispatcher()
class CodeStates(StatesGroup):
product_code = State()
@dp.message(filters.CommandStart())
async def start_handler(message: types.Message, state: FSMContext):
await message.answer("Assalomu alaykum! Iltimos, mahsulot kodni kiriting:")
await state.set_state(CodeStates.product_code)
@dp.message(CodeStates.product_code)
async def get_code(message: types.Message, state: FSMContext):
code = message.text
await state.clear()
url = f'https://horeca.felixits.uz/api/v1/products/set_tg_id/{code}/'
res = requests.post(url, data={'tg_id': message.from_user.id})
if res.status_code == 200:
await message.answer("Raxmat")
else:
await message.answer("Mahsulot topilmadi, qayta urinib koring")
@dp.message(filters.Command(commands=['web_app']))
async def start_handler(message: types.Message):
keyboard = ReplyKeyboardMarkup(
keyboard=[
[KeyboardButton(
text="Open",
web_app=WebAppInfo(url="https://agro360.vercel.app") # Web app URL
web_app=WebAppInfo(url="https://agro360.vercel.app")
)]
],
resize_keyboard=True