Add modular Roblox buyer bot and documentation
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import logging
|
||||
|
||||
from aiogram.enums import ParseMode
|
||||
from aiogram.types import CallbackQuery, FSInputFile
|
||||
|
||||
|
||||
async def log_admin(bot, admin_id: int, text: str, log_bot=None) -> None:
|
||||
try:
|
||||
target = log_bot or bot
|
||||
await target.send_message(admin_id, text, parse_mode=ParseMode.HTML)
|
||||
except Exception as exc:
|
||||
logging.error("log_admin: %s", exc)
|
||||
|
||||
|
||||
async def log_admin_document(bot, admin_id: int, path: str, caption: str | None = None, log_bot=None) -> None:
|
||||
try:
|
||||
target = log_bot or bot
|
||||
await target.send_document(
|
||||
admin_id,
|
||||
document=FSInputFile(path),
|
||||
caption=caption,
|
||||
parse_mode=ParseMode.HTML,
|
||||
)
|
||||
except Exception as exc:
|
||||
logging.error("log_admin_document: %s", exc)
|
||||
|
||||
|
||||
async def safe_edit(
|
||||
cb: CallbackQuery,
|
||||
text: str,
|
||||
reply_markup=None,
|
||||
parse_mode=ParseMode.HTML,
|
||||
disable_web_page_preview: bool = False,
|
||||
) -> None:
|
||||
try:
|
||||
await cb.message.edit_text(
|
||||
text,
|
||||
reply_markup=reply_markup,
|
||||
parse_mode=parse_mode,
|
||||
disable_web_page_preview=disable_web_page_preview,
|
||||
)
|
||||
except Exception:
|
||||
try:
|
||||
await cb.message.answer(
|
||||
text,
|
||||
reply_markup=reply_markup,
|
||||
parse_mode=parse_mode,
|
||||
disable_web_page_preview=disable_web_page_preview,
|
||||
)
|
||||
except Exception as exc:
|
||||
logging.error("safe_edit fail: %s", exc)
|
||||
@@ -0,0 +1,17 @@
|
||||
def parse_cookies_text(text: str) -> tuple[list[str], int]:
|
||||
valid = set()
|
||||
duplicates = 0
|
||||
for line in text.replace("\r", "").split("\n"):
|
||||
line = line.strip()
|
||||
if "_|WARNING:-DO-NOT-SHARE-THIS." not in line:
|
||||
continue
|
||||
try:
|
||||
cookie = line.split("_|WARNING:-DO-NOT-SHARE-THIS.")[1].split()[0]
|
||||
full = f"_|WARNING:-DO-NOT-SHARE-THIS.{cookie}"
|
||||
if full in valid:
|
||||
duplicates += 1
|
||||
else:
|
||||
valid.add(full)
|
||||
except Exception:
|
||||
pass
|
||||
return list(valid), duplicates
|
||||
Reference in New Issue
Block a user