add start, nometa, neprivet
This commit is contained in:
@@ -21,3 +21,9 @@ Clone repository, edit code if needed and deploy on your sever.
|
|||||||
|
|
||||||
### Where can I get more help, if I need it?
|
### Where can I get more help, if I need it?
|
||||||
Bot is easily understandable reading in-code comments of the handler functions, also read [PyTelegramBotAPI documentation](url=https://github.com/eternnoir/pyTelegramBotAPI) for library help.
|
Bot is easily understandable reading in-code comments of the handler functions, also read [PyTelegramBotAPI documentation](url=https://github.com/eternnoir/pyTelegramBotAPI) for library help.
|
||||||
|
|
||||||
|
|
||||||
|
### How do I read logs of running Lutz bot daemon?
|
||||||
|
Continuous log reading on Linux:
|
||||||
|
|
||||||
|
```# journalctl --unit=lutz.service -f --no-pager```
|
||||||
+25
@@ -32,6 +32,15 @@ zen_rows = ['Beautiful is better than ugly.', 'Explicit is better than implicit.
|
|||||||
"Namespaces are one honking great idea — let's do more of those!"]
|
"Namespaces are one honking great idea — let's do more of those!"]
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['start'])
|
||||||
|
def start(message: types.Message):
|
||||||
|
""" Start """
|
||||||
|
log_msg = f'[START] {message.from_user.id} {message.from_user.first_name}'
|
||||||
|
if message.from_user.last_name:
|
||||||
|
log_msg += f' {message.from_user.first_name}'
|
||||||
|
logging.warning(log_msg)
|
||||||
|
|
||||||
|
|
||||||
def check_spam_list(type_message: types.Message) -> bool:
|
def check_spam_list(type_message: types.Message) -> bool:
|
||||||
""" Check for mentioning unwanted persons in text. """
|
""" Check for mentioning unwanted persons in text. """
|
||||||
if type_message.from_user.username not in WHITEUN and type_message.from_user.id not in WHITEIDS:
|
if type_message.from_user.username not in WHITEUN and type_message.from_user.id not in WHITEIDS:
|
||||||
@@ -247,6 +256,22 @@ def send_tsya_link(message: types.Message):
|
|||||||
bot.reply_to(message.reply_to_message, link, parse_mode='HTML', disable_web_page_preview=True)
|
bot.reply_to(message.reply_to_message, link, parse_mode='HTML', disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['nometa'])
|
||||||
|
def send_nometa(message: types.Message):
|
||||||
|
""" No meta """
|
||||||
|
answer = 'Пожалуйста, не задавайте <a href="https://nometa.xyz/ru.html">мета-вопросов</a> в чате!'
|
||||||
|
if message.reply_to_message:
|
||||||
|
bot.reply_to(message.reply_to_message, answer, parse_mode='HTML', disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['neprivet'])
|
||||||
|
def send_neprivet(message: types.Message):
|
||||||
|
""" Neprivet. """
|
||||||
|
answer = '<a href="https://neprivet.com/">Непривет</a>'
|
||||||
|
if message.reply_to_message:
|
||||||
|
bot.reply_to(message.reply_to_message, answer, parse_mode='HTML', disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['g'])
|
@bot.message_handler(commands=['g'])
|
||||||
def google_it(message: types.Message):
|
def google_it(message: types.Message):
|
||||||
""" Google it! """
|
""" Google it! """
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ PYTHONCHATRU = -1001338616632 # pythonchatru
|
|||||||
|
|
||||||
URL_RX = re.compile(r'\w+\.\w+/\w+')
|
URL_RX = re.compile(r'\w+\.\w+/\w+')
|
||||||
ALLOWED_WORDS = ['pastebin', 'github', 'google', 'nometa', 'python', 'django', 'flask', 'fastapi',
|
ALLOWED_WORDS = ['pastebin', 'github', 'google', 'nometa', 'python', 'django', 'flask', 'fastapi',
|
||||||
'stackoverflow', 'habr', 'medium', 'youtube', 'stepik', 'telegraph', '#rtfm']
|
'stackoverflow', 'habr', 'medium', 'youtu', 'stepik', 'telegraph', '#rtfm']
|
||||||
|
|
||||||
WHITEUN = set(os.environ.get('whitelist', '<<<ERR_USRS').split(','))
|
WHITEUN = set(os.environ.get('whitelist', '<<<ERR_USRS').split(','))
|
||||||
logging.warning(f'White users {WHITEUN}')
|
logging.warning(f'White users {WHITEUN}')
|
||||||
|
|||||||
Reference in New Issue
Block a user