mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2025-04-12 23:29:37 +08:00
二次元、原神图片增加自动撤回
This commit is contained in:
parent
f3ab0d0c19
commit
398f3fe52b
@ -6,7 +6,7 @@ from nonebot.params import CommandArg, RegexGroup
|
|||||||
from nonebot.message import event_preprocessor
|
from nonebot.message import event_preprocessor
|
||||||
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, MessageEvent, MessageSegment, FriendRequestEvent, \
|
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, MessageEvent, MessageSegment, FriendRequestEvent, \
|
||||||
GroupRequestEvent
|
GroupRequestEvent
|
||||||
from ..utils.util import FreqLimiter
|
from ..utils.util import FreqLimiter, auto_withdraw
|
||||||
from ..utils.config import config
|
from ..utils.config import config
|
||||||
from asyncio import sleep
|
from asyncio import sleep
|
||||||
import random
|
import random
|
||||||
@ -62,7 +62,8 @@ async def cat_pic_handler(event: Union[GroupMessageEvent, MessageEvent]):
|
|||||||
|
|
||||||
|
|
||||||
@ecy_pic.handle()
|
@ecy_pic.handle()
|
||||||
async def ecy_pic_handler(event: Union[GroupMessageEvent, MessageEvent], regexGroup=RegexGroup()):
|
@auto_withdraw(15)
|
||||||
|
async def ecy_pic_handler(bot: Bot, event: Union[GroupMessageEvent, MessageEvent], regexGroup=RegexGroup()):
|
||||||
urls = [
|
urls = [
|
||||||
'https://www.dmoe.cc/random.php',
|
'https://www.dmoe.cc/random.php',
|
||||||
'https://acg.toubiec.cn/random.php',
|
'https://acg.toubiec.cn/random.php',
|
||||||
@ -89,10 +90,11 @@ async def ecy_pic_handler(event: Union[GroupMessageEvent, MessageEvent], regexGr
|
|||||||
elif url:
|
elif url:
|
||||||
await cat_pic.send('派蒙努力找图ing..请稍候...')
|
await cat_pic.send('派蒙努力找图ing..请稍候...')
|
||||||
ecy_lmt.start_cd(event.group_id or event.user_id, config.paimon_ecy_cd)
|
ecy_lmt.start_cd(event.group_id or event.user_id, config.paimon_ecy_cd)
|
||||||
await cat_pic.finish(MessageSegment.image(file=url))
|
return await cat_pic.send(MessageSegment.image(file=url))
|
||||||
|
|
||||||
|
|
||||||
@ys_pic.handle()
|
@ys_pic.handle()
|
||||||
|
@auto_withdraw(30)
|
||||||
async def ys_pic_handler(event: Union[GroupMessageEvent, MessageEvent]):
|
async def ys_pic_handler(event: Union[GroupMessageEvent, MessageEvent]):
|
||||||
urls = [
|
urls = [
|
||||||
'https://api.r10086.com/img-api.php?type=%E5%8E%9F%E7%A5%9E%E6%A8%AA%E5%B1%8F%E7%B3%BB%E5%88%971',
|
'https://api.r10086.com/img-api.php?type=%E5%8E%9F%E7%A5%9E%E6%A8%AA%E5%B1%8F%E7%B3%BB%E5%88%971',
|
||||||
|
@ -4,20 +4,34 @@ from typing import List
|
|||||||
|
|
||||||
|
|
||||||
class PluginConfig(BaseModel):
|
class PluginConfig(BaseModel):
|
||||||
|
# 群组模拟抽卡冷却(秒)
|
||||||
paimon_gacha_cd_group: int = 30
|
paimon_gacha_cd_group: int = 30
|
||||||
|
# 个人模拟抽卡冷却(秒)
|
||||||
paimon_gacha_cd_user: int = 60
|
paimon_gacha_cd_user: int = 60
|
||||||
|
# 树脂提醒停止检查时间(小时)
|
||||||
paimon_remind_start: int = 0
|
paimon_remind_start: int = 0
|
||||||
paimon_remind_end: int = 8
|
paimon_remind_end: int = 8
|
||||||
|
# 树脂提醒检查间隔(分钟)
|
||||||
paimon_check_interval: int = 16
|
paimon_check_interval: int = 16
|
||||||
|
# 树脂提醒每日提醒次数上限
|
||||||
paimon_remind_limit: int = 3
|
paimon_remind_limit: int = 3
|
||||||
|
# 自动签到开始时间(小时)
|
||||||
paimon_sign_hour: int = 0
|
paimon_sign_hour: int = 0
|
||||||
|
# 自动签到开始时间(分钟)
|
||||||
paimon_sign_minute: int = 0
|
paimon_sign_minute: int = 0
|
||||||
|
# 对联冷却(秒)
|
||||||
paimon_duilian_cd: int = 6
|
paimon_duilian_cd: int = 6
|
||||||
|
# 猫图冷却(秒)
|
||||||
paimon_cat_cd: int = 12
|
paimon_cat_cd: int = 12
|
||||||
|
# 二次元图冷却(秒)
|
||||||
paimon_ecy_cd: int = 6
|
paimon_ecy_cd: int = 6
|
||||||
|
# 原神壁纸图冷却(秒)
|
||||||
paimon_ysp_cd: int = 10
|
paimon_ysp_cd: int = 10
|
||||||
|
# 是否自动通过好友请求
|
||||||
paimon_add_friend: bool = False
|
paimon_add_friend: bool = False
|
||||||
|
# 是否自动通过群组请求
|
||||||
paimon_add_group: bool = False
|
paimon_add_group: bool = False
|
||||||
|
# 派蒙聊天开启群组
|
||||||
paimon_chat_group: List[int] = []
|
paimon_chat_group: List[int] = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import string
|
|||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
|
import asyncio
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
from nonebot import get_bot
|
from nonebot import get_bot
|
||||||
@ -23,6 +24,24 @@ from .db_util import get_cookie_cache, update_cookie_cache, delete_cookie_cache
|
|||||||
from .db_util import get_last_query, update_last_query
|
from .db_util import get_last_query, update_last_query
|
||||||
|
|
||||||
|
|
||||||
|
def auto_withdraw(seconds: int = -1):
|
||||||
|
def wrapper(func):
|
||||||
|
|
||||||
|
@functools.wraps(func)
|
||||||
|
async def wrapped(**kwargs):
|
||||||
|
try:
|
||||||
|
message_id = await func(**kwargs)
|
||||||
|
if message_id and seconds >= 1:
|
||||||
|
await asyncio.sleep(seconds)
|
||||||
|
await get_bot().delete_msg(message_id=message_id['message_id'])
|
||||||
|
except Exception as e:
|
||||||
|
raise e
|
||||||
|
|
||||||
|
return wrapped
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
# 缓存装饰器 ttl为过期时间 参数use_cache决定是否使用缓存,默认为True
|
# 缓存装饰器 ttl为过期时间 参数use_cache决定是否使用缓存,默认为True
|
||||||
def cache(ttl=datetime.timedelta(hours=1), **kwargs):
|
def cache(ttl=datetime.timedelta(hours=1), **kwargs):
|
||||||
def wrap(func):
|
def wrap(func):
|
||||||
@ -149,7 +168,7 @@ async def get_use_cookie(user_id, uid='', mys_id='', action=''):
|
|||||||
return cache_cookie
|
return cache_cookie
|
||||||
use_cookie = random.choice(cookies)
|
use_cookie = random.choice(cookies)
|
||||||
logger.info(f'---派蒙调用用户{use_cookie[0]}的uid{use_cookie[2]}私人cookie执行{action}操作---')
|
logger.info(f'---派蒙调用用户{use_cookie[0]}的uid{use_cookie[2]}私人cookie执行{action}操作---')
|
||||||
return {'type': 'private', 'user_id': use_cookie[0], 'cookie': use_cookie[1], 'uid': use_cookie[2],
|
return {'type': 'private', 'user_id': use_cookie[0], 'cookie': use_cookie[1], 'uid': use_cookie[2],
|
||||||
'mys_id': use_cookie[3]}
|
'mys_id': use_cookie[3]}
|
||||||
|
|
||||||
|
|
||||||
@ -258,14 +277,14 @@ def get_ds(q="", b=None) -> str:
|
|||||||
# 米游社爬虫headers
|
# 米游社爬虫headers
|
||||||
def get_headers(cookie, q='', b=None):
|
def get_headers(cookie, q='', b=None):
|
||||||
headers = {
|
headers = {
|
||||||
'DS': get_ds(q, b),
|
'DS': get_ds(q, b),
|
||||||
'Origin': 'https://webstatic.mihoyo.com',
|
'Origin': 'https://webstatic.mihoyo.com',
|
||||||
'Cookie': cookie,
|
'Cookie': cookie,
|
||||||
'x-rpc-app_version': "2.11.1",
|
'x-rpc-app_version': "2.11.1",
|
||||||
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS '
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS '
|
||||||
'X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1',
|
'X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1',
|
||||||
'x-rpc-client_type': '5',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/'
|
'Referer': 'https://webstatic.mihoyo.com/'
|
||||||
}
|
}
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
@ -280,17 +299,17 @@ def get_old_version_ds() -> str:
|
|||||||
|
|
||||||
def get_sign_headers(cookie):
|
def get_sign_headers(cookie):
|
||||||
headers = {
|
headers = {
|
||||||
'User_Agent': 'Mozilla/5.0 (Linux; Android 10; MIX 2 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 ('
|
'User_Agent': 'Mozilla/5.0 (Linux; Android 10; MIX 2 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 ('
|
||||||
'KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.101 Mobile Safari/537.36 '
|
'KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.101 Mobile Safari/537.36 '
|
||||||
'miHoYoBBS/2.3.0',
|
'miHoYoBBS/2.3.0',
|
||||||
'Cookie': cookie,
|
'Cookie': cookie,
|
||||||
'x-rpc-device_id': random_hex(32),
|
'x-rpc-device_id': random_hex(32),
|
||||||
'Origin': 'https://webstatic.mihoyo.com',
|
'Origin': 'https://webstatic.mihoyo.com',
|
||||||
'X_Requested_With': 'com.mihoyo.hyperion',
|
'X_Requested_With': 'com.mihoyo.hyperion',
|
||||||
'DS': get_old_version_ds(),
|
'DS': get_old_version_ds(),
|
||||||
'x-rpc-client_type': '5',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true&act_id'
|
'Referer': 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true&act_id'
|
||||||
'=e202009291139501&utm_source=bbs&utm_medium=mys&utm_campaign=icon',
|
'=e202009291139501&utm_source=bbs&utm_medium=mys&utm_campaign=icon',
|
||||||
'x-rpc-app_version': '2.3.0'
|
'x-rpc-app_version': '2.3.0'
|
||||||
}
|
}
|
||||||
return headers
|
return headers
|
||||||
@ -300,12 +319,12 @@ def get_sign_headers(cookie):
|
|||||||
async def check_cookie(cookie):
|
async def check_cookie(cookie):
|
||||||
url = 'https://bbs-api.mihoyo.com/user/wapi/getUserFullInfo?gids=2'
|
url = 'https://bbs-api.mihoyo.com/user/wapi/getUserFullInfo?gids=2'
|
||||||
headers = {
|
headers = {
|
||||||
'DS': get_ds(),
|
'DS': get_ds(),
|
||||||
'Origin': 'https://webstatic.mihoyo.com',
|
'Origin': 'https://webstatic.mihoyo.com',
|
||||||
'Cookie': cookie,
|
'Cookie': cookie,
|
||||||
'x-rpc-app_version': "2.11.1",
|
'x-rpc-app_version': "2.11.1",
|
||||||
'x-rpc-client_type': '5',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/'
|
'Referer': 'https://webstatic.mihoyo.com/'
|
||||||
}
|
}
|
||||||
async with ClientSession() as session:
|
async with ClientSession() as session:
|
||||||
res = await session.get(url=url, headers=headers)
|
res = await session.get(url=url, headers=headers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user