koishi-plugin-aakook 0.2.0 → 0.3.0

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/guard.d.ts CHANGED
@@ -27,11 +27,22 @@ export interface ExecStats {
27
27
  problems: string[];
28
28
  /** AA "cannot tell" notes, once per (person, reason) a day: patrol summary and log only. */
29
29
  notes: string[];
30
+ /** Corp roles (军团身份组): given / taken back / newly made (in report mode: would be). */
31
+ corpGrants: number;
32
+ corpRevokes: number;
33
+ corpCreates: number;
34
+ /** Corp channel groups newly made (in report mode: would be). */
35
+ corpGroups: number;
36
+ /** Corp tickers whose role was not made this run (limit per run); they are retried next round. */
37
+ corpDeferred: Set<string>;
38
+ /** Corp tickers whose role must not be made, claimed or given this run (blocked, deferred or unsafe); asked once per run. */
39
+ corpSkip: Set<string>;
30
40
  /** New write failures (first time recorded): the only lines pushed to ops outside a patrol. */
31
41
  alerts: string[];
32
42
  /** The round was cut short (KOOK offline). */
33
43
  aborted: boolean;
34
44
  }
45
+ export declare const emptyStats: () => ExecStats;
35
46
  export declare class Guard implements GuardControl {
36
47
  private ctx;
37
48
  private config;
@@ -55,6 +66,7 @@ export declare class Guard implements GuardControl {
55
66
  private roleCache;
56
67
  private failures;
57
68
  private failuresSnapshot;
69
+ private corpGroupReset;
58
70
  private notesSeen;
59
71
  private master;
60
72
  private notesDirty;
@@ -69,6 +81,14 @@ export declare class Guard implements GuardControl {
69
81
  private deferred;
70
82
  private names;
71
83
  private lastPatrolText;
84
+ /** Corp tickers whose role is being made right now (one creation per ticker at a time). */
85
+ private corpCreating;
86
+ /** Serialises changes of the stored corp mapping. */
87
+ private corpMapChain;
88
+ /** Corp roles are made / claimed one after the other (the role count and the 95 limit stay right). */
89
+ private corpMakeChain;
90
+ /** When roles were made by a non-patrol path (last 24 hours). */
91
+ private corpEventCreates;
72
92
  constructor(ctx: Context, config: Config, options?: GuardOptions);
73
93
  private load;
74
94
  get paused(): boolean;
@@ -122,6 +142,49 @@ export declare class Guard implements GuardControl {
122
142
  /** Send one reminder privately; returns true when it was delivered. Failed `new` / `last` ones go to `pings`. */
123
143
  private remind;
124
144
  private kickOne;
145
+ private readCorpMap;
146
+ /** Change the stored mapping one change at a time (read, change, write), so two tickers never overwrite each other. */
147
+ private updateCorpMap;
148
+ /** Role ids the plugin manages in other ways (never claimed as a corp role). */
149
+ private otherManagedRoleIds;
150
+ /**
151
+ * Decide the corp role work of one `execute` call: read the mapping, drop mapped roles that are gone (patrol only: the
152
+ * role list is read again to be sure, and a big "everything vanished" is not believed), leave out mapped roles that
153
+ * became unsafe, work out per person what to give / take back, and stop everything (alert) when the AA name card
154
+ * format looks changed or too many corp roles would be taken back at once. Null = corp roles are off or could not be prepared.
155
+ * In report mode nothing is written; the counts and the lines about roles that would be made / claimed go into `stats`.
156
+ */
157
+ private prepareCorp;
158
+ /** Report mode: say what sync would do about roles (claim a same-name role, make a new one, hit the limit). */
159
+ private reportCorp;
160
+ /** Take back old corp roles, then give the right one (made first when it does not exist yet). */
161
+ private applyCorp;
162
+ /** The role id for a corp ticker: from the mapping, a same-name role claimed, or a new one. Null when it cannot be had now. */
163
+ private ensureCorpRole;
164
+ private makeCorpRole;
165
+ private readCorpChannels;
166
+ private corpGroupSummary;
167
+ /** Linked members per ticker who hold the corp role now or are about to (this run's decision). */
168
+ private corpHolders;
169
+ /** A "no" from KOOK on a channel call most likely means the bot lacks a permission: say which. */
170
+ private channelCall;
171
+ /**
172
+ * Corp channel groups: one category per corp (hidden from everyone but the corp role and the bot) with the template's
173
+ * channels in it. Patrol only. Never deletes anything. In report mode it only says what would be made.
174
+ * Nothing is written when the channel list could not be read (an unreadable list is not "the owner deleted it").
175
+ * While the bot cannot set permissions (or a group is not hidden yet) no new group is made: a new category is
176
+ * visible to everybody until its permissions are set.
177
+ */
178
+ private prepareCorpChannels;
179
+ /**
180
+ * Make (or finish) one group: the category, its permissions, then every template channel with its permissions.
181
+ * Every id is saved as soon as it exists, so a reload or a failure in the middle never leads to a second group;
182
+ * a later patrol only makes what is missing. The category is hidden before any channel is made in it.
183
+ * Before asking for a category a `pending` note is saved, and a channel is looked for by name in its category first,
184
+ * so an answer that got lost (timeout) does not lead to a duplicate or to a "same name, hands off" take-over.
185
+ * A round counts against the repair limit only when something was really sent to KOOK.
186
+ */
187
+ private fillCorpGroup;
125
188
  /** Patrol now, or after the one that is running. Resolves with the summary text. */
126
189
  requestPatrol(): Promise<string>;
127
190
  /** Same as `requestPatrol` (kept as the plain name for tests and callers). */
@@ -129,6 +192,8 @@ export declare class Guard implements GuardControl {
129
192
  /** Resolves when no patrol is running (does not start one). */
130
193
  patrolIdle(): Promise<void>;
131
194
  private patrolOnce;
195
+ /** A whitelist role that does not exist (typo, other server, deleted and recreated) protects nobody: say so. */
196
+ private checkWhitelistRoles;
132
197
  private patrolSummary;
133
198
  pollEvents(): Promise<void>;
134
199
  /** First run: only remember the newest event id, then do a full patrol. */
@@ -158,12 +223,16 @@ export declare class Guard implements GuardControl {
158
223
  kind: 'kook' | 'qq';
159
224
  id: string;
160
225
  }, actor: string): Promise<string>;
226
+ /** One line saying which whitelist the person is on (nothing when none). Roles come from a live lookup. */
227
+ private whitelistLine;
161
228
  inspect(target: {
162
229
  kind: 'kook' | 'qq';
163
230
  id: string;
164
231
  }, options?: {
165
232
  full?: boolean;
166
233
  }): Promise<string>;
234
+ /** Lines for kookaa.check: the corp ticker from the card, and the corp roles the person holds (live lookup). */
235
+ private corpInspectLines;
167
236
  configErrorsText(): string;
168
237
  statusReport(): Promise<string>;
169
238
  }