From 6be4c5977b5fed2e206120c80894eb09ecaf9d66 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 13 Mar 2023 02:33:29 +0800 Subject: [PATCH] up --- plugins/tgbot/index.html | 1 + plugins/tgbot/index.py | 39 +++++++++++++++++++++ plugins/tgbot/js/tgbot.js | 72 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) diff --git a/plugins/tgbot/index.html b/plugins/tgbot/index.html index f98fd5ded..b0020e579 100755 --- a/plugins/tgbot/index.html +++ b/plugins/tgbot/index.html @@ -5,6 +5,7 @@

服务

自启动

Bot配置

+

扩展列表

日志

diff --git a/plugins/tgbot/index.py b/plugins/tgbot/index.py index a97219094..aebb79b1a 100755 --- a/plugins/tgbot/index.py +++ b/plugins/tgbot/index.py @@ -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 "请手动删除
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()) diff --git a/plugins/tgbot/js/tgbot.js b/plugins/tgbot/js/tgbot.js index 04c1643ed..0170cdcd7 100755 --- a/plugins/tgbot/js/tgbot.js +++ b/plugins/tgbot/js/tgbot.js @@ -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 = '
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
脚本类型状态操作
\ + \ +
'; + $('.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 = '
无数据
'; + } + + var ldata = rdata.data; + for (var i = 0; i < ldata.length; i++) { + tBody += '' + tBody += ''+ldata[i]['id']+''; + tBody += ''+ldata[i]['name']+''; + + if (ldata[i]['status'] == 'start'){ + tBody += ''; + } else{ + tBody += ''; + } + + tBody += "重启 | 编辑"; + tBody +=''; + }; + $('#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); + // }); + }); +}