bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
item1 = types.KeyboardButton('Заказать справку')
markup.add(item1)
bot.send_message(message.chat.id, 'Вас приветствует бот myboy', reply_markup=markup)
@bot.message_handler(content_types=['text'])
def bot_message(message):
if message.text == 'Заказать справку':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton('Справка#1')
item2 = types.KeyboardButton('Справка#2')
item3 = types.KeyboardButton('Справка#3')
back = types.KeyboardButton('Назад')
markup.add(item1, item2, item3, back)
bot.send_message(message.chat.id, 'Какая справка Вам нужна?', reply_markup=markup)
elif message.text == 'Справка#1':
bot.send_message(message.chat.id, 'Введите ИИН')
bot.register_next_step_handler(message, process_first_step)
elif message.text == 'Справка#2':
bot.send_message(message.chat.id, 'Введите ИИН')
bot.register_next_step_handler(message, process_second_step)
def process_first_step(message):
if len(message.text) == 12:
with con:
cur = con.cursor()
sql = "SELECT `fullname` FROM `bot_db` WHERE `iin`=%s and status=1 and user_type=1 limit 1 "
cur.execute(sql, (message.text,))
result = cur.fetchone()
rand = random.randint(30,60)
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
pdf.cell(40, 10, 'Hello World!')
pdf.output('{}.pdf'.format(rand), 'F')
r = open('C:\\Users\\Alkon PC\\PycharmProjects\\main_bot\\{}.pdf'.format(rand), 'rb')
bot.send_message(message.chat.id, 'Name: {}'.format(result))
bot.send_document(message.chat.id, r)
def process_second_step(message):
if len(message.text) == 12:
with con:
cur = con.cursor()
sql = "SELECT `fullname` FROM `bot_db` WHERE `iin`=%s and status=1 and user_type=1 limit 1 "
cur.execute(sql, (message.text,))
result = cur.fetchone()
rand = random.randint(30, 60)
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
pdf.cell(40, 10, 'Hello World!')
pdf.output('{}.pdf'.format(rand), 'F')
r = open('C:\\Users\\Alkon PC\\PycharmProjects\\main_bot\\{}.pdf'.format(rand), 'rb')
bot.send_message(message.chat.id, 'Name: {}'.format(result))
bot.send_document(message.chat.id, r)
bot.polling(none_stop=True)
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
item1 = types.KeyboardButton('Заказать справку')
markup.add(item1)
bot.send_message(message.chat.id, 'Вас приветствует бот myboy', reply_markup=markup)
@bot.message_handler(content_types=['text'])
def bot_message(message):
if message.text == 'Заказать справку':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton('Справка#1')
item2 = types.KeyboardButton('Справка#2')
item3 = types.KeyboardButton('Справка#3')
back = types.KeyboardButton('Назад')
markup.add(item1, item2, item3, back)
bot.send_message(message.chat.id, 'Какая справка Вам нужна?', reply_markup=markup)
elif message.text == 'Справка#1':
bot.send_message(message.chat.id, 'Введите ИИН')
bot.register_next_step_handler(message, process_first_step)
elif message.text == 'Справка#2':
bot.send_message(message.chat.id, 'Введите ИИН')
bot.register_next_step_handler(message, process_second_step)
def process_first_step(message):
bot.send_message(message.chat.id, 'First Process')
def process_second_step(message):
bot.send_message(message.chat.id, 'Second Process')
bot.polling(none_stop=True)