add: add features
This commit is contained in:
25
main.py
25
main.py
@@ -5,17 +5,21 @@ from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, WebAppInfo
|
|||||||
from aiogram.fsm.state import StatesGroup, State
|
from aiogram.fsm.state import StatesGroup, State
|
||||||
from aiogram.fsm.context import FSMContext
|
from aiogram.fsm.context import FSMContext
|
||||||
|
|
||||||
TOKEN = "8043593409:AAEC4GfxOyfv9LmbfLiwU7_g-mdtuj3y8rI"
|
TOKEN1 = "7003564044:AAE4R5Nk-E74hOno932iJINNPW3YRjjH8Mo" # web app
|
||||||
BACKEND_URL = 'https://agro.felixits.uz/'
|
TOKEN2 = "8043593409:AAEC4GfxOyfv9LmbfLiwU7_g-mdtuj3y8rI" # delivery
|
||||||
bot = Bot(token=TOKEN)
|
|
||||||
dp = Dispatcher()
|
BACKEND_URL = 'http://localhost:8080/'
|
||||||
|
bot1 = Bot(token=TOKEN1)
|
||||||
|
bot2 = Bot(token=TOKEN2)
|
||||||
|
dp1 = Dispatcher()
|
||||||
|
dp2 = Dispatcher()
|
||||||
|
|
||||||
class CodeStates(StatesGroup):
|
class CodeStates(StatesGroup):
|
||||||
phone = State()
|
phone = State()
|
||||||
full_name = State()
|
full_name = State()
|
||||||
|
|
||||||
|
|
||||||
@dp.message(filters.CommandStart())
|
@dp2.message(filters.CommandStart())
|
||||||
async def start_handler(message: types.Message, state: FSMContext):
|
async def start_handler(message: types.Message, state: FSMContext):
|
||||||
url = f"{BACKEND_URL}/api/v1/orders/supplier/{message.from_user.id}/"
|
url = f"{BACKEND_URL}/api/v1/orders/supplier/{message.from_user.id}/"
|
||||||
res = requests.get(url)
|
res = requests.get(url)
|
||||||
@@ -38,7 +42,7 @@ async def start_handler(message: types.Message, state: FSMContext):
|
|||||||
await state.clear()
|
await state.clear()
|
||||||
|
|
||||||
|
|
||||||
@dp.message(CodeStates.phone)
|
@dp2.message(CodeStates.phone)
|
||||||
async def get_code(message: types.Message, state: FSMContext):
|
async def get_code(message: types.Message, state: FSMContext):
|
||||||
phone = message.contact.phone_number
|
phone = message.contact.phone_number
|
||||||
await state.update_data(phone=phone)
|
await state.update_data(phone=phone)
|
||||||
@@ -46,7 +50,7 @@ async def get_code(message: types.Message, state: FSMContext):
|
|||||||
await state.set_state(CodeStates.full_name)
|
await state.set_state(CodeStates.full_name)
|
||||||
|
|
||||||
|
|
||||||
@dp.message(CodeStates.full_name)
|
@dp2.message(CodeStates.full_name)
|
||||||
async def get_code(message: types.Message, state: FSMContext):
|
async def get_code(message: types.Message, state: FSMContext):
|
||||||
full_name = message.text
|
full_name = message.text
|
||||||
await state.update_data(full_name=full_name)
|
await state.update_data(full_name=full_name)
|
||||||
@@ -65,7 +69,7 @@ async def get_code(message: types.Message, state: FSMContext):
|
|||||||
await message.answer(res.json())
|
await message.answer(res.json())
|
||||||
|
|
||||||
|
|
||||||
@dp.message(filters.Command(commands=['web_app']))
|
@dp1.message(filters.Command(commands=['web_app']))
|
||||||
async def start_handler(message: types.Message):
|
async def start_handler(message: types.Message):
|
||||||
keyboard = ReplyKeyboardMarkup(
|
keyboard = ReplyKeyboardMarkup(
|
||||||
keyboard=[
|
keyboard=[
|
||||||
@@ -79,7 +83,10 @@ async def start_handler(message: types.Message):
|
|||||||
await message.answer("Salom! Web Appni ochish uchun tugmani bosing 👇", reply_markup=keyboard)
|
await message.answer("Salom! Web Appni ochish uchun tugmani bosing 👇", reply_markup=keyboard)
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
await dp.start_polling(bot)
|
await asyncio.gather(
|
||||||
|
dp1.start_polling(bot1),
|
||||||
|
dp2.start_polling(bot2),
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
||||||
|
|||||||
Reference in New Issue
Block a user