From 5c7fcd09bd217f82ed87c0c90ed62b0b2ebd51f9 Mon Sep 17 00:00:00 2001 From: Casper Warden <216465704+casperwardensl@users.noreply.github.com> Date: Thu, 19 Nov 2020 15:56:29 +0000 Subject: [PATCH] Add support for sending teleport requests. Closes #33 --- example/testBot.js | 5 ++++ .../commands/CommunicationsCommands.ts | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/example/testBot.js b/example/testBot.js index 640de66..b70bb43 100644 --- a/example/testBot.js +++ b/example/testBot.js @@ -360,6 +360,9 @@ async function connect() // Send a group message await bot.clientCommands.comms.sendGroupMessage(groupKey, 'Test'); + + // "Open" group chat but don't send a message + await bot.clientCommands.comms.startGroupChatSession("f0466f71-abf4-1559-db93-50352d13ae74", ""); } catch (error) { @@ -379,6 +382,8 @@ async function connect() console.log(p.Name); } console.log('========================'); + + await bot.clientCommands.comms.sendTeleport('d1cd5b71-6209-4595-9bf0-771bf689ce00'); } catch (error) { diff --git a/lib/classes/commands/CommunicationsCommands.ts b/lib/classes/commands/CommunicationsCommands.ts index db51fa4..66f860b 100644 --- a/lib/classes/commands/CommunicationsCommands.ts +++ b/lib/classes/commands/CommunicationsCommands.ts @@ -12,6 +12,7 @@ import { PacketFlags } from '../../enums/PacketFlags'; import { GroupChatSessionJoinEvent } from '../../events/GroupChatSessionJoinEvent'; import { ScriptDialogEvent } from '../../events/ScriptDialogEvent'; import Timer = NodeJS.Timer; +import { StartLureMessage } from '../messages/StartLure'; export class CommunicationsCommands extends CommandsBase { @@ -100,6 +101,32 @@ export class CommunicationsCommands extends CommandsBase return await this.circuit.waitForAck(sequenceNo, 10000); } + async sendTeleport(target: UUID | string, message?: string) + { + if (typeof target === 'string') + { + target = new UUID(target); + } + if (message === undefined) + { + message = 'Join me in ' + this.currentRegion.regionName; + } + const p = new StartLureMessage(); + p.AgentData = { + AgentID: this.agent.agentID, + SessionID: this.circuit.sessionID + }; + p.Info = { + LureType: 0, + Message: Utils.StringToBuffer(message) + } + p.TargetData = [{ + TargetID: target + }]; + const sequenceNo = this.circuit.sendMessage(p, PacketFlags.Reliable); + return await this.circuit.waitForAck(sequenceNo, 10000); + } + async stopTypingLocal(): Promise { const cfv = new ChatFromViewerMessage();