From 58824697ac347c8383b42c7eada452e22f0747a1 Mon Sep 17 00:00:00 2001 From: Rykov7 Date: Mon, 2 Jan 2023 23:02:10 +0300 Subject: [PATCH] fix README.md, is_white filter --- README.md | 2 +- app/bot.py | 2 +- app/filters.py | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d33725e..2e83d8b 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ ExecStart=/bin/bash -c 'source /home/inferno/lutzpybot/venv/bin/activate; gunico [Install] WantedBy=multi-user.target ``` -2. Enable and start with `systemctl enable lutz.service`, `systemctl enable lutz.service`. +2. Enable and start with `systemctl enable lutz.service`, `systemctl start lutz.service`. ### Where can I get more help, if I need it? Bot is easily understandable reading in-code comments of the handler functions, additionally read [PyTelegramBotAPI documentation](url=https://github.com/eternnoir/pyTelegramBotAPI) for library help. diff --git a/app/bot.py b/app/bot.py index 0b777f8..40c51ce 100644 --- a/app/bot.py +++ b/app/bot.py @@ -263,7 +263,7 @@ def list_jobs(message): bot.send_message(ADMIN_ID, reminder.print_get_jobs()) -@bot.message_handler(func=is_admin, commands=['add']) +@bot.message_handler(func=is_white, commands=['add']) def add_stan_quote(message): if message.reply_to_message and message.reply_to_message.text: with open('Stan.txt', 'a', encoding='utf8') as stan_quotes: diff --git a/app/filters.py b/app/filters.py index b43f2fe..5069f36 100644 --- a/app/filters.py +++ b/app/filters.py @@ -2,11 +2,11 @@ from telebot import types from .config import * -def check_spam_list(type_message: types.Message) -> bool: +def check_spam_list(message: types.Message) -> bool: """ 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 message.from_user.username not in WHITEUN and message.from_user.id not in WHITEIDS: for url in SPAM: - if url in type_message.text.casefold(): + if url in message.text.casefold(): return True @@ -49,6 +49,10 @@ def is_admin(message: types.Message) -> bool: return message.from_user.id == ADMIN_ID +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): if m.reply_to_message: bot.reply_to(m.reply_to_message, answer)