-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
47 lines (45 loc) · 1.93 KB
/
index.py
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
import os
import asyncio
import libs.main as BotMain
import libs.audit as BotAudit
from botpy import logging
_log = logging.get_logger() #Botpy Logger
config_path = os.path.join(os.getcwd(), 'config.py')
if __name__ == '__main__':
# 检查config.py是否存在
if os.path.isfile(config_path):
try:
from config import *
if AUDIT:
asyncio.run(BotMain.main(APPID,SECRET))
else:
cAUDIT = input("机器人是否已经通过开放平台审核(y/n):")
with open('config.py','w',encoding='utf8') as f:
f.write(f'APPID="{APPID}"\n')
f.write(f'SECRET="{SECRET}"\n')
if(cAUDIT == 'y'):
_log.info("审核通过,正在启动主程序,若未通过审核,则无法使用该机器人(可从config.py中更改)")
f.write(f'AUDIT=True')
input("按任意键继续...")
exit(0)
else:
f.write(f'AUDIT=False')
if(cAUDIT != 'y'):
_log.info("正在启动审核模式...")
BotAudit.main(APPID,SECRET)
except ImportError as e:
_log.error(f"导入账号信息失败: {e}")
else:
_log.warning("账号信息不存在,正在新建账号")
APPID = input("请输入AppID(机器人ID):")
SECRET = input("请输入AppSecret(机器人密钥)")
AUDIT = input("机器人是否已经通过开放平台审核(y/n):")
with open('config.py','w',encoding='utf8') as f:
f.write(f'APPID="{APPID}"\n')
f.write(f'SECRET="{SECRET}"\n')
if(AUDIT == 'y'):
f.write(f'AUDIT=True')
else:
f.write(f'AUDIT=False')
_log.info("导入账号信息完毕,请重启...")
input("按任意键继续...")