From b6ee52b1e53cd44f43b588a59d590bb7cf02b6d5 Mon Sep 17 00:00:00 2001
From: Kyomotoi <1172294279@qq.com>
Date: Sat, 6 Jun 2020 17:37:17 +0800
Subject: some changes for weather
---
 .idea/Aya.iml                                      |  11 ++
 .idea/misc.xml                                     |   7 +
 .idea/modules.xml                                  |   8 +
 .idea/vcs.xml                                      |   6 +
 .idea/workspace.xml                                | 209 +++++++++++++++++++++
 AyaBot/plugins/Module/google_translate/__init__.py | 144 ++++++++++++++
 .../__pycache__/__init__.cpython-37.pyc            | Bin 0 -> 3205 bytes
 AyaBot/plugins/__pycache__/awsl.cpython-37.pyc     | Bin 2482 -> 0 bytes
 AyaBot/plugins/__pycache__/bilibili.cpython-37.pyc | Bin 1114 -> 0 bytes
 .../plugins/__pycache__/bilibilifan.cpython-37.pyc | Bin 1083 -> 0 bytes
 .../plugins/__pycache__/broadcast.cpython-37.pyc   | Bin 2238 -> 0 bytes
 AyaBot/plugins/__pycache__/bug.cpython-37.pyc      | Bin 1044 -> 0 bytes
 AyaBot/plugins/__pycache__/covid19.cpython-37.pyc  | Bin 3945 -> 2265 bytes
 AyaBot/plugins/__pycache__/math.cpython-37.pyc     | Bin 121 -> 0 bytes
 AyaBot/plugins/__pycache__/r6.cpython-37.pyc       | Bin 1364 -> 0 bytes
 .../plugins/__pycache__/translate.cpython-37.pyc   | Bin 4537 -> 1769 bytes
 AyaBot/plugins/__pycache__/weather.cpython-37.pyc  | Bin 1299 -> 4221 bytes
 AyaBot/plugins/__pycache__/yiqing.cpython-37.pyc   | Bin 6561 -> 0 bytes
 AyaBot/plugins/covid19.py                          | 120 +++---------
 AyaBot/plugins/translate.py                        | 150 +--------------
 AyaBot/plugins/weather.py                          | 163 ++++++++++++----
 __pycache__/config.cpython-37.pyc                  | Bin 311 -> 0 bytes
 run.py                                             |   3 +-
 23 files changed, 549 insertions(+), 272 deletions(-)
 create mode 100644 .idea/Aya.iml
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/modules.xml
 create mode 100644 .idea/vcs.xml
 create mode 100644 .idea/workspace.xml
 create mode 100644 AyaBot/plugins/Module/google_translate/__init__.py
 create mode 100644 AyaBot/plugins/Module/google_translate/__pycache__/__init__.cpython-37.pyc
 delete mode 100644 AyaBot/plugins/__pycache__/awsl.cpython-37.pyc
 delete mode 100644 AyaBot/plugins/__pycache__/bilibili.cpython-37.pyc
 delete mode 100644 AyaBot/plugins/__pycache__/bilibilifan.cpython-37.pyc
 delete mode 100644 AyaBot/plugins/__pycache__/broadcast.cpython-37.pyc
 delete mode 100644 AyaBot/plugins/__pycache__/bug.cpython-37.pyc
 delete mode 100644 AyaBot/plugins/__pycache__/math.cpython-37.pyc
 delete mode 100644 AyaBot/plugins/__pycache__/r6.cpython-37.pyc
 delete mode 100644 AyaBot/plugins/__pycache__/yiqing.cpython-37.pyc
 delete mode 100644 __pycache__/config.cpython-37.pyc
