mirror of
https://github.com/icewind1991/mx-puppet-steam.git
synced 2026-06-03 17:44:09 +02:00
parent
3656419a80
commit
18d411e324
4 changed files with 19 additions and 20 deletions
|
|
@ -46,7 +46,7 @@ async function apngToGif(sourceUrl: string): Promise<Buffer> {
|
|||
return output.getContents();
|
||||
}
|
||||
|
||||
async function formatBBCode(steam: Steam, puppetId: number, node: BBCodeNode, fromSteamId?: SteamID): Promise<ImageMessage | TextMessage> {
|
||||
async function formatBBCode(steam: Steam, puppetId: number, node: BBCodeNode, message: IIncomingFriendMessage | IIncomingChatMessage): Promise<ImageMessage | TextMessage> {
|
||||
if (node.tag === 'img') {
|
||||
return {
|
||||
kind: "image",
|
||||
|
|
@ -72,7 +72,7 @@ async function formatBBCode(steam: Steam, puppetId: number, node: BBCodeNode, fr
|
|||
} else if (node.tag === 'gameinvite') {
|
||||
let game = await steam.getProduct(puppetId, node.attrs['appid']);
|
||||
|
||||
if (steam.getSteamId(puppetId) === fromSteamId) {
|
||||
if (message['local_echo']) {
|
||||
return {
|
||||
kind: "text",
|
||||
body: "",
|
||||
|
|
@ -92,12 +92,11 @@ export async function exportMessageForSending(
|
|||
steam: Steam,
|
||||
puppetId: number,
|
||||
message: IIncomingFriendMessage | IIncomingChatMessage,
|
||||
fromSteamId?: SteamID
|
||||
): Promise<(TextMessage | ImageMessage)[]> {
|
||||
if (message.message_bbcode_parsed) {
|
||||
let parts = await Promise.all(message.message_bbcode_parsed.map(node => {
|
||||
if (isBBCode(node)) {
|
||||
return formatBBCode(steam, puppetId, node, message['steamid_friend']);
|
||||
return formatBBCode(steam, puppetId, node, message);
|
||||
} else {
|
||||
return {kind: "text", body: node} as TextMessage;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue