for bad_word in bad_words:
if bad_word in message.text.lower():
@bot.message_handler(commands=['start'])
def start(message):
keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
keyboard.add(*[types.KeyboardButton(name) for name in ['111','222', '333','444', '555','666', '777']])
bot.send_message(message.chat.id, 'ляляля', reply_markup=keyboard)
@bot.message_handler(content_types=['text'])
def name(message):
if message.text == '111':
bot.send_message(message.chat.id, '123')
elif message.text = '222':
# blabla
self.from_user = False
self.from_chat = False
self.from_group = False
self.from_me = False
if call.data.startswith('buy_'):
subjects = {
'Русский язык': {'desc': 'Книга по русскому языку', 'shortname': 'rus'},
'Математика': {'desc': 'Книга по русскому языку', 'shortname': 'math'},
'Физика': {'desc': 'Книга по физике', 'shortname': 'physics'},
'Литература': {'desc': 'Книга по литературе', 'shortname': 'literature'}
}
@bot.message_handler(commands=['start'])
def send_start(message):
main_kb = InlineKeyboardMarkup(row_width=2)
buttons = []
for name, value in subjects.items():
buttons.append(InlineKeyboardButton(name, callback_data=value['shortname']))
main_kb.add(*buttons)
bot.send_message(message.chat.id, 'Список книг', reply_markup=main_kb)
@bot.callback_query_handler(func=lambda call: True)
def callback(call):
for name, value in subjects.items():
if value['shortname'] in call.data:
if call.data.startswith('buy_'):
bot.send_message(call.message.chat.id, 'Кнопка покупки {}'.format(name))
else:
buy_button = InlineKeyboardMarkup()
buy_button.add(InlineKeyboardButton('Купить книгу {}'.format(name), callback_data='buy_{}'.format(value['shortname'])))
bot.send_message(call.message.chat.id, value['desc'], reply_markup=buy_button)
cd "meandpython\python_work"
python hello_world.py