diff --git a/.idea/Aya.iml b/.idea/Aya.iml
new file mode 100644
index 0000000..6711606
--- /dev/null
+++ b/.idea/Aya.iml
@@ -0,0 +1,11 @@
+
+
+  
+    
+    
+    
+  
+  
+    
+  
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..8656114
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+  
+    
+  
+  
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..eca873e
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+  
+    
+      
+    
+  
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+  
+    
+  
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..eccc8d0
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,209 @@
+
+
+  
+    
+      
+      
+      
+      
+      
+      
+      
+      
+      
+    
+    
+    
+    
+    
+    
+  
+  
+    
+      
+        
+          
+            
+              
+              
+                
+              
+            
+          
+        
+      
+      
+        
+          
+            
+              
+              
+                
+              
+            
+          
+        
+      
+    
+  
+  
+    
+  
+  
+    
+  
+  
+    
+      
+        
+        
+        
+      
+    
+  
+  
+    
+    
+    
+    
+  
+  
+    
+      
+    
+    
+      
+      
+        
+          
+            
+               
+               
+            
+            
+               
+               
+               
+            
+            
+               
+               
+               
+               
+            
+          
+          
+        
+      
+    
+  
+  
+    
+    
+    
+    
+    
+  
+  
+    
+      
+        
+          
+        
+        
+          
+        
+      
+    
+  
+  
+    
+  
+  
+    
+      
+      1591429432399
+      
+      
+      1591429432399
+      
+      
+    
+    
+  
+  
+    
+  
+  
+    
+    
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+    
+  
+  
+    
+  
+  
+    
+      
+        
+          
+          
+            
+          
+        
+      
+    
+    
+      
+        
+          
+        
+      
+    
+    
+      
+        
+          
+          
+            
+          
+        
+      
+    
+    
+      
+        
+          
+          
+            
+          
+        
+      
+    
+  
+
\ No newline at end of file
diff --git a/AyaBot/plugins/Module/google_translate/__init__.py b/AyaBot/plugins/Module/google_translate/__init__.py
new file mode 100644
index 0000000..fbb732d
--- /dev/null
+++ b/AyaBot/plugins/Module/google_translate/__init__.py
@@ -0,0 +1,144 @@
+import re
+import requests
+import demjson
+from pprint import pformat, pprint
+from urllib.parse import urlencode
+
+
+def int_overflow(val):
+    maxint = 2147483647
+    if not -maxint - 1 <= val <= maxint:
+        val = (val + (maxint + 1)) % (2 * (maxint + 1)) - maxint - 1
+    return val
+
+
+def ansii(a):
+    return a.encode('gbk')
+
+
+def kr(a: int, b):
+    c = 0
+    b = ansii(b)
+    while c < len(b) - 2:
+        d = b[c + 2]
+        d = d - 87 if ansii("a")[0] <= d else int(chr(d))
+        d = a >> d if ansii("+")[0] == b[c + 1] else a << d
+        d = int_overflow(d)
+        a = a + d & 4294967295 if ansii("+")[0] == b[c] else a ^ d
+        c += 3
+    return int_overflow(a)
+
+
+def mr(q, TKK):
+    e = q.encode()
+    d = str(TKK).split('.')
+    a = int(d[0])
+    b = int(d[0])
+
+    for f in e:
+        a += f
+        a = kr(a, "+-a^+6")
+    a = kr(a, "+-3^+b+-f")
+    a &= 0xffffffff  # 出错了,转回无符号
+    a ^= (int(d[1]) or 0)
+    if 0 > a:
+        a = (a & 2147483647) + 2147483648
+    a %= 1E6
+    a = int(a)
+
+    # c = '&tk='
+    # return c + (str(a) + "." + str(a ^ b))
+    return (str(a) + "." + str(a ^ b))
+
+
+"""
+def Sr(a, TKK):
+    a = ''.join(a['a']['b']['q'])
+    return mr(a, TKK)
+d = {
+    'a':{
+        'a': ['q'],
+        'b': {
+            'q': ['me']
+        },
+        'c': 1,
+        'g': 1
+    },
+    'b': 1,
+    'c': None,
+    'j': False,
+}
+TKK = '426151.3141811846'
+tk = Sr(d, TKK)
+print(tk)
+"""
+
+session = requests.session()
+
+
+def translate(q='hello', source='en', to='zh-CN', tkk=None):
+    """
+    限制最大5000,按utf-8算,一个汉字算1个,1个英文算一个,超过会失败
+    """
+    if not tkk:
+        tkk = '426151.3141811846'
+    tk = mr(q, tkk)
+    params = {
+        'client': 't',
+        'sl': source,
+        'tl': to,
+        'hl': source,
+        'dt': [
+            'at', 'qca', 'rw', 'rm', 'ss', 't'
+        ],
+        'tk': tk,
+        'ie': 'UTF-8',
+        'oe': 'UTF-8',
+        'pc': 1,
+        'kc': 1,
+        'ssel': 0,
+        'otf': 1
+    }
+    data = {
+        'q': q
+    }
+    headers = {
+        'Referer': 'https://translate.google.cn/',
+        'Host': 'translate.google.cn',
+    }
+    resp = requests.post('https://translate.google.cn/translate_a/single', params=params, data=data, headers=headers)
+    if resp.status_code == 200:
+        resp.encoding = 'utf-8'
+        data = resp.json()
+
+        result = []
+        result.append(''.join(map(lambda x: x[0], data[0][:-1])))
+        result.append(data[0][-1][-1])
+        return result
+    else:
+        return None
+
+
+def ref_words(q='hello', source='en', to='zh-CN'):
+    params = {
+        'q': q,
+        'client': 'translate-web',
+        'ds': 'translate',
+        'hl': source,
+        'requiredfields': f'tl:{to}',
+        'callback': 'window.google.ref_words'
+    }
+    url = 'https://clients1.google.com/complete/search?'
+    headers = {
+        'Referer': 'https://translate.google.cn/',
+        'Host': 'clients1.google.cn',
+    }
+    resp = session.get(url, params=params, headers=headers)
+    if resp.status_code == 200:
+        resp.encoding = 'utf-8'
+        result = re.search(r'window.google.ref_words\((.*)\)', resp.text).group(1)
+        json_data = demjson.decode(result)
+        data_list = list(map(lambda x: x[0], json_data[1]))
+        return data_list
+    else:
+        return None
\ No newline at end of file
diff --git a/AyaBot/plugins/Module/google_translate/__pycache__/__init__.cpython-37.pyc b/AyaBot/plugins/Module/google_translate/__pycache__/__init__.cpython-37.pyc
new file mode 100644
index 0000000..2e141ef
Binary files /dev/null and b/AyaBot/plugins/Module/google_translate/__pycache__/__init__.cpython-37.pyc differ
diff --git a/AyaBot/plugins/__pycache__/awsl.cpython-37.pyc b/AyaBot/plugins/__pycache__/awsl.cpython-37.pyc
deleted file mode 100644
index 6c47288..0000000
Binary files a/AyaBot/plugins/__pycache__/awsl.cpython-37.pyc and /dev/null differ
diff --git a/AyaBot/plugins/__pycache__/bilibili.cpython-37.pyc b/AyaBot/plugins/__pycache__/bilibili.cpython-37.pyc
deleted file mode 100644
index 59bdbf0..0000000
Binary files a/AyaBot/plugins/__pycache__/bilibili.cpython-37.pyc and /dev/null differ
diff --git a/AyaBot/plugins/__pycache__/bilibilifan.cpython-37.pyc b/AyaBot/plugins/__pycache__/bilibilifan.cpython-37.pyc
deleted file mode 100644
index e6f89bd..0000000
Binary files a/AyaBot/plugins/__pycache__/bilibilifan.cpython-37.pyc and /dev/null differ
diff --git a/AyaBot/plugins/__pycache__/broadcast.cpython-37.pyc b/AyaBot/plugins/__pycache__/broadcast.cpython-37.pyc
deleted file mode 100644
index ed83918..0000000
Binary files a/AyaBot/plugins/__pycache__/broadcast.cpython-37.pyc and /dev/null differ
diff --git a/AyaBot/plugins/__pycache__/bug.cpython-37.pyc b/AyaBot/plugins/__pycache__/bug.cpython-37.pyc
deleted file mode 100644
index 17caf47..0000000
Binary files a/AyaBot/plugins/__pycache__/bug.cpython-37.pyc and /dev/null differ
diff --git a/AyaBot/plugins/__pycache__/covid19.cpython-37.pyc b/AyaBot/plugins/__pycache__/covid19.cpython-37.pyc
index edecda4..be04c61 100644
Binary files a/AyaBot/plugins/__pycache__/covid19.cpython-37.pyc and b/AyaBot/plugins/__pycache__/covid19.cpython-37.pyc differ
diff --git a/AyaBot/plugins/__pycache__/math.cpython-37.pyc b/AyaBot/plugins/__pycache__/math.cpython-37.pyc
deleted file mode 100644
index b29588f..0000000
Binary files a/AyaBot/plugins/__pycache__/math.cpython-37.pyc and /dev/null differ
diff --git a/AyaBot/plugins/__pycache__/r6.cpython-37.pyc b/AyaBot/plugins/__pycache__/r6.cpython-37.pyc
deleted file mode 100644
index f10eb1b..0000000
Binary files a/AyaBot/plugins/__pycache__/r6.cpython-37.pyc and /dev/null differ
diff --git a/AyaBot/plugins/__pycache__/translate.cpython-37.pyc b/AyaBot/plugins/__pycache__/translate.cpython-37.pyc
index 40e59c6..6346914 100644
Binary files a/AyaBot/plugins/__pycache__/translate.cpython-37.pyc and b/AyaBot/plugins/__pycache__/translate.cpython-37.pyc differ
diff --git a/AyaBot/plugins/__pycache__/weather.cpython-37.pyc b/AyaBot/plugins/__pycache__/weather.cpython-37.pyc
index db86c0c..733d83e 100644
Binary files a/AyaBot/plugins/__pycache__/weather.cpython-37.pyc and b/AyaBot/plugins/__pycache__/weather.cpython-37.pyc differ
diff --git a/AyaBot/plugins/__pycache__/yiqing.cpython-37.pyc b/AyaBot/plugins/__pycache__/yiqing.cpython-37.pyc
deleted file mode 100644
index db96f6f..0000000
Binary files a/AyaBot/plugins/__pycache__/yiqing.cpython-37.pyc and /dev/null differ
diff --git a/AyaBot/plugins/covid19.py b/AyaBot/plugins/covid19.py
index 1dbed70..ea9a341 100644
--- a/AyaBot/plugins/covid19.py
+++ b/AyaBot/plugins/covid19.py
@@ -1,10 +1,13 @@
 import re
 import json
+import sys
+sys.path.append('D:\code\Aya\AyaBot\plugins\Module')
 import demjson
 import requests
 from pprint import pformat, pprint
 from urllib.parse import urlencode
 from nonebot import on_command, CommandSession
+import google_translate
 
 
 # 国外版 数据更新非常及时
@@ -27,104 +30,23 @@ LIST = """截至: {lastChecked}
 最后检查时间: {lastReported}"""
 
 
-def int_overflow(val):
-    maxint = 2147483647
-    if not -maxint-1 <= val <= maxint: 
-        val = (val + (maxint + 1)) % (2 * (maxint + 1)) - maxint - 1 
-    return val
-
-def ansii(a):
-    return a.encode('gbk')
-
-
-def kr(a:int, b):
-    c = 0
-    b = ansii(b)
-    while c < len(b)-2:
-        d = b[c + 2]
-        d = d - 87 if ansii("a")[0] <= d else int(chr(d))
-        d = a >> d if ansii("+")[0] == b[c + 1] else a << d
-        d = int_overflow(d)
-        a = a + d & 4294967295 if ansii("+")[0] == b[c] else a ^ d
-        c += 3
-    return int_overflow(a)
-
-
-def mr(q, TKK):
-    e = q.encode()
-    d = str(TKK).split('.')
-    a = int(d[0])
-    b = int(d[0])
-
-    for f in e:
-        a += f
-        a = kr(a, "+-a^+6")
-    a = kr(a, "+-3^+b+-f")
-    a &= 0xffffffff # 出错了,转回无符号
-    a ^= (int(d[1]) or 0)
-    if 0 > a:
-        a = (a & 2147483647) + 2147483648
-    a %= 1E6
-    a = int(a)
-
-    # c = '&tk='
-    # return c + (str(a) + "." + str(a ^ b))
-    return (str(a) + "." + str(a ^ b))
-
-
-def translate(q='hello', source='en', to='zh-CN', tkk=None):
-    """
-    限制最大5000,按utf-8算,一个汉字算1个,1个英文算一个,超过会失败
-    """
-    if not tkk:
-        tkk = '426151.3141811846'
-    tk = mr(q, tkk)
-    params = {
-        'client': 't',
-        'sl': source,
-        'tl': to,
-        'hl': source,
-        'dt': [
-            'at', 'qca', 'rw', 'rm', 'ss', 't'
-            ],
-        'tk': tk,
-        'ie': 'UTF-8',
-        'oe': 'UTF-8',
-        'pc': 1,
-        'kc': 1,
-        'ssel': 0,
-        'otf': 1
-    }
-    data = {
-        'q': q
-    }
-    headers = {
-        'Referer': 'https://translate.google.cn/',
-        'Host': 'translate.google.cn',
-    }
-    resp = requests.post('https://translate.google.cn/translate_a/single', params=params, data=data, headers=headers)
-    if resp.status_code == 200:
-        resp.encoding = 'utf-8'
-        data = resp.json()
-        
-        result = []
-        result.append(''.join(map(lambda x:x[0], data[0][:-1])))
-        result.append(data[0][-1][-1])
-        return result
-    else:
-        return None
-
-
 @on_command('covid19', aliases=['疫情', '疫情查询', '疫情情况'], only_to_me=False)
 async def covid19(session: CommandSession):
