diff options
author | Kyomotoi <1172294279@qq.com> | 2021-04-11 15:03:35 +0800 |
---|---|---|
committer | Kyomotoi <1172294279@qq.com> | 2021-04-11 15:03:35 +0800 |
commit | cbf4900c5c3b1de65e55ce480d4b453091528e84 (patch) | |
tree | 6bde5ad2d8f6f4010cb317b2b72be36f17b503d4 /ATRI/plugins/utils | |
parent | 212424da74fecbd77c9824e422ea8b028b330c9e (diff) | |
download | ATRI-cbf4900c5c3b1de65e55ce480d4b453091528e84.tar.gz ATRI-cbf4900c5c3b1de65e55ce480d4b453091528e84.tar.bz2 ATRI-cbf4900c5c3b1de65e55ce480d4b453091528e84.zip |
🚀✨⚡️🎨🐛 正式推送
Diffstat (limited to 'ATRI/plugins/utils')
-rw-r--r-- | ATRI/plugins/utils/__init__.py | 17 | ||||
-rw-r--r-- | ATRI/plugins/utils/data_source.py | 19 |
2 files changed, 16 insertions, 20 deletions
diff --git a/ATRI/plugins/utils/__init__.py b/ATRI/plugins/utils/__init__.py index b23a01f..af6d4e0 100644 --- a/ATRI/plugins/utils/__init__.py +++ b/ATRI/plugins/utils/__init__.py @@ -2,11 +2,7 @@ import re from nonebot.adapters.cqhttp import Bot, MessageEvent from ATRI.service import Service as sv -from ATRI.rule import ( - is_block, - is_in_dormant, - is_in_service -) +from ATRI.rule import is_in_service from .data_source import roll_dice, Encrypt @@ -22,10 +18,9 @@ roll一下 """ roll = sv.on_command( - cmd="/roll", + cmd="roll", docs=__doc__, - rule=is_block() & is_in_dormant() - & is_in_service('/roll') + rule=is_in_service('roll') ) @roll.handle() @@ -46,7 +41,7 @@ async def _(bot: Bot, event: MessageEvent, state: dict) -> None: __doc__ = """ -加密你的信息! +加密传输(bushi 权限组:所有人 用法: /enc e,d msg @@ -58,9 +53,9 @@ __doc__ = """ """ encrypt = sv.on_command( - cmd="/enc", + cmd="enc", docs=__doc__, - rule=is_block() & is_in_service('/enc') & is_in_dormant() + rule=is_in_service('enc') ) @encrypt.handle() diff --git a/ATRI/plugins/utils/data_source.py b/ATRI/plugins/utils/data_source.py index 71da581..18c0492 100644 --- a/ATRI/plugins/utils/data_source.py +++ b/ATRI/plugins/utils/data_source.py @@ -55,7 +55,7 @@ class Encrypt(): def _encodeByte(self, i) -> Union[str, None]: if i > 0xFF: - raise ValueError('ERROR! rc/nb overflow') + raise ValueError('ERROR! at/ri overflow') if i > 0x7F: i = i & 0x7F @@ -65,7 +65,7 @@ class Encrypt(): def _encodeShort(self, i) -> str: if i > 0xFFFF: - raise ValueError('ERROR! rcnb overflow') + raise ValueError('ERROR! atri overflow') reverse = False if i > 0x7FFF: @@ -93,11 +93,12 @@ class Encrypt(): if idx[0] < 0 or idx[1] < 0: idx = [self.cn.index(c[0]), self.cb.index(c[1])] nb = True - raise ValueError('ERROR! rc/nb overflow') + raise ValueError('ERROR! at/ri overflow') - result = idx[0] * self.sb + idx[1] if nb else idx[0] * self.sc + idx[1] + result = idx[0] * self.sb + idx[1] \ + if nb else idx[0] * self.sc + idx[1] if result > 0x7F: - raise ValueError('ERROR! rc/nb overflow') + raise ValueError('ERROR! at/ri overflow') return result | 0x80 if nb else 0 @@ -119,12 +120,12 @@ class Encrypt(): ] if idx[0] < 0 or idx[1] < 0 or idx[2] < 0 or idx[3] < 0: - raise ValueError('ERROR! not rcnb') + raise ValueError('ERROR! not atri') result = idx[0] * self.scnb + idx[1] * self.snb + idx[ 2] * self.sb + idx[3] if result > 0x7FFF: - raise ValueError('ERROR! rcnb overflow') + raise ValueError('ERROR! atri overflow') result |= 0x8000 if reverse else 0 return result @@ -155,8 +156,8 @@ class Encrypt(): result = [] for i in range(0, (len(s) >> 2)): result.append(bytes([self._decodeShort(s[i * 4:i * 4 + 4]) >> 8])) - result.append(bytes([self._decodeShort(s[i * 4:i * 4 + 4]) & 0xFF - ])) + result.append(bytes([ + self._decodeShort(s[i * 4:i * 4 + 4]) & 0xFF])) if (len(s) & 2) == 2: result.append(bytes([self._decodeByte(s[-2:])])) |