diff options
author | Kyomotoi <[email protected]> | 2021-02-20 08:19:41 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2021-02-20 08:19:41 +0800 |
commit | ae7ea2d379ec7fb0edb8e333145bb141106a2fd2 (patch) | |
tree | 3243cb1dd668d36f92f17e958ff2a38e7b2c450c /ATRI/plugins/utils/data_source.py | |
parent | 3d16960b487f8911fb3817c2abcdb252ad848f58 (diff) | |
download | ATRI-ae7ea2d379ec7fb0edb8e333145bb141106a2fd2.tar.gz ATRI-ae7ea2d379ec7fb0edb8e333145bb141106a2fd2.tar.bz2 ATRI-ae7ea2d379ec7fb0edb8e333145bb141106a2fd2.zip |
✨ 更新插件,埋下bug
- 更新插件:
- call-owner
- code-runner
- status
- anime-search
- tex(待修复)
- 埋下bug:
- service中limit作为机器人服务中的开关,目前写入文件亟待修复
Diffstat (limited to 'ATRI/plugins/utils/data_source.py')
-rw-r--r-- | ATRI/plugins/utils/data_source.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/ATRI/plugins/utils/data_source.py b/ATRI/plugins/utils/data_source.py index b83cd33..f41a1d1 100644 --- a/ATRI/plugins/utils/data_source.py +++ b/ATRI/plugins/utils/data_source.py @@ -1,3 +1,34 @@ -from nonebot.adapters.cqhttp.message import MessageSegment +import re +import random -MessageSegment.
\ No newline at end of file + +def roll_dice(par: str) -> str: + result = 0 + proc = '' + proc_list = [] + p = par.split("+") + + for i in p: + args = re.findall(r"(\d{0,10})(?:(d)(\d{1,10}))", i) + args = list(args[0]) + + args[0] = args[0] or 1 + if int(args[0]) >= 5000 or int(args[2]) >= 5000: + return "阿...好大......" + + for a in range(1, int(args[0]) + 1): + rd = random.randint(1, int(args[2])) + result = result + rd + + if len(proc_list) <= 10: + proc_list.append(rd) + + if len(proc_list) <= 10: + proc += "+".join(map(str, proc_list)) + elif len(proc_list) > 10: + proc += "太长了不展示了就酱w" + else: + proc += str(result) + + result = f"{par}=({proc})={result}" + return result |