-    country = session.get('country', prompt='请用Eng键入需要查询的国家(例:China)')
-    re_msg = translate(country[:4999], to='en', source='zh-CN')
+    country = session.get('country', prompt='请键入需要查询的国家(例:中国)')
+    if country == '美国':
+        pass
+    else:
+        re_msg = google_translate.translate(country[:4999], to='en', source='zh-CN')
     # if re_msg[0]!='':
     #     await session.send(re_msg[0])
-    await session.send('开始搜寻...\n如返回国名为Global的则为提供的国家名有问题,必须为英文全称')
+    await session.send('开始搜寻...\n如返回Global则为国家名有问题')
     try:
         querystring = {"country":"cy"}
-        querystring["country"] = re_msg[0]
+        if country == '美国':
+            re_msg = 'US'
+            querystring["country"] = re_msg
+        else:
+            querystring["country"] = re_msg[0]
         print(querystring)
         headers = {
             'x-rapidapi-host': "covid-19-coronavirus-statistics.p.rapidapi.com",
@@ -145,4 +67,16 @@ async def covid19(session: CommandSession):
             )
         )
     except:
-        await session.send('搜索出问题了呢,重新试试?')
\ No newline at end of file
+        await session.send('搜索出问题了呢,重新试试?')
+
+@covid19.args_parser
+async def _(session: CommandSession):
+    stripped_arg = session.current_arg_text.strip()
+    if session.is_first_run:
+        if stripped_arg:
+            session.state['country'] = stripped_arg
+        return
+
+    if not stripped_arg:
+        session.pause('要查询的国家不能为空,请重新输入')
+    session.state[session.current_key] = stripped_arg
diff --git a/AyaBot/plugins/translate.py b/AyaBot/plugins/translate.py
index b49aedd..6422380 100644
--- a/AyaBot/plugins/translate.py
+++ b/AyaBot/plugins/translate.py
@@ -1,155 +1,21 @@
 import re
-import requests
+import sys
+sys.path.append('D:\code\Aya\AyaBot\plugins\Module')
 import demjson
+import requests
 from pprint import pformat, pprint
 from urllib.parse import urlencode
 from nonebot import on_command, CommandSession
+import google_translate
 
 #FROM Joenothing-lst
 
 
-def int_overflow(val):
-    maxint = 2147483647
-    if not -maxint-1 <= val <= maxint: 
-        val = (val + (maxint + 1)) % (2 * (maxint + 1)) - maxint - 1 
-    return val
-
-def ansii(a):
-    return a.encode('gbk')
-
-def kr(a:int, b):
-    c = 0
-    b = ansii(b)
-    while c < len(b)-2:
-        d = b[c + 2]
-        d = d - 87 if ansii("a")[0] <= d else int(chr(d))
-        d = a >> d if ansii("+")[0] == b[c + 1] else a << d
-        d = int_overflow(d)
-        a = a + d & 4294967295 if ansii("+")[0] == b[c] else a ^ d
-        c += 3
-    return int_overflow(a)
-
-def mr(q, TKK):
-    e = q.encode()
-    d = str(TKK).split('.')
-    a = int(d[0])
-    b = int(d[0])
-
-    for f in e:
-        a += f
-        a = kr(a, "+-a^+6")
-    a = kr(a, "+-3^+b+-f")
-    a &= 0xffffffff # 出错了,转回无符号
-    a ^= (int(d[1]) or 0)
-    if 0 > a:
-        a = (a & 2147483647) + 2147483648
-    a %= 1E6
-    a = int(a)
-
-    # c = '&tk='
-    # return c + (str(a) + "." + str(a ^ b))
-    return (str(a) + "." + str(a ^ b))
-
-
-"""
-def Sr(a, TKK):
-    a = ''.join(a['a']['b']['q'])
-    return mr(a, TKK)
-d = {
-    'a':{
-        'a': ['q'],
-        'b': {
-            'q': ['me']
-        },
-        'c': 1,
-        'g': 1
-    },
-    'b': 1,
-    'c': None,
-    'j': False,
-}
-TKK = '426151.3141811846'
-tk = Sr(d, TKK)
-print(tk)
-"""
-
-
-session = requests.session()
-
-
-def translate(q='hello', source='en', to='zh-CN', tkk=None):
-    """
-    限制最大5000,按utf-8算,一个汉字算1个,1个英文算一个,超过会失败
-    """
-    if not tkk:
-        tkk = '426151.3141811846'
-    tk = mr(q, tkk)
-    params = {
-        'client': 't',
-        'sl': source,
-        'tl': to,
-        'hl': source,
-        'dt': [
-            'at', 'qca', 'rw', 'rm', 'ss', 't'
-            ],
-        'tk': tk,
-        'ie': 'UTF-8',
-        'oe': 'UTF-8',
-        'pc': 1,
-        'kc': 1,
-        'ssel': 0,
-        'otf': 1
-    }
-    data = {
-        'q': q
-    }
-    headers = {
-        'Referer': 'https://translate.google.cn/',
-        'Host': 'translate.google.cn',
-    }
-    resp = requests.post('https://translate.google.cn/translate_a/single', params=params, data=data, headers=headers)
-    if resp.status_code == 200:
-        resp.encoding = 'utf-8'
-        data = resp.json()
-        
-        result = []
-        result.append(''.join(map(lambda x:x[0], data[0][:-1])))
-        result.append(data[0][-1][-1])
-        return result
-    else:
-        return None
-
-
-def ref_words(q='hello', source='en', to='zh-CN'):
-    params = {
-        'q': q,
-        'client': 'translate-web',
-        'ds': 'translate',
-        'hl': source,
-        'requiredfields': f'tl:{to}',
-        'callback':'window.google.ref_words'
-    }
-    url = 'https://clients1.google.com/complete/search?'
-    headers = {
-        'Referer': 'https://translate.google.cn/',
-        'Host': 'clients1.google.cn',
-    }
-    resp = session.get(url, params=params, headers=headers)
-    if resp.status_code == 200:
-        resp.encoding = 'utf-8'
-        result = re.search(r'window.google.ref_words\((.*)\)', resp.text).group(1)
-        json_data = demjson.decode(result)
-        data_list = list(map(lambda x:x[0], json_data[1]))
-        return data_list
-    else:
-        return None
-
-
 @on_command('ja_to_zh', aliases=('日语翻译',), only_to_me=False)                 
 async def _(session: CommandSession):
     if ' ' in session.ctx['raw_message']: 
         msg=session.ctx['raw_message'][5:]
