From e035c8e93cc5893c25d5595eac37434e67447500 Mon Sep 17 00:00:00 2001 From: BadHappy <1196554262@qq.com> Date: Sat, 30 Dec 2023 09:39:00 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20module/hitokoto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/hitokoto/__init__.py | 53 ++++++++++++++++++++++++++++++++++-- module/hitokoto/test.py | Bin 1056 -> 1024 bytes 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/module/hitokoto/__init__.py b/module/hitokoto/__init__.py index cd88196..69316d5 100644 --- a/module/hitokoto/__init__.py +++ b/module/hitokoto/__init__.py @@ -1,5 +1,52 @@ import requests +import random + + +def hitokoto(ctypet): + try: + + if ctypet == '动画' or ctypet == 'a': + ctype = 'a' + elif ctypet == '漫画' or ctypet == 'b': + ctype = 'b' + elif ctypet == '游戏' or ctypet == 'c': + ctype = 'c' + elif ctypet == '文学' or ctypet == 'd': + ctype = 'd' + elif ctypet == '原创' or ctypet == 'e': + ctype = 'e' + elif ctypet == '网络' or ctypet == 'f': + ctype = 'f' + elif ctypet == '其他' or ctypet == 'g': + ctype = 'g' + elif ctypet == '影视' or ctypet == 'h': + ctype = 'h' + elif ctypet == '诗词' or ctypet == 'i': + ctype = 'i' + elif ctypet == '网易云' or ctypet == 'j': + ctype = 'j' + elif ctypet == '哲学' or ctypet == 'k': + ctype = 'k' + elif ctypet == '抖机灵' or ctypet == 'l': + ctype = 'l' + + elif ctypet == '没有': + ctype = random.choice('abcdefghijkl') + params_value = {'c': ctype} + hitokoto = requests.get('https://v1.hitokoto.cn', params=params_value) + + return 0, hitokoto.json() + else: + return 3, None + + params_value = {'c': ctype} + hitokoto = requests.get('https://v1.hitokoto.cn', params=params_value) + + return 0, hitokoto.json() + + except IOError: + return 2, None + + + -def hitokoto(): - hitokoto = requests.get('https://v1.hitokoto.cn') - print(hitokoto.json) \ No newline at end of file diff --git a/module/hitokoto/test.py b/module/hitokoto/test.py index fc4aa4806e81c1e149cdba276a26e8249915c308..06d7405020018ddf3cacee90fd4af10487da3d20 100644 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 1056 zcmZ|O!Aiq07zglspCY%kFgnHCpwA**o3?4Yrl#3I#DfQQ3{=Ks3J$!fAR-FN*xcK! z?H0Hy zEb5?YfD8lSbnuej&M{(qdurlVnf=R`VN^s-T+T@NU&wx50ig{E?H$5&n)PqwJ6Mol z?GVP7>D!Ym*pOhuLVEp}_8(+{KmvhfkFa>h2lG8_oL-(C?h_E_%M==K7k(^Ktccu*akI+F?ve@KiCpqkyVV4*uxOmHD yjZVvWUCg3Xb$@l22o-xm#7V2!?CtAyMz