mirror of
https://github.com/icewind1991/mx-puppet-steam.git
synced 2026-06-03 17:44:09 +02:00
support initiating 1-1 chats from matrix
This commit is contained in:
parent
cdfaf57cb9
commit
3aa54d0cd2
2 changed files with 40 additions and 1 deletions
|
|
@ -92,6 +92,8 @@ async function run() {
|
|||
puppet.setCreateUserHook(steam.createUser.bind(steam));
|
||||
// puppet.setGetUserIdsInRoomHook(steam.getUserIdsInRoom.bind(steam));
|
||||
puppet.setListUsersHook(steam.listUsers.bind(steam));
|
||||
puppet.setGetDmRoomIdHook(steam.getDmRoomId.bind(steam));
|
||||
puppet.setCreateRoomHook(steam.createRoom.bind(steam));
|
||||
puppet.setGetDescHook(async (puppetId: number, data: any): Promise<string> => {
|
||||
let s = "Steam";
|
||||
if (data.screenName) {
|
||||
|
|
|
|||
37
src/steam.ts
37
src/steam.ts
|
|
@ -298,6 +298,43 @@ export class Steam {
|
|||
}));
|
||||
}
|
||||
|
||||
public async getDmRoomId(user: IRemoteUser): Promise<string | null> {
|
||||
log.info(`Got request for dm room id for ${user.userId}`);
|
||||
|
||||
if (!this.puppets[user.puppetId]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return user.userId;
|
||||
}
|
||||
|
||||
public async createRoom(room: IRemoteRoom): Promise<IRemoteRoom | null> {
|
||||
const p = this.puppets[room.puppetId];
|
||||
if (!p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
let steamId = new SteamID(room.roomId);
|
||||
if (!steamId.isValid()) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
let persona = await this.getPersona(p, steamId);
|
||||
|
||||
log.info(`Got request to room user ${room.roomId}`);
|
||||
return {
|
||||
puppetId: room.puppetId,
|
||||
roomId: room.roomId,
|
||||
isDirect: true,
|
||||
topic: persona.player_name
|
||||
};
|
||||
} catch (e) {
|
||||
await this.bridge.sendStatusMessage(room.puppetId, `Creating group room chats is currently not supported`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// public async getUserIdsInRoom(room: IRemoteRoom): Promise<Set<string> | null> {
|
||||
// const p = this.puppets[room.puppetId];
|
||||
// const client: TalkClient = p.client;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue