安卓手机 mirai 3.1.7
扩展插件 https://project-mirai.github.io/mirai-api-http/API.html#状态码
python调用
在群内发消息,超过2个字符的发不出去
可发送 :
12
ai
a1
pq
不可发送:
asd
aw1
12345
汉
字
群内无法发送图片
私聊好友一切正常
python 代码
s1 = requests.session()
#登录省略
def sendImageMessage(sessionKey, ID, imgUrl):
j = {
"sessionKey": sessionKey,
# "qq": ID,
"group": ID,
"urls": [imgUrl]
}
res = requests.post(mainUrl + '/sendImageMessage', json=j)
print(res.text)
s1 = requests.session()
#登录省略
def uploadImage(sessionKey, type1, imgName):
data = {
'sessionKey': sessionKey,
'type': type1,
}
params = {"img": (imgName, open(imgName, 'rb'))}
res = requests.post(mainUrl + '/uploadImage', data=data, files=params)
print(res.text)
return eval(res.content)["url"]
def sendGroupMessage(sessionKey, groupID, msg):
j = {
"sessionKey": sessionKey,
"group": groupID,
"messageChain": [
{"type": "Plain", "text": msg}
]
}
print(s1.post(mainUrl + '/sendGroupMessage', json=j).text)