-        re_msg = translate(msg[:4999], to='zh-CN', source='ja')
+        re_msg = google_translate.translate(msg[:4999], to='zh-CN', source='ja')
         if re_msg[0]!='' and re_msg[0]!=msg:
             await session.send(re_msg[0])
 
@@ -157,7 +23,7 @@ async def _(session: CommandSession):
 async def _(session: CommandSession):
     if ' ' in session.ctx['raw_message']: 
         msg=session.ctx['raw_message'][5:]
-        re_msg = translate(msg[:4999], to='zh-CN', source='en')
+        re_msg = google_translate.translate(msg[:4999], to='zh-CN', source='en')
         if re_msg[0]!='':
             await session.send(re_msg[0])
 
@@ -165,7 +31,7 @@ async def _(session: CommandSession):
 async def _(session: CommandSession):
     if ' ' in session.ctx['raw_message']: 
         msg=session.ctx['raw_message'][5:]
-        re_msg = translate(msg[:4999], to='ja', source='zh-CN')
+        re_msg = google_translate.translate(msg[:4999], to='ja', source='zh-CN')
         if re_msg[0]!='':
             await session.send(re_msg[0])
 
@@ -173,6 +39,6 @@ async def _(session: CommandSession):
 async def _(session: CommandSession):
     if ' ' in session.ctx['raw_message']: 
         msg=session.ctx['raw_message'][5:]
