@minato-bot/plugin-wxjsxy 2.4.4 → 2.4.6

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.d.mts CHANGED
@@ -7,6 +7,7 @@ import { TextSegment } from "node-napcat-ts";
7
7
  import * as _$yargs from "yargs";
8
8
 
9
9
  //#region src/api.d.ts
10
+ declare function changeCasAndDyUrl(cas: string, dy: string): void;
10
11
  declare const casReq: _$_atri_bot_lib_request0.KyInstance;
11
12
  declare const dyReq: _$_atri_bot_lib_request0.KyInstance;
12
13
  interface LoginToCasReq {
@@ -168,6 +169,8 @@ interface WxjsxyPluginConfig {
168
169
  cron: string;
169
170
  offset: number;
170
171
  }>;
172
+ casUrl: string;
173
+ dyUrl: string;
171
174
  }
172
175
  declare const plugin: Plugin<WxjsxyPluginConfig>;
173
176
  declare const addAccountCommand: _$_atri_bot_core0.ATRICommand<"message", _$yargs.Argv<{
@@ -199,4 +202,4 @@ declare function startProcess(req: LoginToCasReq, offset: number): Promise<TextS
199
202
  declare function syncCrons(config: WxjsxyPluginConfig, bot: Bot, saveConfig: () => Promise<void>, logger: ATRI['logger']): Promise<void>;
200
203
  declare function stopAllCrons(): void;
201
204
  //#endregion
202
- export { DyProcessDetailRes, DyProcessItem, DyProcessRes, GetDyTokenRes, LoginToCasReq, LoginToCasRes, RSAKeyPair, SetDyProcessReq, SetDyProcessRes, WxjsxyPluginConfig, addAccountCommand, casReq, checkHaveAccount, cronStartProcessCommand, cronStopProcessCommand, deleteAccountCommand, dyReq, encryptedString, getCasLoginToken, getDyCookie, getDyProcessDetail, getDyProcessList, getDyProcessReq, getDyToken, getDyTokenByCas, getProcessList, getProcessListCommand, loginToCas, plugin, setDyProcess, setMaxDigits, startProcess, startProcessCommand, stopAllCrons, syncCrons };
205
+ export { DyProcessDetailRes, DyProcessItem, DyProcessRes, GetDyTokenRes, LoginToCasReq, LoginToCasRes, RSAKeyPair, SetDyProcessReq, SetDyProcessRes, WxjsxyPluginConfig, addAccountCommand, casReq, changeCasAndDyUrl, checkHaveAccount, cronStartProcessCommand, cronStopProcessCommand, deleteAccountCommand, dyReq, encryptedString, getCasLoginToken, getDyCookie, getDyProcessDetail, getDyProcessList, getDyProcessReq, getDyToken, getDyTokenByCas, getProcessList, getProcessListCommand, loginToCas, plugin, setDyProcess, setMaxDigits, startProcess, startProcessCommand, stopAllCrons, syncCrons };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{n as e,r as t,t as n}from"./lib-DMqn3JNQ.mjs";import r from"node:crypto";import{useRequest as i}from"@atri-bot/lib-request";import{Plugin as a}from"@atri-bot/core";import{addCronJob as o,getCronJob as s,getCronJobs as c,removeCronJob as l}from"@atri-bot/lib-cron";import{Structs as u}from"node-napcat-ts";import d from"dayjs";t(131);const f=new n(`010001`,``,`00b5eeb166e069920e80bebd1fea4829d3d1f3216f2aabe79b6c47a3c18dcee5fd22c2e7ac519cab59198ece036dcf289ea8201e2a0b9ded307f8fb704136eaeb670286f5ad44e691005ba9ea5af04ada5367cd724b5a26fdb5120cc95b6431604bd219c6b7d83a6f8f24b43918ea988a76f93c333aa5a20991493d4eb1117e7b1`),p=`https://1252343003-i6vavhfm71.ap-guangzhou.tencentscf.com`,m=`https://1252343003-lhlsf5iypl.ap-guangzhou.tencentscf.com`,h=i({throwHttpErrors:!1,headers:{"User-Agent":`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36`,Accept:`application/json, text/plain, */*`,"Content-Type":`application/x-www-form-urlencoded`,"sec-ch-ua-platform":`"Windows"`}}),g=i({headers:{"User-Agent":`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36`,Accept:`application/json, text/plain, */*`,"sec-ch-ua-platform":`"Windows"`,mode:`wxa`,"Content-Type":`application/json`}});async function _(t){let{username:n,password:r}=t;return await h.post(`${p}/lyuapServer/v1/tickets`,{body:new URLSearchParams({username:n,password:e(f,r),service:`https://portal.wxjsxy.com.cn/`,loginType:``,id:``,code:``,otpcode:``})}).json()}async function v(e){let t=await h.post(`${p}/lyuapServer/v1/tickets/${e}`,{body:new URLSearchParams({service:`https://dy.wxjsxy.com.cn/prdapi/wxjsxyapp/cas/index`,loginToken:`loginToken`})}).text();return[t.startsWith(`ST-`),t]}async function y(e){let t=(await h.get(`${m}/prdapi/wxjsxyapp/cas/index?ticket=${e}`,{redirect:`manual`})).headers.getSetCookie();return t.length===0?null:t.map(e=>`${e.split(`;`)[0]};`).join(``)}async function b(e){return await g.get(`${m}/prdapi/wxjsxyapp/cas/indexData`,{headers:{cookie:e}}).json()}async function x(e,t){let n={...t,processDefinitionKey:`studentApply`},i=r.createHash(`md5`).update(`myappsecret${JSON.stringify(n)}myappsecret`).digest(`hex`);return await g.post(`${m}/prdapi/activiti/processInstance/startProcess?user_info_query_json=${encodeURIComponent(JSON.stringify(n))}&sign=${i}`,{json:n,headers:{token:e,sign:i,timestamp:Date.now().toString()}}).json()}async function S(e,t={pageNo:1,pageSize:1}){let n=r.createHash(`md5`).update(`myappsecret${JSON.stringify(t)}myappsecret`).digest(`hex`);return await g.post(`${m}/prdapi/activiti/task/myapply?user_info_query_json=${encodeURIComponent(JSON.stringify(t))}&sign=${n}`,{json:t,headers:{token:e,sign:n,timestamp:Date.now().toString()}}).json()}async function C(e,t){let n={instanceId:t},i=r.createHash(`md5`).update(`myappsecret${JSON.stringify(n)}myappsecret`).digest(`hex`);return await g.post(`${m}/prdapi/activiti/task/done/info/byInstanceId?user_info_query_json=${encodeURIComponent(JSON.stringify(n))}&sign=${i}`,{json:n,headers:{token:e,sign:i,timestamp:Date.now().toString()}}).json()}var w=`@minato-bot/plugin-wxjsxy`;function T(e,t){return e.accounts[t]?[!0,null]:[!1,[u.text(`请先添加账号,使用命令:wxjsxy添加账号`)]]}async function E(e){let t=await _(e);if(!(`ticket`in t))return[u.text(`请假失败, 登陆账号失败: ${JSON.stringify(t)}`)];let[n,r]=await v(t.tgt);if(!n)return[u.text(`请假失败, 获取CasToken失败: ${r}`)];let i=await y(r);if(!i)return[u.text(`请假失败, 获取DyCookie失败`)];let a=await b(i);return a.token?a.token:[u.text(`请假失败, 获取DyToken失败: ${JSON.stringify(a)}`)]}async function D(e,t){let n=await E(e);if(Array.isArray(n))return n;let r=await x(n,{beginTime:d().add(t,`day`).hour(6).minute(30).format(`YYYY-MM-DD HH:mm`),endTime:d().add(t,`day`).hour(20).minute(50).format(`YYYY-MM-DD HH:mm`),leaveSchool:`是`,backDormitory:`是`,askedType:`事假`,reason:`集训`});return r.code===200?[u.text(`请假成功, 返回信息: \n ${JSON.stringify(r)}`)]:[u.text(`请假失败, 提交请假申请失败: ${JSON.stringify(r)}`)]}async function O(e,t,n,r){k();for(let[i,a]of Object.entries(e.crons))s(`wxjsxy_cron_${i}`)&&l(`wxjsxy_cron_${i}`),o({name:`wxjsxy_cron_${i}`,cronTime:a.cron,onTick:async()=>{let[o,s]=T(e,i.toString());if(!o){r.WARN(`用户 ${i} 的账号信息有误,无法执行定时请假任务,已自动删除定时任务`),delete e.crons[i],await n();return}let c=await D(e.accounts[i],a.offset);await t.sendMsg({message_type:`private`,user_id:Number.parseFloat(i)},c)}})}function k(){for(let[e,t]of Object.entries(c()))e.startsWith(`wxjsxy_cron_`)&&l(e)}const A=new a(w).setDefaultConfig([{key:`accounts`,val:{},comment:`账号信息, key为用户id, value为账号信息`},{key:`crons`,val:{},comment:`定时任务信息, key为用户id, value为定时任务信息`}]).onInstall(async({config:e,bot:t,saveConfig:n,logger:r})=>{await O(e,t,n,r)}).onUninstall(()=>{k()}),j=A.command(`wxjsxy添加账号`).commander(e=>e().option(`username`,{alias:`u`,type:`string`,description:`账号`}).option(`password`,{alias:`p`,type:`string`,description:`密码`})).callback(async({context:e,options:t,config:n,bot:r,saveConfig:i})=>{if(T(n,e.user_id.toString())[0]){await r.sendMsg(e,[u.text(`账号已存在, 无需重复添加`)]);return}let{username:a,password:o}=t;if(!a){await r.sendMsg(e,[u.text(`请输入账号(学号):`)]);let t=await r.useMessage(e);if(!t)return;a=t.raw_message.trim()}if(!o){await r.sendMsg(e,[u.text(`请输入密码(Wxjsxy@身份证后六位):`)]);let t=await r.useMessage(e);if(!t)return;o=t.raw_message.trim()}let s=await _({username:a,password:o});if(!(`ticket`in s)){await r.sendMsg(e,[u.text(`登录失败, 请检查账号密码是否正确: \n ${JSON.stringify(s)}`)]);return}await r.sendMsg(e,[u.text(`登录成功, 返回信息: \n ${JSON.stringify(s)}`)]),n.accounts[e.user_id.toString()]={username:a,password:o},await i()}),M=A.command(`wxjsxy删除账号`).callback(async({context:e,config:t,bot:n,saveConfig:r})=>{let[i,a]=T(t,e.user_id.toString());if(!i){await n.sendMsg(e,a);return}delete t.accounts[e.user_id.toString()],delete t.crons[e.user_id.toString()],l(`wxjsxy_cron_${e.user_id}`),await r(),await n.sendMsg(e,[u.text(`账号删除成功`)])}),N=A.command(`wxjsxy请假`).commander(e=>e().option(`offset`,{alias:`o`,type:`number`,description:`请假日期相对于今天的偏移, 0表示当天`})).callback(async({context:e,options:t,config:n,bot:r})=>{let[i,a]=T(n,e.user_id.toString());if(!i){await r.sendMsg(e,a);return}let{offset:o}=t;if(o===void 0){await r.sendMsg(e,[u.text(`请输入请假日期相对于今天的偏移, 0表示当天:`)]);let t=await r.useMessage(e);if(!t)return;if(o=Number.parseInt(t.raw_message.trim()),Number.isNaN(o)){await r.sendMsg(e,[u.text(`偏移必须是一个数字`)]);return}}let s=await D(n.accounts[e.user_id.toString()],o);await r.sendMsg(e,s)});async function P(e,t){let n=await E(e);if(Array.isArray(n))return n;let r=await S(n,t);if(r.code!==200)return[u.text(`获取请假情况失败, 错误信息: ${JSON.stringify(r)}`)];let i=await Promise.all(r.rows.map(e=>C(n,e.instanceId)));return i.some(e=>e.code!==200)?[u.text(`获取请假详情失败, 错误信息: ${JSON.stringify(i)}`)]:[u.text(`请假情况:
1
+ import{n as e,r as t,t as n}from"./lib-DMqn3JNQ.mjs";import r from"node:crypto";import{useRequest as i}from"@atri-bot/lib-request";import{Plugin as a}from"@atri-bot/core";import{addCronJob as o,getCronJob as s,getCronJobs as c,removeCronJob as l}from"@atri-bot/lib-cron";import{Structs as u}from"node-napcat-ts";import d from"dayjs";t(131);const f=new n(`010001`,``,`00b5eeb166e069920e80bebd1fea4829d3d1f3216f2aabe79b6c47a3c18dcee5fd22c2e7ac519cab59198ece036dcf289ea8201e2a0b9ded307f8fb704136eaeb670286f5ad44e691005ba9ea5af04ada5367cd724b5a26fdb5120cc95b6431604bd219c6b7d83a6f8f24b43918ea988a76f93c333aa5a20991493d4eb1117e7b1`);let p=`https://1252343003-bmxobd4t96.ap-shanghai.tencentscf.com`,m=`https://1252343003-ku2o9smhxs.ap-shanghai.tencentscf.com`;function h(e,t){p=e,m=t}const g=i({throwHttpErrors:!1,headers:{"User-Agent":`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36`,Accept:`application/json, text/plain, */*`,"Content-Type":`application/x-www-form-urlencoded`,"sec-ch-ua-platform":`"Windows"`}}),_=i({headers:{"User-Agent":`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36`,Accept:`application/json, text/plain, */*`,"sec-ch-ua-platform":`"Windows"`,mode:`wxa`,"Content-Type":`application/json`}});async function v(t){let{username:n,password:r}=t;return await g.post(`${p}/lyuapServer/v1/tickets`,{body:new URLSearchParams({username:n,password:e(f,r),service:`https://portal.wxjsxy.com.cn/`,loginType:``,id:``,code:``,otpcode:``})}).json()}async function y(e){let t=await g.post(`${p}/lyuapServer/v1/tickets/${e}`,{body:new URLSearchParams({service:`https://dy.wxjsxy.com.cn/prdapi/wxjsxyapp/cas/index`,loginToken:`loginToken`})}).text();return[t.startsWith(`ST-`),t]}async function b(e){let t=(await g.get(`${m}/prdapi/wxjsxyapp/cas/index?ticket=${e}`,{redirect:`manual`})).headers.getSetCookie();return t.length===0?null:t.map(e=>`${e.split(`;`)[0]};`).join(``)}async function x(e){return await _.get(`${m}/prdapi/wxjsxyapp/cas/indexData`,{headers:{cookie:e}}).json()}async function S(e,t){let n={...t,processDefinitionKey:`studentApply`},i=r.createHash(`md5`).update(`myappsecret${JSON.stringify(n)}myappsecret`).digest(`hex`);return await _.post(`${m}/prdapi/activiti/processInstance/startProcess?user_info_query_json=${encodeURIComponent(JSON.stringify(n))}&sign=${i}`,{json:n,headers:{token:e,sign:i,timestamp:Date.now().toString()}}).json()}async function C(e,t={pageNo:1,pageSize:1}){let n=r.createHash(`md5`).update(`myappsecret${JSON.stringify(t)}myappsecret`).digest(`hex`);return await _.post(`${m}/prdapi/activiti/task/myapply?user_info_query_json=${encodeURIComponent(JSON.stringify(t))}&sign=${n}`,{json:t,headers:{token:e,sign:n,timestamp:Date.now().toString()}}).json()}async function w(e,t){let n={instanceId:t},i=r.createHash(`md5`).update(`myappsecret${JSON.stringify(n)}myappsecret`).digest(`hex`);return await _.post(`${m}/prdapi/activiti/task/done/info/byInstanceId?user_info_query_json=${encodeURIComponent(JSON.stringify(n))}&sign=${i}`,{json:n,headers:{token:e,sign:i,timestamp:Date.now().toString()}}).json()}var T=`@minato-bot/plugin-wxjsxy`;function E(e,t){return e.accounts[t]?[!0,null]:[!1,[u.text(`请先添加账号,使用命令:wxjsxy添加账号`)]]}async function D(e){let t=await v(e);if(!(`ticket`in t))return[u.text(`请假失败, 登陆账号失败: ${JSON.stringify(t)}`)];let[n,r]=await y(t.tgt);if(!n)return[u.text(`请假失败, 获取CasToken失败: ${r}`)];let i=await b(r);if(!i)return[u.text(`请假失败, 获取DyCookie失败`)];let a=await x(i);return a.token?a.token:[u.text(`请假失败, 获取DyToken失败: ${JSON.stringify(a)}`)]}async function O(e,t){let n=await D(e);if(Array.isArray(n))return n;let r=await S(n,{beginTime:d().add(t,`day`).hour(6).minute(30).format(`YYYY-MM-DD HH:mm`),endTime:d().add(t,`day`).hour(20).minute(50).format(`YYYY-MM-DD HH:mm`),leaveSchool:`是`,backDormitory:`是`,askedType:`事假`,reason:`集训`});return r.code!==200&&(r=await S(n,{beginTime:d().add(t,`day`).hour(6).minute(30).format(`YYYY-MM-DD HH:mm`),endTime:d().add(t,`day`).hour(16).minute(0).format(`YYYY-MM-DD HH:mm`),leaveSchool:`是`,backDormitory:`是`,askedType:`事假`,reason:`集训`}),r.code!==200)?[u.text(`请假失败, 提交请假申请失败: ${JSON.stringify(r)}`)]:[u.text(`请假成功, 返回信息: \n ${JSON.stringify(r)}`)]}async function k(e,t,n,r){A();for(let[i,a]of Object.entries(e.crons))s(`wxjsxy_cron_${i}`)&&l(`wxjsxy_cron_${i}`),o({name:`wxjsxy_cron_${i}`,cronTime:a.cron,onTick:async()=>{let[o,s]=E(e,i.toString());if(!o){r.WARN(`用户 ${i} 的账号信息有误,无法执行定时请假任务,已自动删除定时任务`),delete e.crons[i],await n();return}let c=await O(e.accounts[i],a.offset);await t.sendMsg({message_type:`private`,user_id:Number.parseFloat(i)},c)}})}function A(){for(let[e,t]of Object.entries(c()))e.startsWith(`wxjsxy_cron_`)&&l(e)}const j=new a(T).setDefaultConfig([{key:`accounts`,val:{},comment:`账号信息, key为用户id, value为账号信息`},{key:`crons`,val:{},comment:`定时任务信息, key为用户id, value为定时任务信息`},{key:`casUrl`,val:`https://1252343003-bmxobd4t96.ap-shanghai.tencentscf.com`,comment:`CAS服务器URL, 默认为上海环境URL`},{key:`dyUrl`,val:`https://1252343003-ku2o9smhxs.ap-shanghai.tencentscf.com`,comment:`DY服务器URL, 默认为上海环境URL`}]).onInstall(async({config:e,bot:t,saveConfig:n,logger:r})=>{await k(e,t,n,r)}).onUninstall(()=>{A()}),M=j.command(`wxjsxy添加账号`).commander(e=>e().option(`username`,{alias:`u`,type:`string`,description:`账号`}).option(`password`,{alias:`p`,type:`string`,description:`密码`})).callback(async({context:e,options:t,config:n,bot:r,saveConfig:i})=>{if(E(n,e.user_id.toString())[0]){await r.sendMsg(e,[u.text(`账号已存在, 无需重复添加`)]);return}let{username:a,password:o}=t;if(!a){await r.sendMsg(e,[u.text(`请输入账号(学号):`)]);let t=await r.useMessage(e);if(!t)return;a=t.raw_message.trim()}if(!o){await r.sendMsg(e,[u.text(`请输入密码(Wxjsxy@身份证后六位):`)]);let t=await r.useMessage(e);if(!t)return;o=t.raw_message.trim()}let s=await v({username:a,password:o});if(!(`ticket`in s)){await r.sendMsg(e,[u.text(`登录失败, 请检查账号密码是否正确: \n ${JSON.stringify(s)}`)]);return}await r.sendMsg(e,[u.text(`登录成功, 返回信息: \n ${JSON.stringify(s)}`)]),n.accounts[e.user_id.toString()]={username:a,password:o},await i()}),N=j.command(`wxjsxy删除账号`).callback(async({context:e,config:t,bot:n,saveConfig:r})=>{let[i,a]=E(t,e.user_id.toString());if(!i){await n.sendMsg(e,a);return}delete t.accounts[e.user_id.toString()],delete t.crons[e.user_id.toString()],l(`wxjsxy_cron_${e.user_id}`),await r(),await n.sendMsg(e,[u.text(`账号删除成功`)])}),P=j.command(`wxjsxy请假`).commander(e=>e().option(`offset`,{alias:`o`,type:`number`,description:`请假日期相对于今天的偏移, 0表示当天`})).callback(async({context:e,options:t,config:n,bot:r})=>{let[i,a]=E(n,e.user_id.toString());if(!i){await r.sendMsg(e,a);return}let{offset:o}=t;if(o===void 0){await r.sendMsg(e,[u.text(`请输入请假日期相对于今天的偏移, 0表示当天:`)]);let t=await r.useMessage(e);if(!t)return;if(o=Number.parseInt(t.raw_message.trim()),Number.isNaN(o)){await r.sendMsg(e,[u.text(`偏移必须是一个数字`)]);return}}let s=await O(n.accounts[e.user_id.toString()],o);await r.sendMsg(e,s)});async function F(e,t){let n=await D(e);if(Array.isArray(n))return n;let r=await C(n,t);if(r.code!==200)return[u.text(`获取请假情况失败, 错误信息: ${JSON.stringify(r)}`)];let i=await Promise.all(r.rows.map(e=>w(n,e.instanceId)));return i.some(e=>e.code!==200)?[u.text(`获取请假详情失败, 错误信息: ${JSON.stringify(i)}`)]:[u.text(`请假情况:
2
2
  `),u.text(r.rows.map((e,t)=>{let n=[`- 申请时间: ${e.processStartTime}`,` 审核状态: ${e.approvaState}`],r=i[t];return r.code===200?(n.push(` 申请时间: ${r.rows.hisTasks[1].processStartTime}`,...r.rows.hisTasks[1].formSchema.formProperties.map(e=>` ${e.name}: ${e.value}`)),n.join(`
3
3
  `)):(n.push(` 获取详情失败: ${JSON.stringify(r)}`),n.join(`
4
- `))}).join(``))]}const F=A.command(`wxjsxy请假情况`).commander(e=>e().option(`page`,{alias:`p`,type:`number`,description:`页码`,default:1}).option(`size`,{alias:`s`,type:`number`,description:`每页数量`,default:1})).callback(async({context:e,options:t,config:n,bot:r})=>{let[i,a]=T(n,e.user_id.toString());if(!i){await r.sendMsg(e,a);return}let o=await P(n.accounts[e.user_id.toString()],{pageNo:t.page,pageSize:t.size});await r.sendMsg(e,o)}),I=A.command(`wxjsxy定时请假`).commander(e=>e().option(`cron`,{alias:`c`,type:`string`,description:`cron表达式`}).option(`offset`,{alias:`o`,type:`number`,description:`请假日期相对于今天的偏移, 0表示当天`})).callback(async({context:e,options:t,config:n,bot:r,saveConfig:i,logger:a})=>{let[o,s]=T(n,e.user_id.toString());if(!o){await r.sendMsg(e,s);return}if(n.crons[e.user_id.toString()]){await r.sendMsg(e,[u.text(`已存在定时请假任务`)]);return}let{cron:c,offset:l}=t;if(!c){await r.sendMsg(e,[u.text(`请输入cron表达式:`),u.text(`cron表达式格式必须为6段, 示例: 0 30 6 * * * 表示每天6点30分`)]);let t=await r.useMessage(e);if(!t)return;c=t.raw_message.trim()}if(c.split(` `).length!==6){await r.sendMsg(e,[u.text(`cron表达式格式错误, 请提供6段表达式.`)]);return}if(l===void 0){await r.sendMsg(e,[u.text(`请输入请假日期相对于今天的偏移, 0表示当天:`)]);let t=await r.useMessage(e);if(!t)return;if(l=Number.parseInt(t.raw_message.trim()),Number.isNaN(l)){await r.sendMsg(e,[u.text(`偏移必须是一个数字`)]);return}}if(!await r.isFriend({user_id:e.user_id})){await r.sendMsg(e,[u.text(`请先添加好友, 才能设置定时请假哦`)]);return}n.crons[e.user_id.toString()]={cron:c,offset:l},await i(),await O(n,r,i,a),await r.sendMsg(e,[u.text(`定时请假设置成功`)])}),L=A.command(`wxjsxy取消定时请假`).callback(async({context:e,config:t,bot:n,saveConfig:r,logger:i})=>{let[a,o]=T(t,e.user_id.toString());if(!a){await n.sendMsg(e,o);return}if(!t.crons[e.user_id.toString()]){await n.sendMsg(e,[u.text(`没有定时请假任务可供取消`)]);return}delete t.crons[e.user_id.toString()],await r(),await O(t,n,r,i),await n.sendMsg(e,[u.text(`定时请假取消成功`)])});export{n as RSAKeyPair,j as addAccountCommand,h as casReq,T as checkHaveAccount,I as cronStartProcessCommand,L as cronStopProcessCommand,M as deleteAccountCommand,g as dyReq,e as encryptedString,v as getCasLoginToken,y as getDyCookie,C as getDyProcessDetail,S as getDyProcessList,b as getDyToken,E as getDyTokenByCas,P as getProcessList,F as getProcessListCommand,_ as loginToCas,A as plugin,x as setDyProcess,t as setMaxDigits,D as startProcess,N as startProcessCommand,k as stopAllCrons,O as syncCrons};
4
+ `))}).join(``))]}const I=j.command(`wxjsxy请假情况`).commander(e=>e().option(`page`,{alias:`p`,type:`number`,description:`页码`,default:1}).option(`size`,{alias:`s`,type:`number`,description:`每页数量`,default:1})).callback(async({context:e,options:t,config:n,bot:r})=>{let[i,a]=E(n,e.user_id.toString());if(!i){await r.sendMsg(e,a);return}let o=await F(n.accounts[e.user_id.toString()],{pageNo:t.page,pageSize:t.size});await r.sendMsg(e,o)}),L=j.command(`wxjsxy定时请假`).commander(e=>e().option(`cron`,{alias:`c`,type:`string`,description:`cron表达式`}).option(`offset`,{alias:`o`,type:`number`,description:`请假日期相对于今天的偏移, 0表示当天`})).callback(async({context:e,options:t,config:n,bot:r,saveConfig:i,logger:a})=>{let[o,s]=E(n,e.user_id.toString());if(!o){await r.sendMsg(e,s);return}if(n.crons[e.user_id.toString()]){await r.sendMsg(e,[u.text(`已存在定时请假任务`)]);return}let{cron:c,offset:l}=t;if(!c){await r.sendMsg(e,[u.text(`请输入cron表达式:`),u.text(`cron表达式格式必须为6段, 示例: 0 30 6 * * * 表示每天6点30分`)]);let t=await r.useMessage(e);if(!t)return;c=t.raw_message.trim()}if(c.split(` `).length!==6){await r.sendMsg(e,[u.text(`cron表达式格式错误, 请提供6段表达式.`)]);return}if(l===void 0){await r.sendMsg(e,[u.text(`请输入请假日期相对于今天的偏移, 0表示当天:`)]);let t=await r.useMessage(e);if(!t)return;if(l=Number.parseInt(t.raw_message.trim()),Number.isNaN(l)){await r.sendMsg(e,[u.text(`偏移必须是一个数字`)]);return}}if(!await r.isFriend({user_id:e.user_id})){await r.sendMsg(e,[u.text(`请先添加好友, 才能设置定时请假哦`)]);return}n.crons[e.user_id.toString()]={cron:c,offset:l},await i(),await k(n,r,i,a),await r.sendMsg(e,[u.text(`定时请假设置成功`)])}),R=j.command(`wxjsxy取消定时请假`).callback(async({context:e,config:t,bot:n,saveConfig:r,logger:i})=>{let[a,o]=E(t,e.user_id.toString());if(!a){await n.sendMsg(e,o);return}if(!t.crons[e.user_id.toString()]){await n.sendMsg(e,[u.text(`没有定时请假任务可供取消`)]);return}delete t.crons[e.user_id.toString()],await r(),await k(t,n,r,i),await n.sendMsg(e,[u.text(`定时请假取消成功`)])});export{n as RSAKeyPair,M as addAccountCommand,g as casReq,h as changeCasAndDyUrl,E as checkHaveAccount,L as cronStartProcessCommand,R as cronStopProcessCommand,N as deleteAccountCommand,_ as dyReq,e as encryptedString,y as getCasLoginToken,b as getDyCookie,w as getDyProcessDetail,C as getDyProcessList,x as getDyToken,D as getDyTokenByCas,F as getProcessList,I as getProcessListCommand,v as loginToCas,j as plugin,S as setDyProcess,t as setMaxDigits,O as startProcess,P as startProcessCommand,A as stopAllCrons,k as syncCrons};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@minato-bot/plugin-wxjsxy",
3
3
  "type": "module",
4
- "version": "2.4.4",
4
+ "version": "2.4.6",
5
5
  "description": "wxjsxy for atri framework",
6
6
  "author": "huan_kong",
7
7
  "license": "MIT",