diff options
author | Lint Action <[email protected]> | 2021-07-08 14:09:51 +0000 |
---|---|---|
committer | Lint Action <[email protected]> | 2021-07-08 14:09:51 +0000 |
commit | 951dcdf4ec224b31433c5ab5c170b76fd3087910 (patch) | |
tree | fe0ee2b5c219bd8f9796917ac3ee6286d4181146 /ATRI/plugins/funny/data_source.py | |
parent | be2747e4d4b820ca0f1f988d3b77a628da26fe7b (diff) | |
download | ATRI-951dcdf4ec224b31433c5ab5c170b76fd3087910.tar.gz ATRI-951dcdf4ec224b31433c5ab5c170b76fd3087910.tar.bz2 ATRI-951dcdf4ec224b31433c5ab5c170b76fd3087910.zip |
:rotating_light: 自动进行代码格式化
Diffstat (limited to 'ATRI/plugins/funny/data_source.py')
-rw-r--r-- | ATRI/plugins/funny/data_source.py | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/ATRI/plugins/funny/data_source.py b/ATRI/plugins/funny/data_source.py index a27cdb5..f298683 100644 --- a/ATRI/plugins/funny/data_source.py +++ b/ATRI/plugins/funny/data_source.py @@ -17,35 +17,34 @@ __doc__ = """ class Funny(Service): - def __init__(self): Service.__init__(self, "乐", __doc__, rule=is_in_service("乐")) - + @staticmethod def idk_laugh(name: str) -> str: laugh_list = list() - + file_path = Path(".") / "ATRI" / "data" / "database" / "funny" / "laugh.txt" with open(file_path, encoding="utf-8") as r: for line in r: laugh_list.append(line.strip("\n")) - + rd: str = choice(laugh_list) result = rd.replace("%name", name) return result - + @staticmethod def me_re_you(msg: str) -> tuple: if "我" in msg and "[CQ" not in msg: return msg.replace("我", "你"), True else: return msg, False - + @staticmethod def fake_msg(text: str) -> list: arg = text.split(" ") node = list() - + for i in arg: args = i.split("-") qq = args[0] @@ -54,7 +53,7 @@ class Funny(Service): dic = {"type": "node", "data": {"name": name, "uin": qq, "content": repo}} node.append(dic) return node - + @staticmethod async def eat_what(name: str, msg: str) -> str: EAT_URL = "https://wtf.hiigara.net/api/run/" @@ -63,7 +62,7 @@ class Funny(Service): pattern_1 = r"(今|明|后|大后)天" arg = re.findall(pattern_0, msg)[0] day = re.match(pattern_1, msg).group(0) # type: ignore - + if arg == "中午": a = f"LdS4K6/{randint(0, 1145141919810)}" url = EAT_URL + a @@ -72,11 +71,11 @@ class Funny(Service): data = await data.json() except RequestError: raise RequestError("Request failed!") - + text = Translate(data["text"]).to_simple().replace("今天", day) get_a = re.search(r"非常(.*?)的", text).group(0) # type: ignore result = text.replace(get_a, "") - + elif arg == "晚上": a = f"KaTMS/{randint(0, 1145141919810)}" url = EAT_URL + a @@ -85,17 +84,13 @@ class Funny(Service): data = await data.json() except RequestError: raise RequestError("Request failed!") - + result = Translate(data["text"]).to_simple().replace("今天", day) - + else: rd = randint(1, 10) if rd == 5: - result = [ - "吃我吧 ❤", - "(脸红)请...请享用咱吧......", - "都可以哦~不能挑食呢~" - ] + result = ["吃我吧 ❤", "(脸红)请...请享用咱吧......", "都可以哦~不能挑食呢~"] return choice(result) else: a = f"JJr1hJ/{randint(0, 1145141919810)}" @@ -105,9 +100,9 @@ class Funny(Service): data = await data.json() except RequestError: raise RequestError("Request failed!") - + text = Translate(data["text"]).to_simple().replace("今天", day) get_a = re.match(r"(.*?)的智商", text).group(0) # type: ignore result = text.replace(get_a, f"{name}的智商") - - return result
\ No newline at end of file + + return result |