import telebot
bot = telebot.TeleBot('1711149709:AAHPbqEzQMPQlYKAGczYxxwSpT1EBQuyQkQ')
def start_message_buttons():
reply_markup = telebot.types.ReplyKeyboardMarkup(row_width=2,resize_keyboard=True)
reply_markup.row(telebot.types.KeyboardButton('Locatsiya jonatish',request_location=True))
reply_markup.row(telebot.types.KeyboardButton('Telefon raqam yuborish', request_contact=True))
return reply_markup
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.from_user.id,
f" Salom {message.from_user.first_name}",
reply_markup=start_message_buttons())
@bot.message_handler(func=lambda m: True)
def all_message(message):
if message.text.lower() == 'salom':
bot.send_message(message.from_user.id,'Nima gap!')
bot.polling(none_stop=True)
import telebot
bot = telebot.TeleBot('1711149709:AAHPbqEzQMPQlYKAGczYxxwSpT1EBQuyQkQ')
PRODUCTS = "Maxsulotlar"
GEIDS = "Qullanma"
BUYURTMA = "Buyurtma berish"
LOCATSIA = "Locatsia yuborish"
CONTACT = "Contact yuborish"
products_data = [
{'id':1,'name':'Olma','price': 500,'photo':'olma.jpg'},
{'id':2,'name':'Banan','price': 700,'photo':'banan.jpg'},
{'id':3,'name':'Ananas','price': 1000,'photo':'Ananas.png'}
]
def get_photo(file_name):
f = open(f"img/{file_name}",'rb')
imega = f.read()
f.close()
return imega
def start_message_buttons():
reply_markup = telebot.types.ReplyKeyboardMarkup(row_width=2,resize_keyboard=True)
reply_markup.add(*[
telebot.types.KeyboardButton(text) for text in [PRODUCTS,GEIDS,BUYURTMA]
])
return reply_markup
@bot.message_handler(commands=['start'])
def start_message(message):
text = f"Salom {message.from_user.first_name} onlayn magazinga hush kelibsiz"
bot.send_message(message.from_user.id,text,reply_markup=start_message_buttons())
def buyurtma_buttons():
reply_markup = telebot.types.ReplyKeyboardMarkup(row_width=2,resize_keyboard=True)
reply_markup.add(*[
telebot.types.KeyboardButton('Locatsia yuborish',request_location=True),
telebot.types.KeyboardButton('Contact yuborish', request_contact=True),
telebot.types.KeyboardButton('Orqaga'),
])
return reply_markup
@bot.message_handler(func=lambda m: True)
def all_message(message):
if message.text == PRODUCTS:
for product in products_data:
caption = f"{product['name']}\n\n{product['price']} so'm"
bot.send_photo(photo=get_photo(product['photo']),chat_id=message.from_user.id,caption=caption)
if message.text == GEIDS:
text = f"https://www.youtube.com/watch?v=Zp-F68Fa-ps \n\n vedioni kuring"
bot.send_message(message.from_user.id,text)
if message.text == BUYURTMA:
text = 'Buyurmani yetkazish uchun lacatsia va contactlarni ulashing'
bot.send_message(message.from_user.id,text,reply_markup=buyurtma_buttons())
if message.text == 'Orqaga':
text = 'Buyurmani amalga oshirish uchun Buyurtma tugmasini bosing!'
bot.send_message(message.from_user.id,text,reply_markup=start_message_buttons())
bot.polling(none_stop=True)
Do'stlaringiz bilan baham: |