amend report.py
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from telebot.types import LabeledPrice, Message, PreCheckoutQuery
|
||||
from ..config import YOOPAY, bot
|
||||
|
||||
prices = [LabeledPrice('Сумма', 100_00)]
|
||||
|
||||
|
||||
@bot.message_handler(commands=['donate'])
|
||||
def request_invoice(message: Message):
|
||||
bot.send_invoice(message.chat.id, 'Поддержать проект', 'Stan', 'donate_stan', provider_token=YOOPAY,
|
||||
currency='RUB', prices=prices,
|
||||
provider_data='{"capture": true}',
|
||||
max_tip_amount=500_000_00,
|
||||
suggested_tip_amounts=[150_00, 300_00, 500_00, 1_000_00], capture=True,
|
||||
)
|
||||
|
||||
|
||||
@bot.pre_checkout_query_handler(func=lambda a: True)
|
||||
def process_pre_checkout(q: PreCheckoutQuery):
|
||||
bot.answer_pre_checkout_query(q.id, True, 'Извините, пожертвования больше не принимаем!')
|
||||
+3
-1
@@ -6,12 +6,14 @@ 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')
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
logging.critical('STAN STARTED!')
|
||||
|
||||
logger.setLevel(logging.INFO)
|
||||
load_dotenv()
|
||||
|
||||
TOKEN = os.environ.get('LUTZPYBOT', 'Token not in ENVIRON')
|
||||
YOOPAY = os.environ.get('YOOKASSA')
|
||||
bot = TeleBot(TOKEN, 'HTML', disable_web_page_preview=True, allow_sending_without_reply=True,
|
||||
colorful_logs=True)
|
||||
|
||||
|
||||
+5
-5
@@ -4,13 +4,13 @@ from .config import DATA
|
||||
|
||||
|
||||
def create_report_text(chat_id):
|
||||
report = ''
|
||||
top_users = ''
|
||||
flooders = []
|
||||
if os.path.exists(f'{DATA}{chat_id}.db'):
|
||||
with shelve.open(f'{DATA}{chat_id}') as s:
|
||||
for n in range(min(3, len(s['Messages']))):
|
||||
top_user = s['Messages'][sorted(s['Messages'], key=lambda a: s['Messages'][a]['Count'], reverse=True)[n]]
|
||||
top_user = s['Messages'][
|
||||
sorted(s['Messages'], key=lambda a: s['Messages'][a]['Count'], reverse=True)[n]]
|
||||
if top_user['Count'] >= 10:
|
||||
flooders.append(top_user)
|
||||
|
||||
@@ -19,10 +19,10 @@ def create_report_text(chat_id):
|
||||
name = f"{user.first_name} {user.last_name}" if user.last_name else user.first_name
|
||||
top_users += f'\n {i + 1}. <a href="tg://user?id={user.id}">{name}</a> ({flooder["Count"]})'
|
||||
|
||||
if len(flooders) >= 3 or s['Banned'] or s['Deleted']:
|
||||
report = f"<code>Hello, World!</code> 🌍\n"
|
||||
if len(flooders) >= 3:
|
||||
report += f"<code>Hello, World!</code> 🌍"
|
||||
report += f"\n<b>Топ</b> 🗣{top_users}"
|
||||
|
||||
report += f"\n<b>Топ</b> 🗣{top_users}\n"
|
||||
if s['Banned'] or s['Deleted']:
|
||||
report += f"""
|
||||
<b>Заблокировано</b> ⛔
|
||||
|
||||
Reference in New Issue
Block a user