mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
✨ 增加随机字符串开关
This commit is contained in:
parent
2aff12e8d3
commit
d887489523
@ -1,3 +1,4 @@
|
|||||||
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import List, Union, Literal, Optional
|
from typing import List, Union, Literal, Optional
|
||||||
|
|
||||||
@ -8,6 +9,10 @@ from gsuid_core.logger import logger
|
|||||||
from gsuid_core.gs_logger import GsLogger
|
from gsuid_core.gs_logger import GsLogger
|
||||||
from gsuid_core.segment import MessageSegment
|
from gsuid_core.segment import MessageSegment
|
||||||
from gsuid_core.models import Event, Message, MessageSend
|
from gsuid_core.models import Event, Message, MessageSend
|
||||||
|
from gsuid_core.utils.plugins_config.gs_config import core_plugins_config
|
||||||
|
|
||||||
|
R_enabled = core_plugins_config.get_config('AutoAddRandomText').data
|
||||||
|
R_text = core_plugins_config.get_config('RandomText').data
|
||||||
|
|
||||||
|
|
||||||
class _Bot:
|
class _Bot:
|
||||||
@ -47,6 +52,13 @@ class _Bot:
|
|||||||
if at_sender and sender_id:
|
if at_sender and sender_id:
|
||||||
_message.append(MessageSegment.at(sender_id))
|
_message.append(MessageSegment.at(sender_id))
|
||||||
|
|
||||||
|
if R_enabled:
|
||||||
|
result = ''.join(
|
||||||
|
random.choice(R_text)
|
||||||
|
for _ in range(random.randint(1, len(R_text)))
|
||||||
|
)
|
||||||
|
_message.append(MessageSegment.text(result))
|
||||||
|
|
||||||
send = MessageSend(
|
send = MessageSend(
|
||||||
content=_message,
|
content=_message,
|
||||||
bot_id=bot_id,
|
bot_id=bot_id,
|
||||||
|
@ -49,4 +49,8 @@ CONIFG_DEFAULT: Dict[str, GSC] = {
|
|||||||
'AutoRestartCoreTime': GsListStrConfig(
|
'AutoRestartCoreTime': GsListStrConfig(
|
||||||
'自动重启Core时间设置', '每晚自动重启Core时间设置(时, 分)', ['4', '40']
|
'自动重启Core时间设置', '每晚自动重启Core时间设置(时, 分)', ['4', '40']
|
||||||
),
|
),
|
||||||
|
'AutoAddRandomText': GsBoolConfig('自动加入随机字符串', '自动加入随机字符串', False),
|
||||||
|
'RandomText': GsStrConfig(
|
||||||
|
'随机字符串列表', '随机字符串列表', 'abcdefghijklmnopqrstuvwxyz'
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user