add listusers

This commit is contained in:
Robin Appelman 2020-05-09 13:41:48 +02:00
commit cdfaf57cb9
3 changed files with 13 additions and 0 deletions

View file

@ -10,6 +10,8 @@ Matrix <-> Steam puppeting bridge based on [mx-puppet-bridge](https://github.com
- [x] steam -> matrix typing notifications - [x] steam -> matrix typing notifications
- [x] online/offline status - [x] online/offline status
- [x] retrieve nickname and avatar from steam - [x] retrieve nickname and avatar from steam
- [x] listing of steam users
- [ ] listing of steam group chats
## Linking ## Linking

View file

@ -91,6 +91,7 @@ async function run() {
puppet.on("video", steam.handleMatrixVideo.bind(steam)); puppet.on("video", steam.handleMatrixVideo.bind(steam));
puppet.setCreateUserHook(steam.createUser.bind(steam)); puppet.setCreateUserHook(steam.createUser.bind(steam));
// puppet.setGetUserIdsInRoomHook(steam.getUserIdsInRoom.bind(steam)); // puppet.setGetUserIdsInRoomHook(steam.getUserIdsInRoom.bind(steam));
puppet.setListUsersHook(steam.listUsers.bind(steam));
puppet.setGetDescHook(async (puppetId: number, data: any): Promise<string> => { puppet.setGetDescHook(async (puppetId: number, data: any): Promise<string> => {
let s = "Steam"; let s = "Steam";
if (data.screenName) { if (data.screenName) {

View file

@ -12,6 +12,7 @@ import * as SteamID from "steamid";
import {EPersonaState} from "./enum"; import {EPersonaState} from "./enum";
import {MatrixPresence} from "mx-puppet-bridge/lib/src/presencehandler"; import {MatrixPresence} from "mx-puppet-bridge/lib/src/presencehandler";
import {AppInfo, IIncomingFriendMessage, IPersona} from "./interfaces"; import {AppInfo, IIncomingFriendMessage, IPersona} from "./interfaces";
import {IRetList} from "mx-puppet-bridge/src/interfaces";
const log = new Log("MatrixPuppet:Steam"); const log = new Log("MatrixPuppet:Steam");
@ -288,6 +289,15 @@ export class Steam {
}; };
} }
public async listUsers(puppetId: number): Promise<IRetList[]> {
let friends = this.puppets[puppetId].client.users as {[steamId: string]: IPersona};
return Object.keys(friends).map((steamId) => ({
id: steamId,
name: friends[steamId].player_name
}));
}
// public async getUserIdsInRoom(room: IRemoteRoom): Promise<Set<string> | null> { // public async getUserIdsInRoom(room: IRemoteRoom): Promise<Set<string> | null> {
// const p = this.puppets[room.puppetId]; // const p = this.puppets[room.puppetId];
// const client: TalkClient = p.client; // const client: TalkClient = p.client;