mirror of
https://github.com/icewind1991/mx-puppet-steam.git
synced 2026-06-03 09:34:13 +02:00
add support for ephemeral events
This commit is contained in:
parent
a5526b440f
commit
21e919167c
3 changed files with 45 additions and 1 deletions
|
|
@ -88,6 +88,9 @@ async function run() {
|
|||
puppet.on("puppetDelete", steam.deletePuppet.bind(steam));
|
||||
puppet.on("message", steam.handleMatrixMessage.bind(steam));
|
||||
puppet.on("image", steam.handleMatrixImage.bind(steam));
|
||||
puppet.on("typing", steam.handleMatrixTyping.bind(steam));
|
||||
puppet.on("read", steam.handleMatrixRead.bind(steam));
|
||||
puppet.on("presence", steam.handleMatrixPresence.bind(steam));
|
||||
puppet.setCreateUserHook(steam.createUser.bind(steam));
|
||||
puppet.setListUsersHook(steam.listUsers.bind(steam));
|
||||
puppet.setGetDmRoomIdHook(steam.getDmRoomId.bind(steam));
|
||||
|
|
|
|||
32
src/steam.ts
32
src/steam.ts
|
|
@ -9,7 +9,7 @@ import {
|
|||
IRetList,
|
||||
Log,
|
||||
PuppetBridge,
|
||||
Util,
|
||||
Util, ISendingUser, IPresenceEvent,
|
||||
} from "mx-puppet-bridge";
|
||||
import * as SteamUser from "steam-user";
|
||||
import * as SteamCommunity from "steamcommunity";
|
||||
|
|
@ -495,4 +495,34 @@ export class Steam {
|
|||
avatarUrl: chat_room_group.group_summary.chat_group_avatar_url,
|
||||
};
|
||||
}
|
||||
|
||||
public handleMatrixTyping(room: IRemoteRoom, typing: boolean) {
|
||||
const p = this.puppets[room.puppetId];
|
||||
let steamId = this.getRoomSteamId(room);
|
||||
if (steamId && typing) {
|
||||
p.client.chat.sendFriendTyping(steamId);
|
||||
}
|
||||
}
|
||||
|
||||
public handleMatrixRead(room: IRemoteRoom, eventId: string) {
|
||||
const p = this.puppets[room.puppetId];
|
||||
let steamId = this.getRoomSteamId(room);
|
||||
if (steamId) {
|
||||
p.client.chat.ackFriendMessage(steamId, new Date());
|
||||
} else {
|
||||
let [groupId, chatId] = this.parseChatRoomId(room.roomId);
|
||||
p.client.chat.ackChatMessage(groupId, chatId, new Date());
|
||||
}
|
||||
}
|
||||
|
||||
public handleMatrixPresence(puppetId, presence: IPresenceEvent) {
|
||||
const p = this.puppets[puppetId];
|
||||
if (presence.presence === "offline") {
|
||||
p.client.setPersona(EPersonaState.Offline);
|
||||
} else if (presence.presence === "online") {
|
||||
p.client.setPersona(EPersonaState.Online);
|
||||
} else if (presence.presence === "unavailable") {
|
||||
p.client.setPersona(EPersonaState.Away);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue