add buttons
This commit is contained in:
+18
-6
@@ -71,26 +71,38 @@ def delete_message(message: types.Message):
|
||||
|
||||
@bot.message_handler(commands=['links'])
|
||||
def send_links(message):
|
||||
send_or_reply(message, f"{RULES}\n{FAQ}\n{LIB}")
|
||||
markup = types.InlineKeyboardMarkup()
|
||||
markup.add(RULES, FAQ, LIB, row_width=1)
|
||||
answer = "Почитай на досуге"
|
||||
if message.reply_to_message:
|
||||
bot.reply_to(message.reply_to_message, answer, reply_maarkup=markup)
|
||||
else:
|
||||
bot.send_message(message.chat.id, answer, reply_markup=markup)
|
||||
|
||||
|
||||
@bot.message_handler(commands=['rules', 'r'])
|
||||
@bot.message_handler(commands=['rules', 'rule', 'r'])
|
||||
def send_rules(message):
|
||||
markup = types.InlineKeyboardMarkup()
|
||||
markup.add(RULES, row_width=1)
|
||||
args = message.text.split()
|
||||
if len(args) > 1 and args[-1].isdigit():
|
||||
send_or_reply(message, rules.get_rule(args[-1]))
|
||||
send_or_reply(message, f'<b>Правило {args[-1]}</b>\n<i>{rules.get_rule(args[-1])}</i>', reply_markup=markup)
|
||||
else:
|
||||
send_or_reply(message, f'{RULES}')
|
||||
send_or_reply(message, 'Почитай', reply_markup=markup)
|
||||
|
||||
|
||||
@bot.message_handler(commands=['faq'])
|
||||
def send_faq(message):
|
||||
send_or_reply(message, f'{FAQ}')
|
||||
markup = types.InlineKeyboardMarkup()
|
||||
markup.add(FAQ, row_width=1)
|
||||
send_or_reply(message, 'Почитай', reply_markup=markup)
|
||||
|
||||
|
||||
@bot.message_handler(commands=['lib', 'library', 'books'])
|
||||
def send_lib(message):
|
||||
send_or_reply(message, f'{LIB}')
|
||||
markup = types.InlineKeyboardMarkup()
|
||||
markup.add(LIB, row_width=1)
|
||||
send_or_reply(message, 'Советую', reply_markup=markup)
|
||||
|
||||
|
||||
@bot.message_handler(commands=['lutz'])
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
import logging
|
||||
from telebot import TeleBot, logger
|
||||
from telebot import TeleBot, logger, types
|
||||
from dotenv import load_dotenv
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s', datefmt='%Y.%m.%d %H:%M:%S')
|
||||
@@ -31,9 +31,9 @@ ENG = """`qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&QWERTYUIOP{}|ASDFGHJKL:"ZXCVB
|
||||
RUS_ENG_TABLE = str.maketrans(RUS, ENG)
|
||||
ENG_RUS_TABLE = str.maketrans(ENG, RUS)
|
||||
|
||||
RULES = '🟡 <b><a href="https://telegra.ph/pythonchatru-07-07">Правила чата</a></b>'
|
||||
FAQ = '🔵 <b><a href="https://telegra.ph/faq-10-07-4">Частые вопросы</a></b>'
|
||||
LIB = '📚 <b><a href="https://telegra.ph/what-to-read-10-06">Библиотека питониста</a></b>'
|
||||
RULES = types.InlineKeyboardButton('🟡 Правила чата', url='https://telegra.ph/pythonchatru-07-07')
|
||||
FAQ = types.InlineKeyboardButton('🔵 Частые вопросы', url='https://telegra.ph/faq-10-07-4')
|
||||
LIB = types.InlineKeyboardButton('📚 Библиотека', url='https://telegra.ph/what-to-read-10-06')
|
||||
|
||||
SPAM = ['me.sv/', 'tg.sv/', 'goo.by/', 'go.sv/', 'intim.video/', 'uclck.ru/']
|
||||
NON_GRATA = ['дудар', 'хауди', 'dudar']
|
||||
|
||||
+3
-3
@@ -53,8 +53,8 @@ def is_white(message: types.Message) -> bool:
|
||||
return message.from_user.username in WHITEUN or message.from_user.id in WHITEIDS
|
||||
|
||||
|
||||
def send_or_reply(m: types.Message, answer):
|
||||
def send_or_reply(m: types.Message, answer, **kwargs):
|
||||
if m.reply_to_message:
|
||||
bot.reply_to(m.reply_to_message, answer)
|
||||
bot.reply_to(m.reply_to_message, answer, **kwargs)
|
||||
else:
|
||||
bot.send_message(m.chat.id, answer)
|
||||
bot.send_message(m.chat.id, answer, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user