1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
import requests
import hmac
import hashlib
import base64
import time
# config
token = "找 yijiong 要"
token_name = "找 yijiong 要"
# api url
url = "找 yijiong 要"
def send_command(group_id: int, command: str, chat_echo_bool: str = "false", async_bool: str = "false"):
timestamp = int(time.time())
# Create the signature
message = f"{token}{command}{group_id}{timestamp}{chat_echo_bool}{async_bool}"
digest = hmac.new(token_name.encode(), message.encode(), digestmod=hashlib.sha256).digest()
signature = base64.b64encode(digest).decode()
# headers
headers = {
"Content-Type": "application/json"
}
# payload
payload = {
"token": token,
"command": command,
"group_id": group_id,
"chat_echo": chat_echo_bool,
"async": async_bool,
"timestamp": timestamp,
"signature": signature
}
# Make the request
response = requests.post(url, headers=headers, json=payload)
# Print the response
print(response.json())
# calm down
time.sleep(1)
def main():
send_command(0, "/list query xxx", "true")
send_command(0, "/list show xxx", "true")
// more...
if __name__ == '__main__':
main()
|