Skip to content

Commit

Permalink
v0.1.0a2🔨
Browse files Browse the repository at this point in the history
  • Loading branch information
KafCoppelia committed Jun 6, 2022
1 parent c8dba58 commit eea42cc
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 161 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _🤐 禁言十连 🤐_
<img src="https://img.shields.io/badge/nonebot2-2.0.0beta.2+-green">
</a>

<a href="https://github.com/MinatoAquaCrews/nonebot_plugin_mute10rolls/releases/tag/v0.1.0">
<a href="https://github.com/MinatoAquaCrews/nonebot_plugin_mute10rolls/releases/tag/v0.1.0a2">
<img src="https://img.shields.io/github/v/release/MinatoAquaCrews/nonebot_plugin_mute10rolls?color=orange">
</a>

Expand All @@ -28,11 +28,11 @@ _🤐 禁言十连 🤐_

## 版本

v0.1.0a1
v0.1.0a2

⚠ 适配nonebot2-2.0.0beta.2+

[更新日志](https://github.com/MinatoAquaCrews/nonebot_plugin_mute10rolls/releases/tag/v0.1.0)
[更新日志](https://github.com/MinatoAquaCrews/nonebot_plugin_mute10rolls/releases/tag/v0.1.0a2)

## 安装

Expand Down Expand Up @@ -61,16 +61,18 @@ v0.1.0a1

⚠ 注意:开启禁言十连功能使用正式版cd,BOT须有管理员权限才可禁言,否则仅抽奖。即使狗管理关闭禁言十连功能,依然能抽奖,此时使用体验版cd,且无论BOT有无管理员权限,均不可禁言

- [ ] TODO 禁言排行榜
- [x] 统计本日群禁言数据,每周自动发布上周群禁言数据

## 命令

1. 十连抽取口球套餐:[禁言十连];

2. [管理员权限] 开启/关闭禁言十连:[开启|启用|关闭|禁用]禁言十连;
2. 查看本日群禁言数据统计:[禁言统计];

3. [管理员权限] 开启/关闭禁言十连:[开启|启用|关闭|禁用]禁言十连;

⚠ 注意:初始状态下,群禁言十连功能默认关闭。

3. [管理员权限] 修改禁言冷却:[修改禁言cd/冷却][seconds],例如:修改禁言cd 60
4. [管理员权限] 修改禁言冷却:[修改禁言cd/冷却][seconds],例如:修改禁言cd 60

⚠ 注意:冷却时间10~120,默认体验版cd比正式版cd较长。建议管理员合理设置防止刷屏与抖M群友
46 changes: 33 additions & 13 deletions nonebot_plugin_mute10rolls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from nonebot.typing import T_State
from nonebot.matcher import Matcher
from nonebot.log import logger
from nonebot import require
from nonebot.adapters.onebot.v11.exception import ActionFailed
from nonebot.adapters.onebot.v11 import GROUP, GROUP_ADMIN, GROUP_OWNER, Message, GroupMessageEvent
from nonebot.params import Depends, CommandArg, State
from .utils import *
from .data_source import *

__mute_rolls_vsrsion__ = "v0.1.0"
__mute_rolls_vsrsion__ = "v0.1.0a2"
__mute_rolls_notes__ = f'''
禁言十连 {__mute_rolls_vsrsion__}
十连抽取口球套餐
Expand All @@ -16,20 +17,23 @@
'''.strip()

mute_rolls = on_command(cmd="禁言十连", permission=GROUP, priority=12)
rank = on_command(cmd="禁言统计", permission=GROUP, priority=12)
roll_on = on_command(cmd="启用禁言十连", aliases={"开启禁言十连"}, permission=GROUP_ADMIN | GROUP_OWNER, priority=12, block=True)
roll_off = on_command(cmd="禁用禁言十连", aliases={"关闭禁言十连"}, permission=GROUP_ADMIN | GROUP_OWNER, priority=12, block=True)
cd_change = on_command(cmd="修改禁言cd", aliases={"修改禁言冷却"}, permission=GROUP_ADMIN | GROUP_OWNER, priority=12, block=True)

scheduler = require("nonebot_plugin_apscheduler").scheduler

@roll_on.handle()
async def _(event: GroupMessageEvent):
gid = str(event.group_id)
switch_enable(gid, True)
m10r_manager.switch_enable(gid, True)
await roll_on.finish("已启用禁言十连功能")

@roll_off.handle()
async def _(event: GroupMessageEvent):
gid = str(event.group_id)
switch_enable(gid, False)
m10r_manager.switch_enable(gid, False)
await roll_off.finish("已禁用禁言十连功能")

async def get_new_cd(args: Message = CommandArg(), state: T_State = State()):
Expand All @@ -51,34 +55,34 @@ async def get_new_cd(args: Message = CommandArg(), state: T_State = State()):
async def _(event: GroupMessageEvent, state: T_State = Depends(get_new_cd)):
gid = str(event.group_id)
cd = state["cd"]
change_cd(gid, cd)
m10r_manager.change_cd(gid, cd)

if check_enable(gid):
if m10r_manager.check_enable(gid):
await cd_change.finish(f"已修改冷却时间为 {cd}s")
else:
await cd_change.finish(f"已修改冷却时间为 {cd}s")

@mute_rolls.handle()
async def _(matcher: Matcher, event: GroupMessageEvent, args: Message = CommandArg()):
args = args.extract_plain_text().strip().split()
args = args.extract_plain_text().strip()
if args == "帮助":
await matcher.finish(__mute_rolls_notes__)

gid = str(event.group_id)

cd = check_cd(gid)
if not check_enable(gid):
cd = m10r_manager.check_cd(gid)
if not m10r_manager.check_enable(gid):
# Trial version
if cd > 0:
await matcher.finish(f"技能冷却中,剩余 {cd}s\n需管理员权限可启用该功能\n通过[修改禁言cd :seconds]可修改禁言冷却时间")
await matcher.finish(f"技能冷却中,剩余 {cd}s\n需管理员启用该功能\n通过[修改禁言cd :seconds]可修改禁言冷却时间")
else:
mute_time, msg = await one_go(event)
mute_time, msg = await m10r_manager.one_go(event)
await matcher.finish(msg)
else:
if cd > 0:
await matcher.finish(f"技能冷却中,剩余 {cd}s\n需管理员通过[修改禁言cd :seconds]可修改禁言冷却时间")
else:
mute_time, msg = await one_go(event)
mute_time, msg = await m10r_manager.one_go(event)
await matcher.send(msg)
if mute_time > 0:
is_botadmin = await is_BotAdmin(event.group_id)
Expand All @@ -95,4 +99,20 @@ async def _(matcher: Matcher, event: GroupMessageEvent, args: Message = CommandA
except ActionFailed:
await matcher.finish("出错啦,这次让你跑掉了~")
else:
logger.info(f"User {event.user_id} | Group {event.group_id} 禁言十连中奖 {mute_time} seconds")
logger.info(f"User {event.user_id} | Group {event.group_id} 禁言十连中奖 {mute_time} seconds")

@rank.handle()
async def _(event: GroupMessageEvent):
gid = str(event.group_id)
msg = await m10r_manager.day_rank(gid)
await rank.finish(msg)

# 上周排行榜总结
@scheduler.scheduled_job("cron", day_of_week=0, hour=0, minute=0)
async def _():
await m10r_manager.last_week_rank()

# 重置每日记录,且周一时重置每周记录
@scheduler.scheduled_job("cron", hour=0, minute=1)
async def _():
m10r_manager.reset_record()
Loading

0 comments on commit eea42cc

Please sign in to comment.