koishi-plugin-oni-sync-bot 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/lib/index.js +31 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as
|
|
1
|
+
import{defineComponent as x,ref as i,watch as d,onMounted as C,resolveComponent as r,openBlock as c,createBlock as g,withCtx as s,createVNode as k,createElementBlock as f,Fragment as B,renderList as T,createElementVNode as p,toDisplayString as $}from"vue";import{store as M,Time as R}from"@koishijs/client";const w="yyyy-MM-dd hh:mm:ss",D=x({__name:"page",setup(o){const e=i(),t=i([]);function l(n){const _=R.template(w,new Date(n.timestamp)),u=n.type.toUpperCase(),m=n.content.replace(/\u001b\[[0-9;]*m/g,"");return`[${_}] [${u}] ${m}`}d(()=>M.onilogs,n=>{n&&(t.value=n.map(l))},{deep:true,immediate:true});const a=()=>{e.value&&(e.value.scrollTop=e.value.scrollHeight)};return d(()=>t.value.length,()=>{setTimeout(a,0)}),C(()=>{a()}),(n,_)=>{const u=r("k-card"),m=r("k-layout");return c(),g(m,null,{default:s(()=>[k(u,{class:"log-container",ref_key:"scrollRef",ref:e},{default:s(()=>[(c(true),f(B,null,T(t.value,(v,h)=>(c(),f("div",{key:h,class:"log-line"},[p("pre",null,$(v),1)]))),128))]),_:1},512)]),_:1})}}}),y=(o,e)=>{const t=o.__vccOpts||o;for(const[l,a]of e)t[l]=a;return t},E=y(D,[["__scopeId","data-v-361e99da"]]),F={};function N(o,e){const t=r("k-card"),l=r("k-layout");return c(),g(l,{class:"calculator"},{default:s(()=>[k(t,null,{default:s(()=>[...e[0]||(e[0]=[p("h2",null,"火箭计算器",-1),p("p",null,"这是一个火箭计算器的页面。",-1)])]),_:1})]),_:1})}const V=y(F,[["render",N]]),I=o=>{o.page({name:"同步机器人",path:"/onilogs",component:E,fields:["onilogs"]}),o.page({name:"火箭计算器",path:"/calculator",component:V})};export{I as default};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.log-container[data-v-
|
|
1
|
+
.log-container[data-v-361e99da]{width:100%;height:100%;overflow-y:auto;padding:12px;font-family:monospace;background:#1e1e1e;color:#d4d4d4}.log-line[data-v-361e99da]{line-height:1.5;font-size:13px}pre[data-v-361e99da]{margin:0;font-family:inherit;white-space:pre-wrap;word-break:break-all}.break-all{word-break:break-all}
|
package/lib/index.js
CHANGED
|
@@ -782,6 +782,7 @@ var PublicLogProvider = class extends import_plugin_console.DataService {
|
|
|
782
782
|
}
|
|
783
783
|
};
|
|
784
784
|
function apply(ctx, config) {
|
|
785
|
+
const log = ctx.logger("oni-sync");
|
|
785
786
|
let ggbot;
|
|
786
787
|
let huijibot;
|
|
787
788
|
ctx.inject(["console"], (ctx2) => {
|
|
@@ -865,14 +866,16 @@ function apply(ctx, config) {
|
|
|
865
866
|
await syncPages(ggbot, huijibot).then(() => {
|
|
866
867
|
logger.info("自动任务:尝试同步所有页面,从 WIKIGG 到 灰机wiki");
|
|
867
868
|
}).catch((err) => {
|
|
868
|
-
logger.error(
|
|
869
|
+
logger.error(`同步所有页面失败`);
|
|
870
|
+
log.error(`,错误信息:${err}`);
|
|
869
871
|
});
|
|
870
872
|
});
|
|
871
873
|
ctx.cron("30 8 * * 3", async () => {
|
|
872
874
|
await syncAllImages(ggbot, huijibot, config).then(() => {
|
|
873
875
|
logger.info("自动任务:尝试同步所有图片,从 WIKIGG 到 灰机wiki");
|
|
874
876
|
}).catch((err) => {
|
|
875
|
-
logger.error(
|
|
877
|
+
logger.error(`同步所有图片失败`);
|
|
878
|
+
log.error(`,错误信息:${err}`);
|
|
876
879
|
});
|
|
877
880
|
});
|
|
878
881
|
});
|
|
@@ -882,7 +885,8 @@ function apply(ctx, config) {
|
|
|
882
885
|
`✅ 已尝试同步页面:${pageTitle},请前往控制台查看:${config.logsUrl}`
|
|
883
886
|
);
|
|
884
887
|
}).catch((err) => {
|
|
885
|
-
session.send(`❌ 同步页面失败:${pageTitle}
|
|
888
|
+
session.send(`❌ 同步页面失败:${pageTitle}`);
|
|
889
|
+
log.error(`,错误信息:${err}`);
|
|
886
890
|
});
|
|
887
891
|
});
|
|
888
892
|
ctx.command("sync.incrementalUpdate", "获取3h内的编辑并尝试更新", {
|
|
@@ -896,7 +900,10 @@ function apply(ctx, config) {
|
|
|
896
900
|
`✅ 已尝试获取三小时前的编辑并同步,请前往控制台查看:${config.logsUrl}`
|
|
897
901
|
);
|
|
898
902
|
}).catch((err) => {
|
|
899
|
-
session.send(
|
|
903
|
+
session.send(
|
|
904
|
+
`❌ 同步所有页面失败,请前往控制台查看日志:${config.logsUrl}`
|
|
905
|
+
);
|
|
906
|
+
log.error(`同步所有页面失败,错误信息:${err}`);
|
|
900
907
|
});
|
|
901
908
|
});
|
|
902
909
|
ctx.command("sync.allpages", "同步所有页面", { authority: 2 }).action(async ({ session }) => {
|
|
@@ -908,7 +915,10 @@ function apply(ctx, config) {
|
|
|
908
915
|
`✅ 已尝试同步所有页面,请前往控制台查看:${config.logsUrl}`
|
|
909
916
|
);
|
|
910
917
|
}).catch((err) => {
|
|
911
|
-
session.send(
|
|
918
|
+
session.send(
|
|
919
|
+
`❌ 同步所有页面失败,请前往控制台查看日志:${config.logsUrl}`
|
|
920
|
+
);
|
|
921
|
+
log.error(`同步所有页面失败,错误信息:${err}`);
|
|
912
922
|
});
|
|
913
923
|
});
|
|
914
924
|
ctx.command("sync.module <moduleTitle:string>", "同步指定模块", {
|
|
@@ -920,7 +930,8 @@ function apply(ctx, config) {
|
|
|
920
930
|
`✅ 已尝试同步模块:${moduleTitle},请前往控制台查看:${config.logsUrl}`
|
|
921
931
|
);
|
|
922
932
|
}).catch((err) => {
|
|
923
|
-
session.send(`❌ 同步模块失败:${moduleTitle}
|
|
933
|
+
session.send(`❌ 同步模块失败:${moduleTitle}`);
|
|
934
|
+
log.error(`错误信息:${err}`);
|
|
924
935
|
});
|
|
925
936
|
});
|
|
926
937
|
ctx.command("sync.allmodules", "同步所有模块", { authority: 2 }).action(async ({ session }) => {
|
|
@@ -932,7 +943,10 @@ function apply(ctx, config) {
|
|
|
932
943
|
`✅ 已尝试同步所有模块,请前往控制台查看:${config.logsUrl}`
|
|
933
944
|
);
|
|
934
945
|
}).catch((err) => {
|
|
935
|
-
session.send(
|
|
946
|
+
session.send(
|
|
947
|
+
`❌ 同步所有模块失败,请前往控制台查看日志:${config.logsUrl}`
|
|
948
|
+
);
|
|
949
|
+
log.error(`同步所有模块失败,错误信息:${err}`);
|
|
936
950
|
});
|
|
937
951
|
});
|
|
938
952
|
ctx.command("sync.img <imgTitle:string>", "同步指定图片", { authority: 2 }).action(async ({ session }, imgTitle) => {
|
|
@@ -947,7 +961,8 @@ function apply(ctx, config) {
|
|
|
947
961
|
).then(() => {
|
|
948
962
|
session.send(`✅ 已尝试同步图片:${imgTitle}`);
|
|
949
963
|
}).catch((err) => {
|
|
950
|
-
session.send(`❌ 同步图片失败:${imgTitle}
|
|
964
|
+
session.send(`❌ 同步图片失败:${imgTitle}`);
|
|
965
|
+
log.error(`同步图片失败:${imgTitle},错误信息:${err}`);
|
|
951
966
|
});
|
|
952
967
|
});
|
|
953
968
|
ctx.command("sync.allimgs", "同步所有图片", { authority: 2 }).action(async ({ session }) => {
|
|
@@ -959,7 +974,10 @@ function apply(ctx, config) {
|
|
|
959
974
|
`✅ 已尝试同步所有图片,请前往控制台查看:${config.logsUrl}`
|
|
960
975
|
);
|
|
961
976
|
}).catch((err) => {
|
|
962
|
-
session.send(
|
|
977
|
+
session.send(
|
|
978
|
+
`❌ 同步所有图片失败,请前往控制台查看日志:${config.logsUrl}`
|
|
979
|
+
);
|
|
980
|
+
log.error(`同步所有图片失败,错误信息:${err}`);
|
|
963
981
|
});
|
|
964
982
|
});
|
|
965
983
|
ctx.command("x <itemName>", "查询缺氧中文wiki,精准匹配+拼音模糊匹配").alias("/查wiki").action(async ({ session }, itemName = "") => {
|
|
@@ -1097,7 +1115,7 @@ bwiki: https://${config.domain}/bw/${id}
|
|
|
1097
1115
|
session.send(`✅ 检索到 ${pages.length} 个页面,已更新至数据库`);
|
|
1098
1116
|
logger.info(`检索到 ${pages.length} 个页面,已更新至数据库`);
|
|
1099
1117
|
} catch (err) {
|
|
1100
|
-
|
|
1118
|
+
log.error("主站缓存更新失败", err);
|
|
1101
1119
|
session.send("❌ 主站缓存更新失败,请联系管理员查看日志");
|
|
1102
1120
|
}
|
|
1103
1121
|
});
|
|
@@ -1107,7 +1125,7 @@ bwiki: https://${config.domain}/bw/${id}
|
|
|
1107
1125
|
session.send(`✅ 已删除 ${count.removed} 条本地缓存`);
|
|
1108
1126
|
logger.info(`已删除 ${count.removed} 条本地缓存`);
|
|
1109
1127
|
} catch (err) {
|
|
1110
|
-
|
|
1128
|
+
log.error("删除缓存失败", err);
|
|
1111
1129
|
session.send("❌ 删除缓存失败,请联系管理员查看日志");
|
|
1112
1130
|
}
|
|
1113
1131
|
});
|
|
@@ -1117,7 +1135,7 @@ bwiki: https://${config.domain}/bw/${id}
|
|
|
1117
1135
|
session.send(`📊 数据库中缓存了 ${pages.length} 条页面`);
|
|
1118
1136
|
logger.info(`数据库中缓存了 ${pages.length} 条页面`);
|
|
1119
1137
|
} catch (err) {
|
|
1120
|
-
|
|
1138
|
+
log.error("查询缓存状态失败", err);
|
|
1121
1139
|
session.send("❌ 查询缓存状态失败,请联系管理员查看日志");
|
|
1122
1140
|
}
|
|
1123
1141
|
});
|
|
@@ -1137,7 +1155,7 @@ bwiki: https://${config.domain}/bw/${id}
|
|
|
1137
1155
|
session.send(`✅ 已尝试添加重定向 ${pageName} -> ${targetPageName}`);
|
|
1138
1156
|
await session.execute(`update`);
|
|
1139
1157
|
} catch (err) {
|
|
1140
|
-
|
|
1158
|
+
log.error(`添加重定向 ${pageName} -> ${targetPageName} 失败`, err);
|
|
1141
1159
|
session.send(`❌ 添加重定向失败,请联系管理员查看日志`);
|
|
1142
1160
|
}
|
|
1143
1161
|
});
|