|
@@ -0,0 +1,35 @@
|
|
|
+from anon import PluginManager
|
|
|
+from anon.event import MessageEvent
|
|
|
+
|
|
|
+import aiohttp
|
|
|
+import json
|
|
|
+
|
|
|
+url = 'http://openapi.tuling123.com/openapi/api/v2'
|
|
|
+
|
|
|
+data = {
|
|
|
+ 'reqType': 0,
|
|
|
+ 'perception': {
|
|
|
+ 'inputText': {
|
|
|
+ 'text': 'test'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'userInfo': {
|
|
|
+ 'apiKey': '19894d9f828147549f19be2ea668a9e4',
|
|
|
+ 'userId': 'placeholder'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+async def getResponse(sentence, uid):
|
|
|
+ data['userInfo']['userId'] = uid
|
|
|
+ data['perception']['inputText']['text'] = sentence
|
|
|
+
|
|
|
+ async with aiohttp.ClientSession() as session:
|
|
|
+ async with session.post(url, json=data) as res:
|
|
|
+ return json.loads(await res.text())['results'][0]['values']['text']
|
|
|
+
|
|
|
+
|
|
|
+@PluginManager().register_event([MessageEvent])
|
|
|
+async def turing(event: MessageEvent):
|
|
|
+ if event.raw.startswith(' '):
|
|
|
+ await event.reply(await getResponse(event.raw.strip(), event.sender.user_id))
|