menu.add(types.InlineKeyboardButton(text=f'{i[0]}', callback_data=f'{i[1]}'), types.InlineKeyboardButton(text=f'{i[0]}', callback_data=f'{i[1]}'))
menu.add(types.InlineKeyboardButton(text=i[0], callback_data=i[1]))
import telebot
print('******1')
from config import token
print('****2')
from telebot import types
bot = telebot.TeleBot(token)
@bot.message_handler(commands = ['start'])
def welcome(message):
bot.send_message(message.chat.id, 'Привет, {0.first_name}!\nЧтобы поискать статьи в техноблоге по моделям нажмите /tech'.format(message.from_user, bot.get_me()), parse_mode='html')
@bot.message_handler(commands = ['tech'])
def tech(gg):
kb = types.InlineKeyboardMarkup()
brand1 = types.InlineKeyboardButton(text='Kingsong', callback_data = 'kingsong')
brand2 = types.InlineKeyboardButton(text='Inmotion', callback_data = 'inmotion')
kb.add(brand1, brand2)
bot.send_message(gg.chat.id, "Choose a brand", reply_markup=kb)
@bot.callback_query_handler(func=lambda call: True)
def tech_ob(call):
if call.data == 'kingsong':
bot.send_message('KS')
elif call.data == 'inmotion':
bot.send_message('Im')
bot.polling(none_stop=True)
def change():
level1 = ""
level2 = ""
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(" ", " ")
save_changes = open(file_name1,'w')
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
level2 = level2.replace('#', '')
level2 = level2.replace(' ', ';')
continue
if level1 and level2:
line = line.replace(' ', ';')
print(f'{level1};{level2};{line}')
final_line = "{}{}{}{}".format(level1, level2, line, "\n")
if final_line.count(';') >= 6:
save_changes.write(final_line)
save_changes.close()
def change():
level1 = ""
level2 = ""
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(" ", " ")
save_changes = open(file_name1,'w')
for line in lines.split('\n'):
if line.count(';') < 6:
continue
result1 = re.match('^@\s+(\d+)\s+(.*)$', line)
if result1:
level1 = f'{result1.group(1)};{result1.group(2)}'
continue
if re.match('#', line):
level2 = line
level2 = level2.replace('#', '')
level2 = level2.replace(' ', ';')
continue
if level1 and level2:
line = line.replace(' ', ';')
print(f'{level1};{level2};{line}')
save_changes.write("{}{}{}{}".format(level1, level2, line, "\n"))
save_changes.close()