2021-12-18 16:58:23 +00:00
|
|
|
import { IntentMock } from "./IntentMock";
|
|
|
|
|
|
|
|
export class AppserviceMock {
|
2023-01-16 15:58:23 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
public readonly intentMap = new Map<string, any>();
|
2023-01-13 10:32:09 -05:00
|
|
|
public readonly botIntent = IntentMock.create(`@bot:example.com`);
|
2023-03-17 16:38:39 +00:00
|
|
|
public namespace = "@hookshot_";
|
|
|
|
|
2021-12-18 16:58:23 +00:00
|
|
|
static create(){
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
return new this() as any;
|
|
|
|
}
|
|
|
|
|
|
|
|
get botUserId() {
|
2023-01-13 10:32:09 -05:00
|
|
|
return this.botIntent.userId;
|
2021-12-18 16:58:23 +00:00
|
|
|
}
|
|
|
|
|
2022-05-12 11:28:55 +01:00
|
|
|
get botClient() {
|
|
|
|
return this.botIntent.underlyingClient;
|
|
|
|
}
|
|
|
|
|
2023-01-13 10:32:09 -05:00
|
|
|
public getIntentForUserId(userId: string) {
|
2023-01-16 15:58:23 +01:00
|
|
|
let intent = this.intentMap.get(userId);
|
|
|
|
if (intent) {
|
|
|
|
return intent;
|
|
|
|
}
|
|
|
|
intent = IntentMock.create(userId);
|
|
|
|
this.intentMap.set(userId, intent);
|
|
|
|
return intent;
|
2021-12-18 16:58:23 +00:00
|
|
|
}
|
2023-03-17 16:38:39 +00:00
|
|
|
|
|
|
|
public isNamespacedUser(userId: string) {
|
|
|
|
return userId.startsWith(this.namespace);
|
|
|
|
}
|
2021-12-18 16:58:23 +00:00
|
|
|
}
|