Skip to content

Commit

Permalink
Merge pull request #45 from limitcool/master
Browse files Browse the repository at this point in the history
增加单session 模式支持,更新READEME.md
  • Loading branch information
JHue58 authored Jun 17, 2022
2 parents 766a200 + 4fdf830 commit 7cec5de
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
3 changes: 2 additions & 1 deletion ChatLearning.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def listening(data):

def main():
data = simuse.Get_data()
data = simuse.Get_Session(data)
if data["Key"] != "":
data = simuse.Get_Session(data)
listening(data)
return None

Expand Down
3 changes: 2 additions & 1 deletion ChatReply.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,8 @@ def listening(data):

def main():
data = simuse.Get_data()
data = simuse.Get_Session(data)
if data["Key"] != "":
data = simuse.Get_Session(data)
listening(data)
return None

Expand Down
6 changes: 4 additions & 2 deletions ChatSubadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def Subadmin(group, sender):
group=int(group)
print('群{}进入管理模式,操作者:{}'.format(group, sender))
data = simuse.Get_data()
data = simuse.Get_Session(data)
if data["Key"] != "":
data = simuse.Get_Session(data)
learning_config = ChatLearning.getconfig()
reply_config = [ChatReply.getconfig(3), ChatReply.getconfig(1)]
learning_close_sign = 0
Expand All @@ -118,7 +119,8 @@ def Subadmin(group, sender):

def main():
data = simuse.Get_data()
data = simuse.Get_Session(data)
if data["Key"] != "":
data = simuse.Get_Session(data)
while 1:
time.sleep(1)
subadmindict = getconfig()
Expand Down
7 changes: 5 additions & 2 deletions Chatmain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import base64
import datetime
from distutils.log import fatal
import pickle
import json
import os
Expand Down Expand Up @@ -1683,7 +1684,8 @@ def getcommand_chat():
global data
global adminsendmode
data = simuse.Get_data() # Test
data = simuse.Get_Session(data) # Test
if data["Key"] != "":
data = simuse.Get_Session(data) # Test
while 1:
if adminsendmode == 1:
print('none')
Expand Down Expand Up @@ -1860,7 +1862,8 @@ def commandchoice(command, fromchat=0):
FastDeletesign = 0
adminsign = 0
data = simuse.Get_data()
data = simuse.Get_Session(data)
if data["Key"] != "":
data = simuse.Get_Session(data)
if learningsign == 1:
learningsign = 0
tempsign = learning(learningsign, mergesign, 0)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

```json
{
"Key": "xxxxx", //在mirai-api-http中设置的密钥
"host": "127.0.0.1", //mirai-api-http中设置的地址(若设置成0.0.0.0,请填写127.0.0.1)
"port": "8080", //mirai-api-http中设置的端口
"qq": "xxx", //在mirai登陆的QQ号
"session": "xxx" //无需修改
"Key": "xxxxx", // 在mirai-api-http中设置的密钥,若使用singleMode也不需要校验,设置为""即可
"host": "127.0.0.1", // mirai-api-http中设置的地址(若设置成0.0.0.0,请填写127.0.0.1)
"port": "8080", // mirai-api-http中设置的端口
"qq": "xxx", // 在mirai登陆的QQ号
"session": "xxx" // 无需修改
}
```

Expand Down
4 changes: 3 additions & 1 deletion simuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def Get_Session(data, getsession=0):
host = data['host']
verifyKey = data['Key']
qq = data['qq']
if verifyKey=='':
return 0
url = 'http://' + host + '/verify'
data_in = dict(verifyKey=verifyKey)
try:
Expand All @@ -77,7 +79,7 @@ def Fetch_Message(data, deal=1):
raise ConnectionError('未与api-http取得连接,或mirai未登录')
host = data['host']
session = data['session']
url = 'http://' + host + '/fetchMessage' + '?sessionKey=' + session + '&count=10'
url = 'http://' + host + '/fetchMessage?' + 'count=10'+ '&sessionKey=' + session
res = r.request('get', url)
res = json.loads(res.text)
Message = res['data']
Expand Down

0 comments on commit 7cec5de

Please sign in to comment.