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):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user