-        re_msg = translate(msg[:4999], to='en', source='zh-CN')
+        re_msg = google_translate.translate(msg[:4999], to='en', source='zh-CN')
         if re_msg[0]!='':
             await session.send(re_msg[0])
\ No newline at end of file
diff --git a/AyaBot/plugins/weather.py b/AyaBot/plugins/weather.py
index f6a78fe..d439eeb 100644
--- a/AyaBot/plugins/weather.py
+++ b/AyaBot/plugins/weather.py
@@ -1,46 +1,139 @@
+import os
+import re
+import sys
+sys.path.append('D:\code\Aya\AyaBot\plugins\Module')
 import json
 import requests
 from nonebot import on_command, CommandSession
+import google_translate
 
+API_URL = 'https://api.weatherbit.io/v2.0/current?city={city}'
+API_URL_2 = ',CN&key=1df2eb2951f3470a94cb323bb4647c18'
 
-API_URL = 'https://www.tianqiapi.com/free/day?appid=36628957&appsecret=WKn4dtVg&city='
 
+LIST = """{city} 情况如下:
+截至: {ob_time}
+天气: {description}
+温度: {temp}
+风速: {wind_spd}
+风向: {wind_cdir}
+云覆盖率(%): {clouds}"""
 
-LIST = """{city} 今日信息如下:
-更新时间:{time}
-天气情况:{wea}
-空气质量:{air}
-温度:
-    现在温度:{tem}
-    最高温度:{temday}
-    最低温度:{temnight}
-风向:{win}
-风力等级:{winspeed}
-风速:{winmeter}"""
+LIST_ALL = """{city} 详细情况如下:
+纬度(°): {lat}
+经度(°): {lon}
+日出时间(HH:MM): {sunrise}
+日落时间(HH:MM): {sunset}
+本地时区: {timezone}
+源站ID: {station}
+上次观察时间(YYYY-MM-DD HH:MM): {ob_time}
+当前周期小时(YYYY-MM-DD HH:MM): {datetime}
+压力(mb): {pres}
+海平面压力(mb): {slp}
+风速(m/s): {wind_spd}
+风向(°): {wind_dir}
+缩写风向: {wind_cdir}
+风向全称: {wind_cdir_full}
+温度(℃): {temp}
+感觉温度(℃): {app_temp}
+相对湿度(%): {rh}
+露点(℃): {dewpt}
+云覆盖率(%): {clouds}
+一天的一部分(d/n): {pod}
+现在天气: {description}
+可见度(km): {vis}
+液体当量沉淀速率(mm/hr): {precip}
+降雪(mm/h): {snow}
+紫外线指数(0-11+): {uv}
+空气质量指数[美国-EPA标准0-+500] [Clear Sky]: {aqi}
+漫射水平太阳辐照度(W/m^2) [Clear Sky]: {dhi}
+普通太阳直射辐射(W/m^2) [Clear Sky]: {dni}
+全球水平太阳辐照度(W/m^2): {ghi}
+估计的太阳辐射(W/m^2): {solar_rad}
+太阳斜角(°): {elev_angle}
+太阳时角(°): {h_angle}"""
 
 
-@on_command('weather', aliases=['天气', '查天气', '天气查询'], only_to_me=False)
+@on_command('weather', aliases=['查天气', '天气', '天气情况'], only_to_me=False)
 async def weather(session: CommandSession):
