Skip to content

Commit

Permalink
添加关闭转发配置项#65
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdaYH committed Mar 12, 2024
1 parent fb0c246 commit f715660
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
| 漂流瓶字符换行比率 | nonebot_plugin_bottle_rt_rate | int | 0 |
| 漂流瓶被评论时将不提示 | nonebot_plugin_bottle_disable_comment_prompt | bool | False |
| 任何情况下都可以查看漂流瓶(若False,则仅有评论或主人可查看) | nonebot_plugin_bottle_everyone_can_read | bool | False |
| 关闭转发(若True,则所有转发消息都会逐条发出) | nonebot_plugin_bottle_disable_forward | bool | False |


## 更新日志
Expand Down
11 changes: 11 additions & 0 deletions nonebot_plugin_bottle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
rtrate,
disable_comment_prompt,
everyone_can_read,
disable_forward
)
from .data_source import (
ba,
Expand Down Expand Up @@ -135,6 +136,16 @@ async def verify(matcher: Matcher, event: GroupMessageEvent) -> None:


async def try_send_forward(event: MessageEvent, bot: Bot, messages: List[Any]):
if disable_forward:
if isinstance(event, GroupMessageEvent):
for message in messages:
await bot.send_group_msg(group_id=event.group_id, message=message)
await asyncio.sleep(0.2)
else:
for message in messages:
await bot.send_private_msg(group_id=event.user_id, message=message)
await asyncio.sleep(0.2)
return
new_messages = []
for message in messages:
if isinstance(message, str):
Expand Down
5 changes: 4 additions & 1 deletion nonebot_plugin_bottle/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Config(BaseModel, extra=Extra.ignore):
nonebot_plugin_bottle_disable_comment_prompt: bool = False
# 所有人都可查看漂流瓶
nonebot_plugin_bottle_everyone_can_read: bool = False
# 关闭转发发送(False为开启转发)
nonebot_plugin_bottle_disable_forward: bool = False


config = Config.parse_obj(get_driver().config.dict())
Expand All @@ -29,4 +31,5 @@ class Config(BaseModel, extra=Extra.ignore):
maxrt = config.nonebot_plugin_bottle_max_return
rtrate = config.nonebot_plugin_bottle_rt_rate
disable_comment_prompt = config.nonebot_plugin_bottle_disable_comment_prompt
everyone_can_read = config.nonebot_plugin_bottle_everyone_can_read
everyone_can_read = config.nonebot_plugin_bottle_everyone_can_read
disable_forward = config.nonebot_plugin_bottle_disable_forward
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot_plugin_bottle"
version = "2.0.0.8"
version = "2.0.0.9"
description = "Bottle post plugin in Nonebot"
authors = ["Todysheep <[email protected]>"]
license = "GNU GPLv3"
Expand Down

0 comments on commit f715660

Please sign in to comment.