27.09.2020",
parse_mode='html',reply_markup=markup)
bot.answer_callback_query(call.id, "Endi xabarnomani jo\'natish sanasini yuboring")
bot.delete_message(call.message.chat.id, call.message.message_id)
bot.register_next_step_handler(msg, data_sana_step)
elif call.data == "one_back":
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
markup.row('📣 Yangi xabarnomani qo\'shish')
markup.row('🔕 O\'rnatilgan xabarnomani o\'chirish')
bot.answer_callback_query(call.id, "Ortga")
bot.send_message(chat_id, "Men Grootman 🌱",
reply_markup=markup, parse_mode="html")
bot.delete_message(call.message.chat.id, call.message.message_id)
elif call.data == "back":
bot.answer_callback_query(call.id, "Ortga")
keyboard_l = types.InlineKeyboardMarkup()
btn1 = types.InlineKeyboardButton("🗓 Har hafta", callback_data="hafta_kun")
btn2 = types.InlineKeyboardButton("📅 Har oyda", callback_data="only_one_date")
btn3 = types.InlineKeyboardButton("🔂 Bir martalik", callback_data="only_one")
back = types.InlineKeyboardButton("🔙Ortga", callback_data="back")
keyboard_l.add(btn1)
keyboard_l.add(btn2)
keyboard_l.add(btn3)
keyboard_l.add(back)
msg = bot.send_message(call.from_user.id, "🎯 Xabarnoma turini tanlang",
reply_markup=keyboard_l)
bot.delete_message(call.message.chat.id, call.message.message_id)
elif call.data in weekdays:
if call.data == "Monday":
bot.answer_callback_query(call.id, "Dushanba kuni belgilandi")
if call.data == "Tuesday":
bot.answer_callback_query(call.id, "Seshanba kuni belgilandi")
if call.data == "Wednesday":
bot.answer_callback_query(call.id, "Chorshanba kuni belgilandi")
if call.data == "Thursday":
bot.answer_callback_query(call.id, "Payshanba kuni belgilandi")
if call.data == "Friday":
bot.answer_callback_query(call.id, "Juma kuni belgilandi")
if call.data == "Saturday":
bot.answer_callback_query(call.id, "Shanba kuni belgilandi")
if call.data == "Sunday":
bot.answer_callback_query(call.id, "Yakshanba kuni belgilandi")
try:
session = Session()
days = session.query(Rejim).filter(Rejim.user_id == chat_id).filter(Rejim.finish == 0).order_by(Rejim.id.desc()).first()
new_day = days.day
if new_day is None:
up_id = session.query(Rejim).filter(Rejim.user_id == chat_id).filter(Rejim.finish == 0).order_by(Rejim.id.desc()).first().id
session.query(Rejim).filter(Rejim.id == up_id).update({Rejim.day: call.data}, synchronize_session=False)
else:
new_day = new_day + ' ' + call.data
up_id = session.query(Rejim).filter(Rejim.user_id == chat_id).filter(Rejim.finish == 0).order_by(Rejim.id.desc()).first().id
session.query(Rejim).filter(Rejim.id == up_id).update({Rejim.day: new_day}, synchronize_session=False)
session.commit()
session.close()
except Exception as e:
bot.send_message(config.admin_id, e)
elif call.data == "next":
session = Session()
days = session.query(Rejim).filter(Rejim.user_id == chat_id).filter(Rejim.finish == 0).order_by(Rejim.id.desc()).first()
day = days.day
need_day = day.split()
kunlar=""
for i in need_day:
if i == "Monday":
kunlar = kunlar+"Dushanba "
if i == "Tuesday":
kunlar = kunlar+"Seshanba "
if i == "Wednesday":
kunlar = kunlar+"Chorshanba "
if i == "Thursday":
kunlar = kunlar+"Payshanba "
if i == "Friday":
kunlar = kunlar+"Juma "
if i == "Saturday":
kunlar = kunlar+"Shanba "
if i == "Sunday":
kunlar = kunlar+"Yakshanba "
else:
kunlar = kunlar+""
keyboard_l = types.InlineKeyboardMarkup()
btn1 = types.InlineKeyboardButton("✅ Ha, vaqtni belgilash", callback_data="yes_time")
btn2 = types.InlineKeyboardButton("🙅♂️ Yo\'q, qayta tanlash", callback_data="back_day")
keyboard_l.add(btn1)
keyboard_l.add(btn2)
bot.send_message(chat_id, "
Do'stlaringiz bilan baham: |