import re
dates = '''06-18, 18:00:
06-18, 21:00:
06-19, 00:00:
06-19, 03:00:
06-19, 06:00:
06-19, 09:00:
06-19, 12:00:
06-19, 15:00:
06-19, 18:00:
06-19, 21:00:
06-20, 00:00:
06-20, 03:00:
06-20, 06:00:
06-20, 09:00:
06-20, 12:00:
06-20, 15:00:
06-20, 18:00:
06-20, 21:00:'''
result = ''
last_day = None
for date in dates.split('\n'):
day = re.search(r'\d+-(\d+)', date).group(1)
if day != last_day:
result += '\n{}\n'.format(date)
last_day = day
else:
result += '{}\n'.format(date)
print(result)
import telebot
TOKEN = "ВАШ_ТОКЕН"
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands = ['start'])
def start_comm(message):
bot.send_message(message.chat.id, "Выбери команду (/start, /say_hi)")
@bot.message_handler(commands = ['say_hi'])
def say_hi_comm(message):
bot.send_message(message.chat.id, f"Привет, {message.from_user.first_name}!")
bot.polling(none_stop = True)
@bot.message_handler(content_types=['text'])
def check(message):
x = message.text
if x == "say_smth":
command = say_hi_comm(message)
else:
command = start_comm(message)
def check(message):
x = message.text
if x == "say_smth":
command = say_hi_comm(message)
else:
command = start_comm(message)
def check_start(message):
поставь декоратор @bot.message_handler(content_types=['text'])
@bot.message_handler(content_types=['sticker', 'photo', 'document'])
def other(message):
bot.send_message(message.from_user.id, 'Вводи текст')
qr = pyqrcode.create(x.encode('utf-8'))