-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBotInfo.py
More file actions
46 lines (41 loc) · 1.26 KB
/
BotInfo.py
File metadata and controls
46 lines (41 loc) · 1.26 KB
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
# @Author: AlanStar
# @Contact: alan233@vip.qq.com
# @License: MIT
# Copyright (c) 2022-2022
import json
# ./config/bot_Info.json 文件检测
def config_status():
with open('./config/bot_Info.json', "r", encoding="UTF-8") as doc:
info = doc.read()
info = json.loads(info)
clientId = info["clientId"]
token = info["token"]
if clientId == "" or token == "":
type = -1
else:
type = 0
return type
# 从 json 中获取 clientId
def get_clientId():
if config_status() == 0:
with open("config/bot_Info.json", mode="r", encoding="UTF-8") as doc:
info = doc.read()
info = json.loads(info)
clientId = info["clientId"]
return clientId
else:
pass
# 从 json 中获取 token
def get_token():
if config_status() == 0:
with open("config/bot_Info.json", mode="r", encoding="UTF-8") as doc:
info = doc.read()
info = json.loads(info)
token = info["token"]
return token
else:
pass
# 拼接 Authorization 以组合公共请求头 -> ./Public_Headers.py
def combine_Authorization():
Authorization = "Bot " + get_clientId() + "." + get_token()
return Authorization