import telebot
from config import TOKEN
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def process_start(message):
keyboard = telebot.types.ReplyKeyboardMarkup(True)
keyboard.row('Выбери меня')
msg = bot.send_message(message.chat.id, text = 'Нажми кнопку в меню', reply_markup = keyboard )
@bot.message_handler(content_types = ['text'])
def step1(message):
menu1 = telebot.types.InlineKeyboardMarkup()
menu1.add(telebot.types.InlineKeyboardButton(text = 'Первая кнопка', callback_data ='first'))
menu1.add(telebot.types.InlineKeyboardButton(text = 'Вторая кнопка', callback_data ='second'))
if message.text == 'Выбери меня':
msg = bot.send_message(message.chat.id, text ='Нажми первую inline кнопку', reply_markup = menu1)
@bot.callback_query_handler(func=lambda call: True)
def step2(call):
menu2 = telebot.types.InlineKeyboardMarkup()
menu2.add(telebot.types.InlineKeyboardButton(text = 'Третья кнопка', callback_data ='third'))
menu2.add(telebot.types.InlineKeyboardButton(text = 'Четвертая кнопка', callback_data ='fourth'))
if call.data == 'first':
msg = bot.send_message(call.message.chat.id, 'Нажми третью кнопку', reply_markup = menu2)
elif call.data == 'third':
msg = bot.send_message(call.message.chat.id, 'Конец')
# читаем исходник
text = open('file1.txt', 'r').read()
# изменяем
text += 'test'
# записываем во второй
f = open('file2.txt', 'w')
f.write(text)
f.close()
def change():
file_name = fd.askopenfilename()
file_name1 = 'второй файл'
f = open(file_name,'r')
lines = f.read()
lines = lines.replace('Путей в парке', '')
lines = lines.replace(';--------------', '')
while " " in lines:
lines = lines.replace(" ", " ")
level1 = None
level2 = None
for line in lines.split('\n'):
result1 = re.match('^@\s+(\d+)\s+(.*)$', line)
if result1:
level1 = f'{result1.group(1)};{result1.group(2)}'
continue
if re.match('#', line):
level2 = line
continue
if level1 and level2:
if level1 and level2 and line:
line = line.replace(' ', '; ')
print(f'{level1};{level2}{line}')
f.close()
save_changes = open(file_name1, 'w')
save_changes.writelines(lines)
save_changes.close()
import re
pattern = re.compile('[^#][<>\n](\d\d\d\d\d\d)[<>\n]')
pattern.findall('<div style="font-family: arial,helvetica,sans-serif; mso-line-height-rule: exactly; color: #313131; text-align: center; font-size: 40px; letter-spacing: 15px; line-height: 100px">366634</div>')
['366634']