-    city = session.get('city', prompt='你想查哪个城市呢?')
-    try:
-        res = API_URL + city
-        res1 = requests.get(res)
-        res1.encoding = 'utf-8'
-        html = res1.text
-        wt = json.loads(html)
-        await session.send(LIST.format(
-            city=wt["city"],
-            time=wt["update_time"],
-            wea=wt["wea"],
-            tem=wt["tem"],
-            temday=wt["tem_day"],
-            temnight=wt["tem_night"],
-            win=wt["win"],
-            winspeed=wt["win_speed"],
-            winmeter=wt["win_meter"],
-            air=wt["air"]
-            )
+    city = session.get('city', prompt='请键入你需要查询的城市(例:北京)')
+    re_msg = google_translate.translate(city[:4999], to='en', source='zh-CN')
+    URL = API_URL + re_msg[0] + API_URL_2
+    # print(URL)
+    res = requests.get(URL)
+    res.encoding = 'utf-8'
+    html = res.text
+    wt = json.loads(html)
+    await session.send(LIST.format(
+        city=wt["data"][0]["city_name"],
+        ob_time=wt["data"][0]["ob_time"],
+        description=wt["data"][0]["weather"]["description"],
+        temp=wt["data"][0]["temp"],
+        wind_spd=wt["data"][0]["wind_spd"],
+        wind_cdir=wt["data"][0]["wind_cdir"],
+        clouds=wt["data"][0]["clouds"],
         )
-    except:
-        await session.send('获取数据时出问题,请重试')
-        return
\ No newline at end of file
+    )
+
+@on_command('wtlist', aliases=['天气详细'])
+async def _(session: CommandSession):
+    city = session.get('city', prompt='请键入你需要查询的城市(例:北京)')
+    session.send('正在搜寻...')
+    re_msg = google_translate.translate(city[:4999], to='en', source='zh-CN')
+    URL = API_URL + re_msg[0] + API_URL_2
+    # print(URL)
+    res = requests.get(URL)
+    res.encoding = 'utf-8'
+    html = res.text
+    wt = json.loads(html)
+    await session.send(LIST_ALL.format(
+        rh=wt["data"][0]["rh"],
+        pod=wt["data"][0]["pod"],
+        lon=wt["data"][0]["lon"],
+        pres=wt["data"][0]["pres"],
+        timezone=wt["data"][0]["timezone"],
+        ob_time=wt["data"][0]["ob_time"],
+        clouds=wt["data"][0]["clouds"],
+        solar_rad=wt["data"][0]["solar_rad"],
+        city=wt["data"][0]["city_name"],
+        wind_spd=wt["data"][0]["wind_spd"],
+        last_ob_time=wt["data"][0]["last_ob_time"],
+        wind_cdir_full=wt["data"][0]["wind_cdir_full"],
+        wind_cdir=wt["data"][0]["wind_cdir"],
+        temp=wt["data"][0]["temp"],
+        slp=wt["data"][0]["slp"],
+        vis=wt["data"][0]["vis"],
+        h_angle=wt["data"][0]["h_angle"],
+        sunset=wt["data"][0]["sunset"],
+        dni=wt["data"][0]["dni"],
+        dewpt=wt["data"][0]["dewpt"],
+        snow=wt["data"][0]["snow"],
+        uv=wt["data"][0]["uv"],
+        precip=wt["data"][0]["precip"],
+        wind_dir=wt["data"][0]["wind_dir"],
+        sunrise=wt["data"][0]["sunrise"],
+        ghi=wt["data"][0]["ghi"],
+        dhi=wt["data"][0]["dhi"],
+        aqi=wt["data"][0]["aqi"],
+        lat=wt["data"][0]["lat"],
+        description=wt["data"][0]["weather"]["description"],
+        datetime=wt["data"][0]["datetime"],
+        station=wt["data"][0]["station"],
+        elev_angle=wt["data"][0]["elev_angle"],
+        app_temp=wt["data"][0]["app_temp"],
+        )
+    )
+
+
+
+@weather.args_parser
+async def _(session: CommandSession):
+    stripped_arg = session.current_arg_text.strip()
+    if session.is_first_run:
+        if stripped_arg:
+            session.state['city'] = stripped_arg
+        return
+
+    if not stripped_arg:
+        session.pause('要查询的城市不能为空,请重新输入')
+    session.state[session.current_key] = stripped_arg
\ No newline at end of file
diff --git a/__pycache__/config.cpython-37.pyc b/__pycache__/config.cpython-37.pyc
deleted file mode 100644
index 535caa2..0000000
Binary files a/__pycache__/config.cpython-37.pyc and /dev/null differ
diff --git a/run.py b/run.py
index b44f258..d8c0297 100644
--- a/run.py
+++ b/run.py
@@ -9,5 +9,4 @@ if __name__ == '__main__':
     nonebot.load_plugins(
         path.join(path.dirname(__file__), 'AyaBot', 'plugins'),
         'AyaBot.plugins')
-    nonebot.run()
-
+    nonebot.run()
\ No newline at end of file
-- 
cgit v1.2.3