-
Notifications
You must be signed in to change notification settings - Fork 0
/
lesAiles_tgBot.py
100 lines (89 loc) · 3.49 KB
/
lesAiles_tgBot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# python_tgBot_lesAiles
import telebot
from telebot import types
bot = telebot.TeleBot(os.environ.get("BOT_TOKEN", "WWW"))
menus = ['💸Cashback', '🎉Tadbirlar', '✍️Fikr bildirish', "ℹ️Ma'lumot"]
def start_button():
markup = types.ReplyKeyboardMarkup(row_width=2)
markup.row(telebot.types.KeyboardButton('🛍Buyrtma berish'))
markup.add(*[
telebot.types.KeyboardButton(text) for text in menus
])
markup.row(
telebot.types.KeyboardButton('⚙️Sozlamalar')
)
return markup
buyrtma = ['🚘Yetkazib berish', '🏃Olib ketish']
def buyrtma_berish():
markup = telebot.types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=1)
markup.add(*[
telebot.types.KeyboardButton(text) for text in buyrtma
])
markup.row(
telebot.types.KeyboardButton('⬅️Orqaga')
)
return markup
def location():
markup = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=1)
markup.row(types.KeyboardButton(text='📍Eng yaqin shaxobchamizni aniqlash', request_location=True))
markup.row(types.KeyboardButton('⬅️Orqaga'))
return markup
loca = ['Joylashuvni qayta jo`natish📍', '☑️Tasdiqlash']
def joylashuv():
markup = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=1)
markup.add(*[
types.KeyboardButton(text) for text in loca
])
markup.row(
telebot.types.KeyboardButton('⬅️Orqaga')
)
return markup
oxirgi = ['📥 Savat', '🚘 Buyurtma berish', '🍱Setlar', '🍔 Burgerlar', '🌯 Lesterlar', '🌭 Longer/Hot-dog', '🍗 Tovuqcha'\
'🍟 Snekla', '🥗 Salatlar', '🎁 Bolalar uchun', '🍰 Десерты', '☕️ Ichimliklar', '😋 Souslar', '']
def savat():
markup = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=2)
markup.add(*[
types.KeyboardButton(text) for text in oxirgi
])
return markup
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(
message.from_user.id,
'Juda yaxshi! Birgalikda buyurtma beramizmi? 😁',
reply_markup=start_button()
)
@bot.message_handler(func=lambda message: True)
def start_message(message):
if message.text == '🛍Buyrtma berish':
text = "Buyrtmani <b>o`zingiz</b> olib keting yoki <b>Yetkazib berishni</b> tanlang"
bot.send_message(
message.from_user.id,
text,
parse_mode='HTML',
reply_markup=buyrtma_berish()
)
elif message.text == '🚘Yetkazib berish':
text = "Buyurtmangizni qaerga yetkazib berish kerak 🚙?\
Agar lokatsiyangizni📍 yuborsangiz, sizga eng yaqin filialni va yetkazib berish xarajatlarini aniqlaymiz 💵"
bot.send_message(
message.from_user.id,
text,
reply_markup = location()
)
elif message.text == '☑️Tasdiqlash':
text = '10:00 - 22:00 - 1 km gacha bo’lgan buyurtmalar yetkazish narxi 5000 so’m\
10:00 - 22:00 - 3 km gacha 9000 so’m keyingi har 1 km uchun -1000 sum Toshkent shahri bo’ylab.'
bot.send_message(
message.from_user.id,
text,
reply_markup=savat()
)
@bot.message_handler(content_types=['location'])
def location_m(message):
text = "Sizning manzilingiz: Узбекистан, Ташкент, улица Козитарнов, 50\
\
Joylashuv natug'rimi?\
Qayta jo'nating 📍"
bot.send_message(message.from_user.id, text, reply_markup=joylashuv())
bot.polling(none_stop=True)