spam process API

This commit is contained in:
BennyThink
2021-12-16 20:04:37 +08:00
parent 2ba6db2564
commit f177eefc23
6 changed files with 110 additions and 9 deletions

View File

@@ -26,7 +26,8 @@ FIX_SEARCH = "http://www.zimuxia.cn/?s={kw}"
ZHUIXINFAN_SEARCH = "http://www.fanxinzhui.com/list?k={}"
ZHUIXINFAN_RESOURCE = "http://www.fanxinzhui.com{}"
# yyets website
WORKERS = "https://yyets.dmesg.app/resource.html?id={id}"
DOMAIN = "https://yyets.dmesg.app/"
WORKERS = f"{DOMAIN}resource.html?id={id}"
# new zmz
NEWZMZ_SEARCH = "https://newzmz.com/subres/index/getres.html?keyword={}"

View File

@@ -18,11 +18,11 @@ import pymongo
import redis
import requests
from bs4 import BeautifulSoup
from bson.objectid import ObjectId
from config import (BD2020_SEARCH, FANSUB_ORDER, FIX_SEARCH, MONGO,
NEWZMZ_RESOURCE, NEWZMZ_SEARCH, REDIS, WORKERS,
XL720_SEARCH, ZHUIXINFAN_RESOURCE, ZHUIXINFAN_SEARCH)
from bson.objectid import ObjectId
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(filename)s [%(levelname)s]: %(message)s')

View File

@@ -12,13 +12,14 @@ import tempfile
import time
from urllib.parse import quote_plus
import requests
import telebot
from apscheduler.schedulers.background import BackgroundScheduler
from telebot import apihelper, types
from tgbot_ping import get_runtime
import fansub
from config import (FANSUB_ORDER, MAINTAINER, PROXY, REPORT, TOKEN,
from config import (DOMAIN, FANSUB_ORDER, MAINTAINER, PROXY, REPORT, TOKEN,
YYETS_SEARCH_URL)
from utils import (get_error_dump, redis_announcement, reset_request,
save_error_dump, show_usage, today_request)
@@ -283,6 +284,29 @@ def choose_link(call):
bot.send_document(call.message.chat.id, f, caption=caption)
@bot.callback_query_handler(func=lambda call: re.findall(r"approve", call.data))
def approve_spam(call):
obj_id = re.findall(r"approve(\S*)", call.data)[0]
data = {
"obj_id": obj_id,
"token": TOKEN
}
requests.post(f"{DOMAIN}api/admin/spam", json=data)
bot.send_chat_action(call.message.chat.id, 'typing')
bot.answer_callback_query(call.id, 'Approved')
@bot.callback_query_handler(func=lambda call: re.findall(r"deny", call.data))
def deny_spam(call):
obj_id = re.findall(r"deny(\S*)", call.data)[0]
data = {
"obj_id": obj_id,
"token": TOKEN
}
requests.delete(f"{DOMAIN}api/admin/spam", json=data)
bot.answer_callback_query(call.id, 'Denied')
@bot.callback_query_handler(func=lambda call: re.findall(r"unwelcome(\d*)", call.data))
def send_unwelcome(call):
# this will come from me only