koishi-plugin-hhs-huatu 0.3.3 → 0.3.4

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/lib/index.js CHANGED
@@ -1873,7 +1873,7 @@ var MembershipSystem = class {
1873
1873
  let message = "【会员到期提醒】\n以下会员即将到期:\n\n";
1874
1874
  expiringMembers.forEach((member, index) => {
1875
1875
  const expireDate = new Date(this.userData[member.userId].membershipExpiry).toLocaleString();
1876
- message += `${index + 1}. 用户ID: ${member.userId}
1876
+ message += `${index + 1}. @${member.userId}
1877
1877
  剩余时间: ${member.remainingHours} 小时
1878
1878
  到期时间: ${expireDate}
1879
1879
 
@@ -1886,7 +1886,7 @@ var MembershipSystem = class {
1886
1886
  for (const bot of bots) {
1887
1887
  try {
1888
1888
  await bot.sendMessage(groupId, message);
1889
- this.ctx.logger.info(`已向群组 ${groupId} 发送会员到期提醒`);
1889
+ this.ctx.logger.info(`已向群组 ${groupId} 发送会员到期提醒(包含@功能)`);
1890
1890
  sent = true;
1891
1891
  break;
1892
1892
  } catch (err) {
@@ -1940,6 +1940,28 @@ var MembershipSystem = class {
1940
1940
  scheduleReminder();
1941
1941
  }
1942
1942
  }
1943
+ // 给所有会员增加天数
1944
+ async addDaysToAllMembers(days) {
1945
+ if (!this.config.membershipEnabled) {
1946
+ return { success: false, count: 0, message: "会员系统未启用" };
1947
+ }
1948
+ const now = Date.now();
1949
+ let updatedCount = 0;
1950
+ const daysInMs = days * 24 * 60 * 60 * 1e3;
1951
+ for (const userId in this.userData) {
1952
+ const user = this.userData[userId];
1953
+ if (user.isMember && user.membershipExpiry > now) {
1954
+ user.membershipExpiry += daysInMs;
1955
+ updatedCount++;
1956
+ this.ctx.logger.info(`已为会员 ${userId} 增加 ${days} 天,到期时间:${new Date(user.membershipExpiry).toLocaleString()}`);
1957
+ }
1958
+ }
1959
+ if (updatedCount > 0) {
1960
+ await this.saveUserData();
1961
+ }
1962
+ const message = updatedCount > 0 ? `✅ 成功为 ${updatedCount} 位会员增加 ${days} 天会员时长` : "⚠️ 当前没有有效会员可增加天数";
1963
+ return { success: true, count: updatedCount, message };
1964
+ }
1943
1965
  // 检查并重置每日使用次数
1944
1966
  checkAndResetDailyUsage(userId) {
1945
1967
  if (!this.userData[userId]) {
@@ -3524,13 +3546,19 @@ function apply(ctx, config) {
3524
3546
  ]);
3525
3547
  });
3526
3548
  if (config.memberDebugCommandEnabled) {
3527
- ctx.command("novelai.member-debug", "会员系统调试指令").userFields(["authority"]).alias("会员调试").option("cleanup", "-c 立即执行会员信息清理").option("remind", "-r 立即执行会员到期提醒").option("status", "-s 查看定时任务状态").option("resetUsage", "-u <userId:string> 重置指定用户的使用次数").action(async ({ session, options: options2 }) => {
3549
+ ctx.command("novelai.member-debug", "会员系统调试指令").userFields(["authority"]).alias("会员调试").option("cleanup", "-c 立即执行会员信息清理").option("remind", "-r 立即执行会员到期提醒").option("status", "-s 查看定时任务状态").option("resetUsage", "-u <userId:string> 重置指定用户的使用次数").option("addDaysAll", "-a <days:number> 给所有会员增加天数").action(async ({ session, options: options2 }) => {
3528
3550
  if (session.user.authority < config.memberDebugCommandAuthLv) {
3529
3551
  return `权限不足,需要权限等级 ${config.memberDebugCommandAuthLv} 或以上`;
3530
3552
  }
3531
3553
  if (!config.membershipEnabled) {
3532
3554
  return "会员系统未启用";
3533
3555
  }
3556
+ if (options2.addDaysAll !== void 0) {
3557
+ const days = options2.addDaysAll;
3558
+ await session.send(`正在为所有会员增加 ${days} 天会员时长...`);
3559
+ const result = await membershipSystem.addDaysToAllMembers(days);
3560
+ return result.message;
3561
+ }
3534
3562
  if (options2.resetUsage) {
3535
3563
  const targetId = options2.resetUsage;
3536
3564
  if (!userData[targetId]) {
@@ -3642,7 +3670,7 @@ function apply(ctx, config) {
3642
3670
  await membershipSystem.checkAndRemindExpiringMembers();
3643
3671
  return "✅ 提醒完成!请查看控制台日志获取详细信息。";
3644
3672
  }
3645
- return "请使用以下选项:\n-c 立即执行会员信息清理\n-r 立即执行会员到期提醒\n-s 查看定时任务状态\n-u 重置指定用户的使用次数";
3673
+ return "请使用以下选项:\n-c 立即执行会员信息清理\n-r 立即执行会员到期提醒\n-s 查看定时任务状态\n-u 重置指定用户的使用次数\n-a <天数> 给所有会员增加天数";
3646
3674
  });
3647
3675
  }
3648
3676
  if (config.directorToolsEnabled !== false) {
@@ -17,6 +17,11 @@ export declare class MembershipSystem {
17
17
  checkAndRemindExpiringMembers(): Promise<void>;
18
18
  private setupCleanupTask;
19
19
  private setupReminderTask;
20
+ addDaysToAllMembers(days: number): Promise<{
21
+ success: boolean;
22
+ count: number;
23
+ message: string;
24
+ }>;
20
25
  checkAndResetDailyUsage(userId: string): void;
21
26
  canUseDrawing(userId: string, session: Session): boolean | string;
22
27
  incrementUsage(userId: string, drawCount?: number): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-hhs-huatu",
3
3
  "description": "Generate images by diffusion models",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [