This commit is contained in:
midoks
2023-03-13 02:33:29 +08:00
parent bbf93bfd9e
commit 6be4c5977b
3 changed files with 112 additions and 0 deletions
+1
View File
@@ -5,6 +5,7 @@
<p class="bgw" onclick="pluginService('tgbot');">服务</p>
<p onclick="pluginInitD('tgbot');">自启动</p>
<p onclick="botConf();">Bot配置</p>
<p onclick="botExtList();">扩展列表</p>
<p onclick="pluginLogs('tgbot','','run_log');">日志</p>
</div>
<div class="bt-w-con pd15">
+39
View File
@@ -48,6 +48,22 @@ def writeConf(data):
return True
def getExtCfg():
cfg_path = getServerDir() + "/extend.cfg"
if not os.path.exists(cfg_path):
mw.writeFile(cfg_path, '{}')
t = mw.readFile(cfg_path)
return json.loads(t)
def writeExtCfg(data):
cfg_path = getServerDir() + "/extend.cfg"
if not os.path.exists(cfg_path):
mw.writeFile(cfg_path, '{}')
t = mw.readFile(cfg_path)
return json.loads(t)
def getInitDTpl():
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
return path
@@ -158,6 +174,11 @@ def reload():
content = mw.readFile(tgbot_tpl)
mw.writeFile(tgbot_dst, content)
ext_src = getPluginDir() + '/startup/extend'
ext_dst = getServerDir()
mw.execShell('cp -rf ' + ext_src + ' ' + ext_dst)
return tbOp('restart')
@@ -222,6 +243,22 @@ def uninstallPreInspection():
return "请手动删除<br/> rm -rf {}".format(getServerDir())
def botExtList():
ext_path = getServerDir() + '/extend'
if not os.path.exists(ext_path):
return mw.returnJson(False, 'ok', [])
elist_source = os.listdir(ext_path)
elist = []
for e in elist_source:
if e.endswith('py'):
elist.append(e)
# extList = getExtCfg()
print(elist)
def runLog():
p = getServerDir() + '/task.log'
return p
@@ -253,6 +290,8 @@ if __name__ == "__main__":
print(getBotConf())
elif func == 'set_bot_conf':
print(setBotConf())
elif func == 'bot_ext_list':
print(botExtList())
elif func == 'run_log':
print(runLog())
+72
View File
@@ -76,3 +76,75 @@ function submitBotConf(){
layer.msg(rdata['msg'],{icon:rdata['status']?1:2,time:2000,shade: [0.3, '#000']});
});
}
function botExtList(){
var body = '<div class="divtable mtb10">\
<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">\
<thead>\
<tr>\
<th width="20">脚本</th>\
<th width="120">类型</th>\
<th width="10">状态</th>\
<th style="text-align: right;" width="50">操作</th>\
</tr>\
</thead>\
<tbody id="ext_list"></tbody>\
</table>\
<div class="dataTables_paginate paging_bootstrap pagination">\
<ul id="ext_list_page" class="page"></ul>\
</div>\
</div>';
$('.soft-man-con').html(body);
botExtListP(1)
}
function botExtListP(p=1){
appPost('bot_ext_list',{'page':p}, function(rdata){
var rdata = $.parseJSON(rdata.data);
var tBody = '';
if (rdata.data.length == 0 ){
var tBody = '<tr><td colspan="4"><div style="text-align:center;">无数据</div></td></tr>';
}
var ldata = rdata.data;
for (var i = 0; i < ldata.length; i++) {
tBody += '<tr data-id="'+ldata[i]['name']+'">'
tBody += '<td>'+ldata[i]['id']+'</td>';
tBody += '<td>'+ldata[i]['name']+'</td>';
if (ldata[i]['status'] == 'start'){
tBody += '<td><span style="color:#20a53a;cursor: pointer;" class="strategy_status glyphicon glyphicon-play"></span></td>';
} else{
tBody += '<td><span style="color:red;cursor: pointer;" class="strategy_status glyphicon glyphicon-pause"></span></td>';
}
tBody += "<td style='text-align: right;'><a class='btlink restart'>重启</a> | <a class='btlink edit'>编辑</a></td>";
tBody +='<tr>';
};
$('#ext_list').html(tBody);
// $('#strategy_list_page').html(rdata.data.list);
// $('#strategy_list .strategy_status').click(function(){
// var id = $(this).parent().parent().data('id');
// var status = 'stop';
// if ($(this).hasClass('glyphicon-pause')){
// status = 'start';
// }
// setStrategyStatus(id,status);
// });
// $('#strategy_list .restart').click(function(){
// var id = $(this).parent().parent().data('id');
// setStrategyRestart(id);
// });
// $('#strategy_list .edit').click(function(){
// var id = $(this).parent().parent().data('id');
// setStrategyEdit(id);
// });
});
}