[BREAKING CHANGES] - Add new commands module for the Friends list, add new events for friends online/offline, friend rights management, friend map lookup

This commit is contained in:
Casper Warden
2018-10-12 14:34:43 +01:00
parent 375abc433e
commit 2a0c4dc3e8
86 changed files with 1406 additions and 330 deletions

2
dist/Bot.d.ts vendored
View File

@@ -4,6 +4,7 @@ import { Region } from './classes/Region';
import { ClientEvents } from './classes/ClientEvents';
import { ClientCommands } from './classes/ClientCommands';
import { BotOptionFlags } from './enums/BotOptionFlags';
import { UUID } from './classes/UUID';
import { Vector3 } from './classes/Vector3';
export declare class Bot {
private loginParams;
@@ -30,5 +31,6 @@ export declare class Bot {
private kicked;
private disconnected;
close(): Promise<void>;
agentID(): UUID;
connectToSim(requested: boolean): Promise<void>;
}

3
dist/Bot.js vendored
View File

@@ -146,6 +146,9 @@ class Bot {
this.disconnected(true, 'Logout completed');
});
}
agentID() {
return this.agent.agentID;
}
connectToSim(requested) {
return __awaiter(this, void 0, void 0, function* () {
this.agent.setCurrentRegion(this.currentRegion);

2
dist/Bot.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -122,7 +122,7 @@ class Circuit {
const timeoutFunc = () => {
if (handleObj.subscription !== null) {
handleObj.subscription.unsubscribe();
const err = new TimeoutError_1.TimeoutError('Timeout waiting for message of type ' + id);
const err = new TimeoutError_1.TimeoutError('Timeout waiting for message of type ' + Message_1.Message[id]);
err.timeout = true;
err.waitingForMessage = id;
reject(err);

File diff suppressed because one or more lines are too long

View File

@@ -11,12 +11,14 @@ import { AgentCommands } from './commands/AgentCommands';
import { GroupCommands } from './commands/GroupCommands';
import { InventoryCommands } from './commands/InventoryCommands';
import { ParcelCommands } from './commands/ParcelCommands';
import { FriendCommands } from './commands/FriendCommands';
export declare class ClientCommands {
network: NetworkCommands;
asset: AssetCommands;
teleport: TeleportCommands;
region: RegionCommands;
parcel: ParcelCommands;
friends: FriendCommands;
grid: GridCommands;
comms: CommunicationsCommands;
agent: AgentCommands;

View File

@@ -10,6 +10,7 @@ const AgentCommands_1 = require("./commands/AgentCommands");
const GroupCommands_1 = require("./commands/GroupCommands");
const InventoryCommands_1 = require("./commands/InventoryCommands");
const ParcelCommands_1 = require("./commands/ParcelCommands");
const FriendCommands_1 = require("./commands/FriendCommands");
class ClientCommands {
constructor(region, agent, bot) {
this.network = new NetworkCommands_1.NetworkCommands(region, agent, bot);
@@ -18,6 +19,7 @@ class ClientCommands {
this.region = new RegionCommands_1.RegionCommands(region, agent, bot);
this.parcel = new ParcelCommands_1.ParcelCommands(region, agent, bot);
this.grid = new GridCommands_1.GridCommands(region, agent, bot);
this.friends = new FriendCommands_1.FriendCommands(region, agent, bot);
this.comms = new CommunicationsCommands_1.CommunicationsCommands(region, agent, bot);
this.agent = new AgentCommands_1.AgentCommands(region, agent, bot);
this.group = new GroupCommands_1.GroupCommands(region, agent, bot);
@@ -34,6 +36,7 @@ class ClientCommands {
this.agent.shutdown();
this.group.shutdown();
this.inventory.shutdown();
this.friends.shutdown();
}
}
exports.ClientCommands = ClientCommands;

View File

@@ -1 +1 @@
{"version":3,"file":"ClientCommands.js","sourceRoot":"","sources":["../../lib/classes/ClientCommands.ts"],"names":[],"mappings":";;AAGA,gEAA2D;AAC3D,4DAAuD;AACvD,kEAA6D;AAC7D,8DAAyD;AACzD,0DAAqD;AACrD,8EAAyE;AACzE,4DAAuD;AACvD,4DAAuD;AACvD,oEAA+D;AAC/D,8DAAyD;AAEzD,MAAa,cAAc;IAavB,YAAY,MAAc,EAAE,KAAY,EAAE,GAAQ;QAE9C,IAAI,CAAC,OAAO,GAAG,IAAI,iCAAe,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,mCAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,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AAE,GAAG,CAAC,CAAC;IAC/D,CAAC;IACD,QAAQ;QAEJ,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;CACJ;AA1CD,wCA0CC"}

View File

@@ -1,4 +1,4 @@
import { ChatEvent, DisconnectEvent, FriendRequestEvent, FriendResponseEvent, GroupChatEvent, GroupChatSessionAgentListEvent, GroupChatSessionJoinEvent, GroupInviteEvent, InstantMessageEvent, InventoryOfferedEvent, LureEvent, TeleportEvent, ScriptDialogEvent, EventQueueStateChangeEvent } from '..';
import { ChatEvent, DisconnectEvent, FriendRequestEvent, FriendResponseEvent, GroupChatEvent, GroupChatSessionAgentListEvent, GroupChatSessionJoinEvent, GroupInviteEvent, InstantMessageEvent, InventoryOfferedEvent, LureEvent, TeleportEvent, ScriptDialogEvent, EventQueueStateChangeEvent, FriendOnlineEvent, FriendRightsEvent, FriendRemovedEvent } from '..';
import { Subject } from 'rxjs/internal/Subject';
export declare class ClientEvents {
onNearbyChat: Subject<ChatEvent>;
@@ -16,4 +16,7 @@ export declare class ClientEvents {
onFriendResponse: Subject<FriendResponseEvent>;
onScriptDialog: Subject<ScriptDialogEvent>;
onEventQueueStateChange: Subject<EventQueueStateChangeEvent>;
onFriendOnline: Subject<FriendOnlineEvent>;
onFriendRights: Subject<FriendRightsEvent>;
onFriendRemoved: Subject<FriendRemovedEvent>;
}

View File

@@ -18,6 +18,9 @@ class ClientEvents {
this.onFriendResponse = new Subject_1.Subject();
this.onScriptDialog = new Subject_1.Subject();
this.onEventQueueStateChange = new Subject_1.Subject();
this.onFriendOnline = new Subject_1.Subject();
this.onFriendRights = new Subject_1.Subject();
this.onFriendRemoved = new Subject_1.Subject();
}
}
exports.ClientEvents = ClientEvents;

View File

@@ -1 +1 @@
{"version":3,"file":"ClientEvents.js","sourceRoot":"","sources":["../../lib/classes/ClientEvents.ts"],"names":[],"mappings":";;AAgBA,mDAA8C;AAG9C,MAAa,YAAY;IAAzB;QAEI,iBAAY,GAAuB,IAAI,iBAAO,EAAa,CAAC;QAC5D,qBAAgB,GAAiC,IAAI,iBAAO,EAAuB,CAAC;QACpF,kBAAa,GAA8B,IAAI,iBAAO,EAAoB,CAAC;QAC3E,oBAAe,GAAgC,IAAI,iBAAO,EAAsB,CAAC;QACjF,uBAAkB,GAAmC,IAAI,iBAAO,EAAyB,CAAC;QAC1F,WAAM,GAAuB,IAAI,iBAAO,EAAa,CAAC;QACtD,oBAAe,GAA2B,IAAI,iBAAO,EAAiB,CAAC;QACvE,mBAAc,GAA8B,IAAI,iBAAO,EAAmB,CAAC;QAC3E,qBAAgB,GAAoB,IAAI,iBAAO,EAAU,CAAC;QAC1D,gBAAW,GAA4B,IAAI,iBAAO,EAAkB,CAAC;QACrE,2BAAsB,GAAuC,IAAI,iBAAO,EAA6B,CAAC;QACtG,+BAA0B,GAA4C,IAAI,iBAAO,EAAkC,CAAC;QACpH,qBAAgB,GAAiC,IAAI,iBAAO,EAAuB,CAAC;QACpF,mBAAc,GAA+B,IAAI,iBAAO,EAAqB,CAAC;QAC9E,4BAAuB,GAAwC,IAAI,iBAAO,EAA8B,CAAC;IAC7G,CAAC;CAAA;AAjBD,oCAiBC"}
{"version":3,"file":"ClientEvents.js","sourceRoot":"","sources":["../../lib/classes/ClientEvents.ts"],"names":[],"mappings":";;AAkBA,mDAA8C;AAG9C,MAAa,YAAY;IAAzB;QAEI,iBAAY,GAAuB,IAAI,iBAAO,EAAa,CAAC;QAC5D,qBAAgB,GAAiC,IAAI,iBAAO,EAAuB,CAAC;QACpF,kBAAa,GAA8B,IAAI,iBAAO,EAAoB,CAAC;QAC3E,oBAAe,GAAgC,IAAI,iBAAO,EAAsB,CAAC;QACjF,uBAAkB,GAAmC,IAAI,iBAAO,EAAyB,CAAC;QAC1F,WAAM,GAAuB,IAAI,iBAAO,EAAa,CAAC;QACtD,oBAAe,GAA2B,IAAI,iBAAO,EAAiB,CAAC;QACvE,mBAAc,GAA8B,IAAI,iBAAO,EAAmB,CAAC;QAC3E,qBAAgB,GAAoB,IAAI,iBAAO,EAAU,CAAC;QAC1D,gBAAW,GAA4B,IAAI,iBAAO,EAAkB,CAAC;QACrE,2BAAsB,GAAuC,IAAI,iBAAO,EAA6B,CAAC;QACtG,+BAA0B,GAA4C,IAAI,iBAAO,EAAkC,CAAC;QACpH,qBAAgB,GAAiC,IAAI,iBAAO,EAAuB,CAAC;QACpF,mBAAc,GAA+B,IAAI,iBAAO,EAAqB,CAAC;QAC9E,4BAAuB,GAAwC,IAAI,iBAAO,EAA8B,CAAC;QACzG,mBAAc,GAA+B,IAAI,iBAAO,EAAqB,CAAC;QAC9E,mBAAc,GAA+B,IAAI,iBAAO,EAAqB,CAAC;QAC9E,oBAAe,GAAgC,IAAI,iBAAO,EAAsB,CAAC;IACrF,CAAC;CAAA;AApBD,oCAoBC"}

View File

@@ -22,6 +22,17 @@ class IPAddress {
if (ipaddr.isValid(buf)) {
this.ip = ipaddr.parse(buf);
}
else {
throw new Error('Invalid IP address');
}
}
}
else {
if (ipaddr.isValid(buf)) {
this.ip = ipaddr.parse(buf);
}
else {
throw new Error('Invalid IP address');
}
}
}

View File

@@ -1 +1 @@
{"version":3,"file":"IPAddress.js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C/B;qBAED;oBACI,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;iBACzC;aACJ;SACJ;QACD,OAAO,MAAM,EACb;YACI,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SACrC;IACL,CAAC;IAtDD,MAAM,CAAC,IAAI;QAEP,OAAO,IAAI,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAoDD,aAAa,CAAC,GAAW,EAAE,GAAW;QAElC,MAAM,KAAK,GAAe,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;QAChD,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAChC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAChC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAChC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;CACJ;AAnED,8BAmEC"}

View File

@@ -109,7 +109,8 @@ class Region {
this.xCoordinate = region.X;
this.yCoordinate = region.Y;
this.mapImage = region.MapImageID;
this.regionHandle = Utils_1.Utils.RegionCoordinatesToHandle(this.xCoordinate, this.yCoordinate);
const globalPos = Utils_1.Utils.RegionCoordinatesToHandle(this.xCoordinate, this.yCoordinate);
this.regionHandle = globalPos.regionHandle;
return FilterResponse_1.FilterResponse.Finish;
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,6 @@
/// <reference types="node" />
import * as Long from 'long';
import { GlobalPosition } from '..';
export declare class Utils {
static StringToBuffer(str: string): Buffer;
static BufferToStringSimple(buf: Buffer, startPos?: number): string;
@@ -7,7 +8,7 @@ export declare class Utils {
readLength: number;
result: string;
};
static RegionCoordinatesToHandle(regionX: number, regionY: number): Long;
static RegionCoordinatesToHandle(regionX: number, regionY: number): GlobalPosition;
static HTTPAssetTypeToInventoryType(HTTPAssetType: string): "" | "script" | "object" | "texture" | "sound" | "animation" | "gesture" | "landmark" | "callcard" | "wearable" | "notecard" | "category" | "mesh";
static UInt16ToFloat(val: number, lower: number, upper: number): number;
static Base64EncodeString(str: string): string;

15
dist/classes/Utils.js vendored
View File

@@ -44,9 +44,18 @@ class Utils {
};
}
static RegionCoordinatesToHandle(regionX, regionY) {
regionX = Math.floor(regionX / 256) * 256;
regionY = Math.floor(regionY / 256) * 256;
return new Long(regionY, regionX);
const realRegionX = Math.floor(regionX / 256) * 256;
const realRegionY = Math.floor(regionY / 256) * 256;
const localX = regionX - realRegionX;
const localY = regionY - realRegionY;
const handle = new Long(realRegionY, realRegionX);
return {
'regionHandle': handle,
'regionX': realRegionX / 256,
'regionY': realRegionY / 256,
'localX': localX,
'localY': localY
};
}
static HTTPAssetTypeToInventoryType(HTTPAssetType) {
switch (HTTPAssetType) {

View File

@@ -1 +1 @@
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../lib/classes/Utils.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,0BAA8B;AAE9B,MAAa,KAAK;IAEd,MAAM,CAAC,cAAc,CAAC,GAAW;QAE7B,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,CAAC,oBAAoB,CAAC,GAAW,EAAE,QAAiB;QAEtD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EACpB;YACI,OAAO,EAAE,CAAC;SACb;QACD,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,EAC7B;YACI,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACxD;aAED;YAC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CAAC,CAAC;IACjC,CAAC;IACD,MAAM,CAAC,SAAS,CAAC,GAAW;QAExB,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,EACtB;YACI,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;SACnB;QACD,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;CACJ;AAnJD,sBAmJC"}

7
dist/classes/Vector2.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
/// <reference types="node" />
import { vec2 } from '../tsm/vec2';
export declare class Vector2 extends vec2 {
static getZero(): Vector2;
constructor(buf?: Buffer | number[], pos?: number, double?: boolean);
writeToBuffer(buf: Buffer, pos: number, double: boolean): void;
}

43
dist/classes/Vector2.js vendored Normal file
View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vec2_1 = require("../tsm/vec2");
class Vector2 extends vec2_1.vec2 {
static getZero() {
return new Vector2();
}
constructor(buf, pos, double) {
if (double === undefined) {
double = false;
}
if (buf !== undefined && pos !== undefined && buf instanceof Buffer) {
if (!double) {
const x = buf.readFloatLE(pos);
const y = buf.readFloatLE(pos + 4);
super([x, y]);
}
else {
const x = buf.readDoubleLE(pos);
const y = buf.readDoubleLE(pos + 8);
super([x, y]);
}
}
else if (buf !== undefined && Array.isArray(buf)) {
super(buf);
}
else {
super();
}
}
writeToBuffer(buf, pos, double) {
if (double) {
buf.writeDoubleLE(this.x, pos);
buf.writeDoubleLE(this.y, pos + 8);
}
else {
buf.writeFloatLE(this.x, pos);
buf.writeFloatLE(this.y, pos + 4);
}
}
}
exports.Vector2 = Vector2;
//# sourceMappingURL=Vector2.js.map

1
dist/classes/Vector2.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3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,CAAC;SACtC;aAED;YACI,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YAC9B,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;SACrC;IACL,CAAC;CACJ;AAlDD,0BAkDC"}

View File

@@ -1,8 +1,6 @@
import { CommandsBase } from './CommandsBase';
import { UUID } from '../UUID';
import { ChatType } from '../../enums/ChatType';
import { InventoryOfferedEvent } from '../../events/InventoryOfferedEvent';
import { FriendRequestEvent } from '../..';
export declare class CommunicationsCommands extends CommandsBase {
sendInstantMessage(to: UUID | string, message: string): Promise<void>;
nearbyChat(message: string, type: ChatType, channel?: number): Promise<void>;
@@ -16,11 +14,5 @@ export declare class CommunicationsCommands extends CommandsBase {
typeInstantMessage(to: UUID | string, message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>;
typeLocalMessage(message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>;
startGroupChatSession(sessionID: UUID | string, message: string): Promise<void>;
acceptFriendRequest(event: FriendRequestEvent): Promise<void>;
sendFriendRequest(to: UUID | string, message: string): Promise<void>;
private respondToInventoryOffer;
acceptInventoryOffer(event: InventoryOfferedEvent): Promise<void>;
rejectInventoryOffer(event: InventoryOfferedEvent): Promise<void>;
rejectFriendRequest(event: FriendRequestEvent): Promise<void>;
sendGroupMessage(groupID: UUID | string, message: string): Promise<number>;
}

View File

@@ -11,14 +11,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
const CommandsBase_1 = require("./CommandsBase");
const UUID_1 = require("../UUID");
const Utils_1 = require("../Utils");
const PacketFlags_1 = require("../../enums/PacketFlags");
const ImprovedInstantMessage_1 = require("../messages/ImprovedInstantMessage");
const Vector3_1 = require("../Vector3");
const ChatFromViewer_1 = require("../messages/ChatFromViewer");
const ChatType_1 = require("../../enums/ChatType");
const InstantMessageDialog_1 = require("../../enums/InstantMessageDialog");
const AcceptFriendship_1 = require("../messages/AcceptFriendship");
const DeclineFriendship_1 = require("../messages/DeclineFriendship");
const __1 = require("../..");
class CommunicationsCommands extends CommandsBase_1.CommandsBase {
sendInstantMessage(to, message) {
@@ -50,7 +47,7 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
const sequenceNo = circuit.sendMessage(im, __1.PacketFlags.Reliable);
return yield circuit.waitForAck(sequenceNo, 10000);
});
}
@@ -69,7 +66,7 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
Type: type,
Channel: channel
};
const sequenceNo = this.circuit.sendMessage(cfv, PacketFlags_1.PacketFlags.Reliable);
const sequenceNo = this.circuit.sendMessage(cfv, __1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
@@ -100,7 +97,7 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
Type: ChatType_1.ChatType.StartTyping,
Channel: 0
};
const sequenceNo = this.circuit.sendMessage(cfv, PacketFlags_1.PacketFlags.Reliable);
const sequenceNo = this.circuit.sendMessage(cfv, __1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
@@ -116,7 +113,7 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
Type: ChatType_1.ChatType.StopTyping,
Channel: 0
};
const sequenceNo = this.circuit.sendMessage(cfv, PacketFlags_1.PacketFlags.Reliable);
const sequenceNo = this.circuit.sendMessage(cfv, __1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
@@ -149,7 +146,7 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
const sequenceNo = circuit.sendMessage(im, __1.PacketFlags.Reliable);
return yield circuit.waitForAck(sequenceNo, 10000);
});
}
@@ -182,7 +179,7 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
const sequenceNo = circuit.sendMessage(im, __1.PacketFlags.Reliable);
return yield circuit.waitForAck(sequenceNo, 10000);
});
}
@@ -310,127 +307,10 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
}
}
});
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
const sequenceNo = circuit.sendMessage(im, __1.PacketFlags.Reliable);
}
});
}
acceptFriendRequest(event) {
return __awaiter(this, void 0, void 0, function* () {
const accept = new AcceptFriendship_1.AcceptFriendshipMessage();
accept.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
accept.TransactionBlock = {
TransactionID: event.requestID
};
accept.FolderData = [];
accept.FolderData.push({
'FolderID': this.agent.inventory.findFolderForType(__1.AssetType.CallingCard)
});
const sequenceNo = this.circuit.sendMessage(accept, PacketFlags_1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
sendFriendRequest(to, message) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof to === 'string') {
to = new UUID_1.UUID(to);
}
const requestID = UUID_1.UUID.random();
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
im.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
im.MessageBlock = {
FromGroup: false,
ToAgentID: to,
ParentEstateID: 0,
RegionID: UUID_1.UUID.zero(),
Position: Vector3_1.Vector3.getZero(),
Offline: 0,
Dialog: InstantMessageDialog_1.InstantMessageDialog.FriendshipOffered,
ID: requestID,
Timestamp: Math.floor(new Date().getTime() / 1000),
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
Message: Utils_1.Utils.StringToBuffer(message),
BinaryBucket: Utils_1.Utils.StringToBuffer('')
};
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = this.circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
respondToInventoryOffer(event, response) {
return __awaiter(this, void 0, void 0, function* () {
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
const folder = this.agent.inventory.findFolderForType(event.type);
const binary = Buffer.allocUnsafe(16);
folder.writeToBuffer(binary, 0);
im.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
im.MessageBlock = {
FromGroup: false,
ToAgentID: event.from,
ParentEstateID: 0,
RegionID: UUID_1.UUID.zero(),
Position: Vector3_1.Vector3.getZero(),
Offline: 0,
Dialog: response,
ID: event.requestID,
Timestamp: Math.floor(new Date().getTime() / 1000),
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
Message: Utils_1.Utils.StringToBuffer(''),
BinaryBucket: binary
};
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = this.circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
acceptInventoryOffer(event) {
return __awaiter(this, void 0, void 0, function* () {
if (event.source === __1.ChatSourceType.Object) {
return yield this.respondToInventoryOffer(event, InstantMessageDialog_1.InstantMessageDialog.TaskInventoryAccepted);
}
else {
return yield this.respondToInventoryOffer(event, InstantMessageDialog_1.InstantMessageDialog.InventoryAccepted);
}
});
}
rejectInventoryOffer(event) {
return __awaiter(this, void 0, void 0, function* () {
if (event.source === __1.ChatSourceType.Object) {
return yield this.respondToInventoryOffer(event, InstantMessageDialog_1.InstantMessageDialog.TaskInventoryDeclined);
}
else {
return yield this.respondToInventoryOffer(event, InstantMessageDialog_1.InstantMessageDialog.InventoryDeclined);
}
});
}
rejectFriendRequest(event) {
return __awaiter(this, void 0, void 0, function* () {
const reject = new DeclineFriendship_1.DeclineFriendshipMessage();
reject.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
reject.TransactionBlock = {
TransactionID: event.requestID
};
const sequenceNo = this.circuit.sendMessage(reject, PacketFlags_1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
sendGroupMessage(groupID, message) {
return new Promise((resolve, reject) => {
this.startGroupChatSession(groupID, message).then(() => {
@@ -461,7 +341,7 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
const sequenceNo = circuit.sendMessage(im, __1.PacketFlags.Reliable);
return this.circuit.waitForAck(sequenceNo, 10000);
}).then(() => {
resolve(this.bot.clientCommands.group.getSessionAgentCount(groupID));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,19 @@
import { CommandsBase } from './CommandsBase';
import { Region } from '../Region';
import { Agent } from '../Agent';
import { Bot } from '../../Bot';
import { Subscription } from 'rxjs/internal/Subscription';
import { Friend, FriendRequestEvent, MapLocation, RightsFlags, UUID } from '../..';
export declare class FriendCommands extends CommandsBase {
friendMessages: Subscription;
friendsList: {
[key: string]: Friend;
};
constructor(region: Region, agent: Agent, bot: Bot);
grantFriendRights(friend: Friend | UUID | string, rights: RightsFlags): Promise<void>;
getFriendMapLocation(friend: Friend | UUID | string): Promise<MapLocation>;
acceptFriendRequest(event: FriendRequestEvent): Promise<void>;
rejectFriendRequest(event: FriendRequestEvent): Promise<void>;
sendFriendRequest(to: UUID | string, message: string): Promise<void>;
shutdown(): void;
}

273
dist/classes/commands/FriendCommands.js vendored Normal file
View File

@@ -0,0 +1,273 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const CommandsBase_1 = require("./CommandsBase");
const Message_1 = require("../../enums/Message");
const __1 = require("../..");
const AcceptFriendship_1 = require("../messages/AcceptFriendship");
const ImprovedInstantMessage_1 = require("../messages/ImprovedInstantMessage");
const InstantMessageDialog_1 = require("../../enums/InstantMessageDialog");
const Utils_1 = require("../Utils");
const DeclineFriendship_1 = require("../messages/DeclineFriendship");
const FindAgent_1 = require("../messages/FindAgent");
const IPAddress_1 = require("../IPAddress");
const FilterResponse_1 = require("../../enums/FilterResponse");
const GrantUserRights_1 = require("../messages/GrantUserRights");
class FriendCommands extends CommandsBase_1.CommandsBase {
constructor(region, agent, bot) {
super(region, agent, bot);
this.friendsList = {};
this.friendMessages = this.circuit.subscribeToMessages([
Message_1.Message.OnlineNotification,
Message_1.Message.OfflineNotification,
Message_1.Message.TerminateFriendship,
Message_1.Message.ChangeUserRights
], (packet) => __awaiter(this, void 0, void 0, function* () {
switch (packet.message.id) {
case Message_1.Message.OnlineNotification:
{
const msg = packet.message;
for (const agentEntry of msg.AgentBlock) {
const uuidStr = agentEntry.AgentID.toString();
if (this.friendsList[uuidStr] === undefined) {
this.friendsList[uuidStr] = (yield this.bot.clientCommands.grid.avatarKey2Name(agentEntry.AgentID));
this.friendsList[uuidStr].online = false;
this.friendsList[uuidStr].myRights = __1.RightsFlags.None;
this.friendsList[uuidStr].theirRights = __1.RightsFlags.None;
}
if (this.friendsList[uuidStr].online !== true) {
this.friendsList[uuidStr].online = true;
const friendOnlineEvent = new __1.FriendOnlineEvent();
friendOnlineEvent.friend = this.friendsList[uuidStr];
friendOnlineEvent.online = true;
this.bot.clientEvents.onFriendOnline.next(friendOnlineEvent);
}
}
break;
}
case Message_1.Message.OfflineNotification:
{
const msg = packet.message;
for (const agentEntry of msg.AgentBlock) {
const uuidStr = agentEntry.AgentID.toString();
if (this.friendsList[uuidStr] === undefined) {
this.friendsList[uuidStr] = (yield this.bot.clientCommands.grid.avatarKey2Name(agentEntry.AgentID));
this.friendsList[uuidStr].online = false;
this.friendsList[uuidStr].myRights = __1.RightsFlags.None;
this.friendsList[uuidStr].theirRights = __1.RightsFlags.None;
}
if (this.friendsList[uuidStr].online !== false) {
this.friendsList[uuidStr].online = false;
const friendOnlineEvent = new __1.FriendOnlineEvent();
friendOnlineEvent.friend = this.friendsList[uuidStr];
friendOnlineEvent.online = false;
this.bot.clientEvents.onFriendOnline.next(friendOnlineEvent);
}
}
break;
}
case Message_1.Message.TerminateFriendship:
{
const msg = packet.message;
const friendID = msg.ExBlock.OtherID;
const uuidStr = friendID.toString();
if (this.friendsList[uuidStr] !== undefined) {
const event = new __1.FriendRemovedEvent();
event.friend = this.friendsList[uuidStr];
this.bot.clientEvents.onFriendRemoved.next(event);
delete this.friendsList[uuidStr];
}
break;
}
case Message_1.Message.ChangeUserRights:
{
const msg = packet.message;
for (const rightsEntry of msg.Rights) {
let uuidStr = '';
if (rightsEntry.AgentRelated.equals(this.agent.agentID)) {
uuidStr = msg.AgentData.AgentID.toString();
if (this.friendsList[uuidStr] === undefined) {
this.friendsList[uuidStr] = (yield this.bot.clientCommands.grid.avatarKey2Name(rightsEntry.AgentRelated));
this.friendsList[uuidStr].online = false;
this.friendsList[uuidStr].myRights = __1.RightsFlags.None;
this.friendsList[uuidStr].theirRights = __1.RightsFlags.None;
}
this.friendsList[uuidStr].myRights = rightsEntry.RelatedRights;
}
else {
uuidStr = rightsEntry.AgentRelated.toString();
if (this.friendsList[uuidStr] === undefined) {
this.friendsList[uuidStr] = (yield this.bot.clientCommands.grid.avatarKey2Name(rightsEntry.AgentRelated));
this.friendsList[uuidStr].online = false;
this.friendsList[uuidStr].myRights = __1.RightsFlags.None;
this.friendsList[uuidStr].theirRights = __1.RightsFlags.None;
}
this.friendsList[uuidStr].theirRights = rightsEntry.RelatedRights;
}
const friendRightsEvent = new __1.FriendRightsEvent();
friendRightsEvent.friend = this.friendsList[uuidStr];
friendRightsEvent.theirRights = this.friendsList[uuidStr].theirRights;
friendRightsEvent.myRights = this.friendsList[uuidStr].myRights;
this.bot.clientEvents.onFriendRights.next(friendRightsEvent);
}
break;
}
}
}));
}
grantFriendRights(friend, rights) {
return __awaiter(this, void 0, void 0, function* () {
let friendKey = __1.UUID.zero();
if (friend instanceof __1.UUID) {
friendKey = friend;
}
else if (friend instanceof __1.Friend) {
friendKey = friend.getKey();
}
else if (typeof friend === 'string') {
friendKey = new __1.UUID(friend);
}
else {
throw new Error('"Friend" parameter must be Friend, UUID or string');
}
const request = new GrantUserRights_1.GrantUserRightsMessage();
request.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
request.Rights = [
{
'AgentRelated': friendKey,
'RelatedRights': rights
}
];
const sequenceNo = this.circuit.sendMessage(request, __1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
getFriendMapLocation(friend) {
return __awaiter(this, void 0, void 0, function* () {
let friendKey = __1.UUID.zero();
if (friend instanceof __1.UUID) {
friendKey = friend;
}
else if (friend instanceof __1.Friend) {
friendKey = friend.getKey();
}
else if (typeof friend === 'string') {
friendKey = new __1.UUID(friend);
}
else {
throw new Error('"Friend" parameter must be Friend, UUID or string');
}
const request = new FindAgent_1.FindAgentMessage();
request.AgentBlock = {
'Hunter': this.agent.agentID,
'Prey': friendKey,
'SpaceIP': IPAddress_1.IPAddress.zero()
};
request.LocationBlock = [
{
GlobalX: 0.0,
GlobalY: 0.0
}
];
this.circuit.sendMessage(request, __1.PacketFlags.Reliable);
const response = yield this.circuit.waitForMessage(Message_1.Message.FindAgent, 10000, (filterMsg) => {
if (filterMsg.AgentBlock.Hunter.equals(this.agent.agentID) && filterMsg.AgentBlock.Prey.equals(friendKey)) {
return FilterResponse_1.FilterResponse.Finish;
}
return FilterResponse_1.FilterResponse.NoMatch;
});
const globalPos = Utils_1.Utils.RegionCoordinatesToHandle(response.LocationBlock[0].GlobalX, response.LocationBlock[0].GlobalY);
const mapInfo = yield this.bot.clientCommands.grid.getRegionMapInfo(globalPos.regionX, globalPos.regionY);
return {
'regionName': mapInfo.block.name,
'mapImage': mapInfo.block.mapImage,
'regionHandle': globalPos.regionHandle,
'regionX': globalPos.regionX,
'regionY': globalPos.regionY,
'localX': Math.floor(globalPos.localX),
'localY': Math.floor(globalPos.localY),
'avatars': mapInfo.avatars
};
});
}
acceptFriendRequest(event) {
return __awaiter(this, void 0, void 0, function* () {
const accept = new AcceptFriendship_1.AcceptFriendshipMessage();
accept.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
accept.TransactionBlock = {
TransactionID: event.requestID
};
accept.FolderData = [];
accept.FolderData.push({
'FolderID': this.agent.inventory.findFolderForType(__1.AssetType.CallingCard)
});
const sequenceNo = this.circuit.sendMessage(accept, __1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
rejectFriendRequest(event) {
return __awaiter(this, void 0, void 0, function* () {
const reject = new DeclineFriendship_1.DeclineFriendshipMessage();
reject.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
reject.TransactionBlock = {
TransactionID: event.requestID
};
const sequenceNo = this.circuit.sendMessage(reject, __1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
sendFriendRequest(to, message) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof to === 'string') {
to = new __1.UUID(to);
}
const requestID = __1.UUID.random();
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
im.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
im.MessageBlock = {
FromGroup: false,
ToAgentID: to,
ParentEstateID: 0,
RegionID: __1.UUID.zero(),
Position: __1.Vector3.getZero(),
Offline: 0,
Dialog: InstantMessageDialog_1.InstantMessageDialog.FriendshipOffered,
ID: requestID,
Timestamp: Math.floor(new Date().getTime() / 1000),
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
Message: Utils_1.Utils.StringToBuffer(message),
BinaryBucket: Utils_1.Utils.StringToBuffer('')
};
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = this.circuit.sendMessage(im, __1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
shutdown() {
this.friendMessages.unsubscribe();
}
}
exports.FriendCommands = FriendCommands;
//# sourceMappingURL=FriendCommands.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,10 @@
import { UUID } from '../UUID';
import { CommandsBase } from './CommandsBase';
import { MapInfoRangeReplyEvent, MapInfoReplyEvent, RegionInfoReplyEvent } from '../..';
import { Avatar, MapInfoRangeReplyEvent, MapInfoReplyEvent, RegionInfoReplyEvent } from '../..';
export declare class GridCommands extends CommandsBase {
getRegionByName(regionName: string): Promise<RegionInfoReplyEvent>;
getRegionMapInfo(gridX: number, gridY: number): Promise<MapInfoReplyEvent>;
getRegionMapInfoRange(minX: number, minY: number, maxX: number, maxY: number): Promise<MapInfoRangeReplyEvent>;
name2Key(name: string): Promise<UUID>;
avatarName2Key(name: string): Promise<UUID>;
avatarKey2Name(uuid: UUID | UUID[]): Promise<Avatar | Avatar[]>;
}

View File

@@ -1,4 +1,12 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const Message_1 = require("../../enums/Message");
const MapBlockRequest_1 = require("../messages/MapBlockRequest");
@@ -14,6 +22,7 @@ const GridLayerType_1 = require("../../enums/GridLayerType");
const MapBlock_1 = require("../MapBlock");
const __1 = require("../..");
const TimeoutError_1 = require("../TimeoutError");
const UUIDNameRequest_1 = require("../messages/UUIDNameRequest");
class GridCommands extends CommandsBase_1.CommandsBase {
getRegionByName(regionName) {
return new Promise((resolve, reject) => {
@@ -56,7 +65,7 @@ class GridCommands extends CommandsBase_1.CommandsBase {
this.waterHeight = region.WaterHeight;
this.agents = region.Agents;
this.mapImageID = region.MapImageID;
this.handle = Utils_1.Utils.RegionCoordinatesToHandle(region.X * 256, region.Y * 256);
this.handle = Utils_1.Utils.RegionCoordinatesToHandle(region.X * 256, region.Y * 256).regionHandle;
}
};
resolve(reply);
@@ -106,7 +115,7 @@ class GridCommands extends CommandsBase_1.CommandsBase {
response.block.mapImage = data.MapImageID;
}
});
const regionHandle = Utils_1.Utils.RegionCoordinatesToHandle(gridX * 256, gridY * 256);
const regionHandle = Utils_1.Utils.RegionCoordinatesToHandle(gridX * 256, gridY * 256).regionHandle;
const mi = new MapItemRequest_1.MapItemRequestMessage();
mi.AgentData = {
AgentID: this.agent.agentID,
@@ -140,10 +149,10 @@ class GridCommands extends CommandsBase_1.CommandsBase {
}
}).then((responseMsg2) => {
responseMsg2.Data.forEach((data) => {
response.avatars.push({
X: data.X,
Y: data.Y
});
response.avatars.push(new __1.Vector2([
data.X,
data.Y
]));
});
resolve(response);
}).catch((err) => {
@@ -201,7 +210,7 @@ class GridCommands extends CommandsBase_1.CommandsBase {
});
});
}
name2Key(name) {
avatarName2Key(name) {
const check = name.split('.');
if (check.length > 1) {
name = check.join(' ');
@@ -249,6 +258,66 @@ class GridCommands extends CommandsBase_1.CommandsBase {
});
});
}
avatarKey2Name(uuid) {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
const req = new UUIDNameRequest_1.UUIDNameRequestMessage();
req.UUIDNameBlock = [];
let arr = true;
if (!Array.isArray(uuid)) {
arr = false;
uuid = [uuid];
}
const waitingFor = {};
let remaining = 0;
for (const id of uuid) {
waitingFor[id.toString()] = null;
req.UUIDNameBlock.push({ 'ID': id });
remaining++;
}
this.circuit.sendMessage(req, __1.PacketFlags.Reliable);
try {
yield this.circuit.waitForMessage(Message_1.Message.UUIDNameReply, 10000, (reply) => {
let found = false;
for (const name of reply.UUIDNameBlock) {
if (waitingFor[name.ID.toString()] !== undefined) {
found = true;
if (waitingFor[name.ID.toString()] === null) {
waitingFor[name.ID.toString()] = {
'firstName': Utils_1.Utils.BufferToStringSimple(name.FirstName),
'lastName': Utils_1.Utils.BufferToStringSimple(name.LastName)
};
remaining--;
}
}
}
if (remaining < 1) {
return FilterResponse_1.FilterResponse.Finish;
}
else if (found) {
return FilterResponse_1.FilterResponse.Match;
}
return FilterResponse_1.FilterResponse.NoMatch;
});
if (!arr) {
const result = waitingFor[uuid[0].toString()];
const av = new __1.Avatar(uuid[0], result.firstName, result.lastName);
resolve(av);
}
else {
const response = [];
for (const k of uuid) {
const result = waitingFor[k.toString()];
const av = new __1.Avatar(k, result.firstName, result.lastName);
response.push(av);
}
resolve(response);
}
}
catch (e) {
reject(e);
}
}));
}
}
exports.GridCommands = GridCommands;
//# sourceMappingURL=GridCommands.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,10 @@
import { CommandsBase } from './CommandsBase';
import { InventoryFolder } from '../InventoryFolder';
import { InventoryOfferedEvent } from '../..';
export declare class InventoryCommands extends CommandsBase {
getInventoryRoot(): InventoryFolder;
getLibraryRoot(): InventoryFolder;
private respondToInventoryOffer;
acceptInventoryOffer(event: InventoryOfferedEvent): Promise<void>;
rejectInventoryOffer(event: InventoryOfferedEvent): Promise<void>;
}

View File

@@ -1,6 +1,18 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const CommandsBase_1 = require("./CommandsBase");
const __1 = require("../..");
const InstantMessageDialog_1 = require("../../enums/InstantMessageDialog");
const ImprovedInstantMessage_1 = require("../messages/ImprovedInstantMessage");
const Utils_1 = require("../Utils");
class InventoryCommands extends CommandsBase_1.CommandsBase {
getInventoryRoot() {
return this.agent.inventory.getRootFolderMain();
@@ -8,6 +20,58 @@ class InventoryCommands extends CommandsBase_1.CommandsBase {
getLibraryRoot() {
return this.agent.inventory.getRootFolderLibrary();
}
respondToInventoryOffer(event, response) {
return __awaiter(this, void 0, void 0, function* () {
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
const folder = this.agent.inventory.findFolderForType(event.type);
const binary = Buffer.allocUnsafe(16);
folder.writeToBuffer(binary, 0);
im.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
im.MessageBlock = {
FromGroup: false,
ToAgentID: event.from,
ParentEstateID: 0,
RegionID: __1.UUID.zero(),
Position: __1.Vector3.getZero(),
Offline: 0,
Dialog: response,
ID: event.requestID,
Timestamp: Math.floor(new Date().getTime() / 1000),
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
Message: Utils_1.Utils.StringToBuffer(''),
BinaryBucket: binary
};
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = this.circuit.sendMessage(im, __1.PacketFlags.Reliable);
return yield this.circuit.waitForAck(sequenceNo, 10000);
});
}
acceptInventoryOffer(event) {
return __awaiter(this, void 0, void 0, function* () {
if (event.source === __1.ChatSourceType.Object) {
return yield this.respondToInventoryOffer(event, InstantMessageDialog_1.InstantMessageDialog.TaskInventoryAccepted);
}
else {
return yield this.respondToInventoryOffer(event, InstantMessageDialog_1.InstantMessageDialog.InventoryAccepted);
}
});
}
rejectInventoryOffer(event) {
return __awaiter(this, void 0, void 0, function* () {
if (event.source === __1.ChatSourceType.Object) {
return yield this.respondToInventoryOffer(event, InstantMessageDialog_1.InstantMessageDialog.TaskInventoryDeclined);
}
else {
return yield this.respondToInventoryOffer(event, InstantMessageDialog_1.InstantMessageDialog.InventoryDeclined);
}
});
}
}
exports.InventoryCommands = InventoryCommands;
//# sourceMappingURL=InventoryCommands.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"InventoryCommands.js","sourceRoot":"","sources":["../../../lib/classes/commands/InventoryCommands.ts"],"names":[],"mappings":";;AAAA,iDAA4C;AAG5C,MAAa,iBAAkB,SAAQ,2BAAY;IAE/C,gBAAgB;QAEZ,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC;IACpD,CAAC;IACD,cAAc;QAEV,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,oBAAoB,EAAE,CAAC;IACvD,CAAC;CACJ;AAVD,8CAUC"}
{"version":3,"file":"InventoryCommands.js","sourceRoot":"","sources":["../../../lib/classes/commands/InventoryCommands.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,iDAA4C;AAE5C,6BAAwF;AACxF,2EAAsE;AACtE,+EAAiF;AACjF,oCAA+B;AAE/B,MAAa,iBAAkB,SAAQ,2BAAY;IAE/C,gBAAgB;QAEZ,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC;IACpD,CAAC;IACD,cAAc;QAEV,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,oBAAoB,EAAE,CAAC;IACvD,CAAC;IACa,uBAAuB,CAAC,KAA4B,EAAE,QAA8B;;YAE9F,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YACnE,MAAM,EAAE,GAAkC,IAAI,sDAA6B,EAAE,CAAC;YAE9E,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,I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,KAAK,EAAE,2CAAoB,CAAC,qBAAqB,CAAC,CAAC;aAChG;iBAED;gBACI,OAAO,MAAM,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,2CAAoB,CAAC,iBAAiB,CAAC,CAAC;aAC5F;QACL,CAAC;KAAA;IAEK,oBAAoB,CAAC,KAA4B;;YAEnD,IAAI,KAAK,CAAC,MAAM,KAAK,kBAAc,CAAC,MAAM,EAC1C;gBACI,OAAO,MAAM,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,2CAAoB,CAAC,qBAAqB,CAAC,CAAC;aAChG;iBAED;gBACI,OAAO,MAAM,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,2CAAoB,CAAC,iBAAiB,CAAC,CAAC;aAC5F;QACL,CAAC;KAAA;CACJ;AAnED,8CAmEC"}

11
dist/classes/public/Avatar.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
import { UUID } from '../UUID';
export declare class Avatar {
private avatarKey;
private firstName;
private lastName;
constructor(avatarKey: UUID, firstName: string, lastName: string);
getName(): string;
getFirstName(): string;
getLastName(): string;
getKey(): UUID;
}

23
dist/classes/public/Avatar.js vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Avatar {
constructor(avatarKey, firstName, lastName) {
this.avatarKey = avatarKey;
this.firstName = firstName;
this.lastName = lastName;
}
getName() {
return this.firstName + ' ' + this.lastName;
}
getFirstName() {
return this.firstName;
}
getLastName() {
return this.lastName;
}
getKey() {
return this.avatarKey;
}
}
exports.Avatar = Avatar;
//# sourceMappingURL=Avatar.js.map

1
dist/classes/public/Avatar.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../lib/classes/public/Avatar.ts"],"names":[],"mappings":";;AAEA,MAAa,MAAM;IAEf,YAAoB,SAAe,EAAU,SAAiB,EAAU,QAAgB;QAApE,cAAS,GAAT,SAAS,CAAM;QAAU,cAAS,GAAT,SAAS,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAQ;IAGxF,CAAC;IACD,OAAO;QAEH,OAAO,IAAI,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChD,CAAC;IACD,YAAY;QAER,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD,WAAW;QAEP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD,MAAM;QAEF,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;CACJ;AAtBD,wBAsBC"}

7
dist/classes/public/Friend.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
import { Avatar } from './Avatar';
import { RightsFlags } from '../..';
export declare class Friend extends Avatar {
online: boolean;
theirRights: RightsFlags;
myRights: RightsFlags;
}

13
dist/classes/public/Friend.js vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Avatar_1 = require("./Avatar");
const __1 = require("../..");
class Friend extends Avatar_1.Avatar {
constructor() {
super(...arguments);
this.theirRights = __1.RightsFlags.None;
this.myRights = __1.RightsFlags.None;
}
}
exports.Friend = Friend;
//# sourceMappingURL=Friend.js.map

1
dist/classes/public/Friend.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Friend.js","sourceRoot":"","sources":["../../../lib/classes/public/Friend.ts"],"names":[],"mappings":";;AAAA,qCAAgC;AAChC,6BAAkC;AAElC,MAAa,MAAO,SAAQ,eAAM;IAAlC;;QAGI,gBAAW,GAAgB,eAAW,CAAC,IAAI,CAAC;QAC5C,aAAQ,GAAgB,eAAW,CAAC,IAAI,CAAC;IAC7C,CAAC;CAAA;AALD,wBAKC"}

View File

@@ -0,0 +1,8 @@
import * as Long from 'long';
export interface GlobalPosition {
regionHandle: Long;
regionX: number;
regionY: number;
localX: number;
localY: number;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=GlobalPosition.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GlobalPosition.js","sourceRoot":"","sources":["../../../../lib/classes/public/interfaces/GlobalPosition.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,13 @@
import { UUID } from '../../UUID';
import * as Long from 'long';
import { Vector2 } from '../../Vector2';
export interface MapLocation {
'regionName': string;
'mapImage': UUID;
'regionHandle': Long;
'regionX': number;
'regionY': number;
'localX': number;
'localY': number;
'avatars': Vector2[];
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=MapLocation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MapLocation.js","sourceRoot":"","sources":["../../../../lib/classes/public/interfaces/MapLocation.ts"],"names":[],"mappings":""}

6
dist/enums/RightsFlags.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
export declare enum RightsFlags {
None = 0,
CanSeeOnline = 1,
CanSeeOnMap = 2,
CanModifyObjects = 4
}

10
dist/enums/RightsFlags.js vendored Normal file
View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var RightsFlags;
(function (RightsFlags) {
RightsFlags[RightsFlags["None"] = 0] = "None";
RightsFlags[RightsFlags["CanSeeOnline"] = 1] = "CanSeeOnline";
RightsFlags[RightsFlags["CanSeeOnMap"] = 2] = "CanSeeOnMap";
RightsFlags[RightsFlags["CanModifyObjects"] = 4] = "CanModifyObjects";
})(RightsFlags = exports.RightsFlags || (exports.RightsFlags = {}));
//# sourceMappingURL=RightsFlags.js.map

1
dist/enums/RightsFlags.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"RightsFlags.js","sourceRoot":"","sources":["../../lib/enums/RightsFlags.ts"],"names":[],"mappings":";;AAAA,IAAY,WAMX;AAND,WAAY,WAAW;IAEnB,6CAAQ,CAAA;IACR,6DAAgB,CAAA;IAChB,2DAAe,CAAA;IACf,qEAAoB,CAAA;AACxB,CAAC,EANW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAMtB"}

5
dist/events/FriendOnlineEvent.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
import { Friend } from '..';
export declare class FriendOnlineEvent {
friend: Friend;
online: boolean;
}

6
dist/events/FriendOnlineEvent.js vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class FriendOnlineEvent {
}
exports.FriendOnlineEvent = FriendOnlineEvent;
//# sourceMappingURL=FriendOnlineEvent.js.map

1
dist/events/FriendOnlineEvent.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"FriendOnlineEvent.js","sourceRoot":"","sources":["../../lib/events/FriendOnlineEvent.ts"],"names":[],"mappings":";;AAEA,MAAa,iBAAiB;CAI7B;AAJD,8CAIC"}

4
dist/events/FriendRemovedEvent.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
import { Friend } from '..';
export declare class FriendRemovedEvent {
friend: Friend;
}

6
dist/events/FriendRemovedEvent.js vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class FriendRemovedEvent {
}
exports.FriendRemovedEvent = FriendRemovedEvent;
//# sourceMappingURL=FriendRemovedEvent.js.map

1
dist/events/FriendRemovedEvent.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"FriendRemovedEvent.js","sourceRoot":"","sources":["../../lib/events/FriendRemovedEvent.ts"],"names":[],"mappings":";;AAEA,MAAa,kBAAkB;CAG9B;AAHD,gDAGC"}

6
dist/events/FriendRightsEvent.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
import { Friend, RightsFlags } from '..';
export declare class FriendRightsEvent {
friend: Friend;
myRights: RightsFlags;
theirRights: RightsFlags;
}

6
dist/events/FriendRightsEvent.js vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class FriendRightsEvent {
}
exports.FriendRightsEvent = FriendRightsEvent;
//# sourceMappingURL=FriendRightsEvent.js.map

1
dist/events/FriendRightsEvent.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"FriendRightsEvent.js","sourceRoot":"","sources":["../../lib/events/FriendRightsEvent.ts"],"names":[],"mappings":";;AAEA,MAAa,iBAAiB;CAK7B;AALD,8CAKC"}

View File

@@ -1,8 +1,6 @@
import { MapBlock } from '../classes/MapBlock';
import { Vector2 } from '..';
export declare class MapInfoReplyEvent {
block: MapBlock;
avatars: {
X: number;
Y: number;
}[];
avatars: Vector2[];
}

View File

@@ -1 +1 @@
{"version":3,"file":"MapInfoReplyEvent.js","sourceRoot":"","sources":["../../lib/events/MapInfoReplyEvent.ts"],"names":[],"mappings":";;AAEA,MAAa,iBAAiB;CAO7B;AAPD,8CAOC"}
{"version":3,"file":"MapInfoReplyEvent.js","sourceRoot":"","sources":["../../lib/events/MapInfoReplyEvent.ts"],"names":[],"mappings":";;AAGA,MAAa,iBAAiB;CAI7B;AAJD,8CAIC"}

11
dist/index.d.ts vendored
View File

@@ -40,4 +40,13 @@ import { ParcelInfoReplyEvent } from './events/ParcelInfoReplyEvent';
import { ScriptDialogEvent } from './events/ScriptDialogEvent';
import { EventQueueStateChangeEvent } from './events/EventQueueStateChangeEvent';
import { RegionFlags } from './enums/RegionFlags';
export { Bot, LoginParameters, AssetType, HTTPAssets, ClientEvents, BVH, ChatSourceType, BotOptionFlags, UUID, Vector3, AgentFlags, CompressedFlags, ControlFlags, DecodeFlags, InstantMessageEventFlags, InventoryItemFlags, LoginFlags, MessageFlags, ParcelInfoFlags, PacketFlags, RegionProtocolFlags, SoundFlags, TeleportFlags, RegionFlags, ChatEvent, DisconnectEvent, FriendRequestEvent, FriendResponseEvent, GroupChatEvent, GroupChatSessionAgentListEvent, GroupChatSessionJoinEvent, GroupInviteEvent, InstantMessageEvent, InventoryOfferedEvent, LureEvent, MapInfoRangeReplyEvent, MapInfoReplyEvent, ParcelInfoReplyEvent, RegionInfoReplyEvent, TeleportEvent, ScriptDialogEvent, EventQueueStateChangeEvent };
import { Friend } from './classes/public/Friend';
import { FriendOnlineEvent } from './events/FriendOnlineEvent';
import { Avatar } from './classes/public/Avatar';
import { RightsFlags } from './enums/RightsFlags';
import { FriendRightsEvent } from './events/FriendRightsEvent';
import { FriendRemovedEvent } from './events/FriendRemovedEvent';
import { GlobalPosition } from './classes/public/interfaces/GlobalPosition';
import { MapLocation } from './classes/public/interfaces/MapLocation';
import { Vector2 } from './classes/Vector2';
export { Bot, LoginParameters, AssetType, HTTPAssets, ClientEvents, BVH, ChatSourceType, BotOptionFlags, UUID, Vector3, Vector2, AgentFlags, CompressedFlags, ControlFlags, DecodeFlags, InstantMessageEventFlags, InventoryItemFlags, LoginFlags, MessageFlags, ParcelInfoFlags, PacketFlags, RegionProtocolFlags, SoundFlags, TeleportFlags, RegionFlags, RightsFlags, ChatEvent, DisconnectEvent, FriendRequestEvent, FriendResponseEvent, GroupChatEvent, GroupChatSessionAgentListEvent, GroupChatSessionJoinEvent, GroupInviteEvent, InstantMessageEvent, InventoryOfferedEvent, LureEvent, MapInfoRangeReplyEvent, MapInfoReplyEvent, ParcelInfoReplyEvent, RegionInfoReplyEvent, TeleportEvent, ScriptDialogEvent, EventQueueStateChangeEvent, FriendOnlineEvent, FriendRightsEvent, FriendRemovedEvent, Avatar, Friend, GlobalPosition, MapLocation };

14
dist/index.js vendored
View File

@@ -84,4 +84,18 @@ const EventQueueStateChangeEvent_1 = require("./events/EventQueueStateChangeEven
exports.EventQueueStateChangeEvent = EventQueueStateChangeEvent_1.EventQueueStateChangeEvent;
const RegionFlags_1 = require("./enums/RegionFlags");
exports.RegionFlags = RegionFlags_1.RegionFlags;
const Friend_1 = require("./classes/public/Friend");
exports.Friend = Friend_1.Friend;
const FriendOnlineEvent_1 = require("./events/FriendOnlineEvent");
exports.FriendOnlineEvent = FriendOnlineEvent_1.FriendOnlineEvent;
const Avatar_1 = require("./classes/public/Avatar");
exports.Avatar = Avatar_1.Avatar;
const RightsFlags_1 = require("./enums/RightsFlags");
exports.RightsFlags = RightsFlags_1.RightsFlags;
const FriendRightsEvent_1 = require("./events/FriendRightsEvent");
exports.FriendRightsEvent = FriendRightsEvent_1.FriendRightsEvent;
const FriendRemovedEvent_1 = require("./events/FriendRemovedEvent");
exports.FriendRemovedEvent = FriendRemovedEvent_1.FriendRemovedEvent;
const Vector2_1 = require("./classes/Vector2");
exports.Vector2 = Vector2_1.Vector2;
//# sourceMappingURL=index.js.map

2
dist/index.js.map vendored
View File

@@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;AAAA,+BAA0B;AA6CtB,cA7CI,SAAG,CA6CJ;AA5CP,+DAA0D;AA6CtD,0BA7CI,iCAAe,CA6CJ;AA5CnB,yDAAoD;AA+ChD,uBA/CI,2BAAY,CA+CJ;AA9ChB,uCAAkC;AA+C9B,cA/CI,SAAG,CA+CJ;AA7CP,iDAA4C;AA0CxC,oBA1CI,qBAAS,CA0CJ;AAzCb,mDAA8C;AA0C1C,qBA1CI,uBAAU,CA0CJ;AAzCd,+EAA0E;AAsDtE,mCAtDI,mDAAwB,CAsDJ;AArD5B,sEAAiE;AAyE7D,8BAzEI,yCAAmB,CAyEJ;AAxEvB,2DAAsD;AA0ClD,yBA1CI,+BAAc,CA0CJ;AAzClB,2DAAsD;AA0ClD,yBA1CI,+BAAc,CA0CJ;AAzClB,yCAAoC;AA0ChC,eA1CI,WAAI,CA0CJ;AAzCR,+CAA0C;AA0CtC,kBA1CI,iBAAO,CA0CJ;AAzCX,kDAA6C;AA4DzC,oBA5DI,qBAAS,CA4DJ;AA3Db,gEAA2D;AAkEvD,2BAlEI,mCAAgB,CAkEJ;AAjEpB,oEAA+D;AA4D3D,6BA5DI,uCAAkB,CA4DJ;AA3DtB,sEAAiE;AA4D7D,8BA5DI,yCAAmB,CA4DJ;AA3DvB,kDAA6C;AAkEzC,oBAlEI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AaJ"}

View File

@@ -25,7 +25,7 @@ const bot = new nmv.Bot(loginParameters, options);
// This will tell the bot to keep trying to teleport back to the 'stay' location.
// You can specify a region and position, such as:
// bot.stayPut(true, 'Izanagi', new Vector3([128, 128, 21]));
// bot.stayPut(true, 'Izanagi', new nmv.Vector3([128, 128, 21]));
// Note that the 'stay' location will be updated if you request or accept a lure (a teleport).
// If no region is specified, it will be set to the region you log in to.
bot.stayPut(true);
@@ -163,7 +163,7 @@ bot.clientEvents.onGroupInvite.subscribe(async (GroupInviteEvent) =>
//Resolve avatar key
try
{
const key = await bot.clientCommands.grid.name2Key(GroupInviteEvent.fromName);
const key = await bot.clientCommands.grid.avatarName2Key(GroupInviteEvent.fromName);
if (key.toString() === master)
{
console.log('Accepting');
@@ -225,7 +225,7 @@ async function connect()
const groupID = new nmv.UUID("c6424e05-6e2c-fb03-220b-ca7904d11e04");
// If you want to wait here for the request to be acknowledged, you can add "await"
bot.clientCommands.comms.sendFriendRequest(master, 'Be friends with me?').then(() => {});
bot.clientCommands.friends.sendFriendRequest(master, 'Be friends with me?').then(() => {});
const folders = bot.clientCommands.inventory.getInventoryRoot().getChildFolders();
folders.forEach((folder) =>
@@ -271,13 +271,17 @@ async function connect()
await bot.waitForEventQueue();
try
{
//await bot.clientCommands.teleport.teleportTo('Izanagi', new nmv.Vector3([128, 128, 20]), new nmv.Vector3([ 0, 1.0, 0]));
//console.log("Teleport completed");
// Get map location of Casper Warden (should (hopefully)! fail if you don't have map rights on me..
const regionLocation = await bot.clientCommands.friends.getFriendMapLocation('d1cd5b71-6209-4595-9bf0-771bf689ce00');
console.log('Casper is in ' + regionLocation.regionName + ' at <' + regionLocation.localX + ', ' + regionLocation.localY + '> and there are ' + regionLocation.avatars.length + ' other avatars there too! You stalker!');
}
catch(error)
{
console.error(error);
console.log('Map location request failed. You probably do not have map rights on Casper.');
}
//await bot.clientCommands.friends.grantFriendRights('d1cd5b71-6209-4595-9bf0-771bf689ce00', nmv.RightsFlags.CanModifyObjects | nmv.RightsFlags.CanSeeOnline | nmv.RightsFlags.CanSeeOnMap );
}
catch (error)
{

View File

@@ -198,6 +198,11 @@ export class Bot
this.disconnected(true, 'Logout completed');
}
agentID(): UUID
{
return this.agent.agentID;
}
async connectToSim(requested: boolean)
{
this.agent.setCurrentRegion(this.currentRegion);

View File

@@ -201,7 +201,7 @@ export class Circuit
if (handleObj.subscription !== null)
{
handleObj.subscription.unsubscribe();
const err = new TimeoutError('Timeout waiting for message of type ' + id);
const err = new TimeoutError('Timeout waiting for message of type ' + Message[id]);
err.timeout = true;
err.waitingForMessage = id;
reject(err);

View File

@@ -11,6 +11,7 @@ import {AgentCommands} from './commands/AgentCommands';
import {GroupCommands} from './commands/GroupCommands';
import {InventoryCommands} from './commands/InventoryCommands';
import {ParcelCommands} from './commands/ParcelCommands';
import {FriendCommands} from './commands/FriendCommands';
export class ClientCommands
{
@@ -19,6 +20,7 @@ export class ClientCommands
public teleport: TeleportCommands;
public region: RegionCommands;
public parcel: ParcelCommands;
public friends: FriendCommands;
public grid: GridCommands;
public comms: CommunicationsCommands;
public agent: AgentCommands;
@@ -33,6 +35,7 @@ export class ClientCommands
this.region = new RegionCommands(region, agent, bot);
this.parcel = new ParcelCommands(region, agent, bot);
this.grid = new GridCommands(region, agent, bot);
this.friends = new FriendCommands(region, agent, bot);
this.comms = new CommunicationsCommands(region, agent, bot);
this.agent = new AgentCommands(region, agent, bot);
this.group = new GroupCommands(region, agent, bot);
@@ -50,5 +53,6 @@ export class ClientCommands
this.agent.shutdown();
this.group.shutdown();
this.inventory.shutdown();
this.friends.shutdown();
}
}

View File

@@ -12,7 +12,9 @@ import {
LureEvent,
TeleportEvent,
ScriptDialogEvent,
EventQueueStateChangeEvent
EventQueueStateChangeEvent,
FriendOnlineEvent,
FriendRightsEvent, FriendRemovedEvent
} from '..';
import {Subject} from 'rxjs/internal/Subject';
@@ -34,4 +36,7 @@ export class ClientEvents
onFriendResponse: Subject<FriendResponseEvent> = new Subject<FriendResponseEvent>();
onScriptDialog: Subject<ScriptDialogEvent> = new Subject<ScriptDialogEvent>();
onEventQueueStateChange: Subject<EventQueueStateChangeEvent> = new Subject<EventQueueStateChangeEvent>();
onFriendOnline: Subject<FriendOnlineEvent> = new Subject<FriendOnlineEvent>();
onFriendRights: Subject<FriendRightsEvent> = new Subject<FriendRightsEvent>();
onFriendRemoved: Subject<FriendRemovedEvent> = new Subject<FriendRemovedEvent>();
}

View File

@@ -36,6 +36,21 @@ export class IPAddress
{
this.ip = ipaddr.parse(buf);
}
else
{
throw new Error('Invalid IP address');
}
}
}
else
{
if (ipaddr.isValid(buf))
{
this.ip = ipaddr.parse(buf);
}
else
{
throw new Error('Invalid IP address');
}
}
}

View File

@@ -178,7 +178,8 @@ export class Region
this.xCoordinate = region.X;
this.yCoordinate = region.Y;
this.mapImage = region.MapImageID;
this.regionHandle = Utils.RegionCoordinatesToHandle(this.xCoordinate, this.yCoordinate);
const globalPos = Utils.RegionCoordinatesToHandle(this.xCoordinate, this.yCoordinate);
this.regionHandle = globalPos.regionHandle;
return FilterResponse.Finish;
}
}

View File

@@ -1,5 +1,5 @@
import * as Long from 'long';
import {HTTPAssets} from '..';
import {GlobalPosition, HTTPAssets} from '..';
export class Utils
{
@@ -60,11 +60,20 @@ export class Utils
}
}
static RegionCoordinatesToHandle(regionX: number, regionY: number): Long
static RegionCoordinatesToHandle(regionX: number, regionY: number): GlobalPosition
{
regionX = Math.floor(regionX / 256) * 256;
regionY = Math.floor( regionY / 256) * 256;
return new Long(regionY, regionX);
const realRegionX = Math.floor(regionX / 256) * 256;
const realRegionY = Math.floor(regionY / 256) * 256;
const localX = regionX - realRegionX;
const localY = regionY - realRegionY;
const handle = new Long(realRegionY, realRegionX);
return {
'regionHandle': handle,
'regionX': realRegionX / 256,
'regionY': realRegionY / 256,
'localX': localX,
'localY': localY
};
}
static HTTPAssetTypeToInventoryType(HTTPAssetType: string)

53
lib/classes/Vector2.ts Normal file
View File

@@ -0,0 +1,53 @@
import {vec2} from '../tsm/vec2';
export class Vector2 extends vec2
{
static getZero(): Vector2
{
return new Vector2();
}
constructor(buf?: Buffer | number[], pos?: number, double?: boolean)
{
if (double === undefined)
{
double = false;
}
if (buf !== undefined && pos !== undefined && buf instanceof Buffer)
{
if (!double)
{
const x = buf.readFloatLE(pos);
const y = buf.readFloatLE(pos + 4);
super([x, y]);
}
else
{
const x = buf.readDoubleLE(pos);
const y = buf.readDoubleLE(pos + 8);
super([x, y]);
}
}
else if (buf !== undefined && Array.isArray(buf))
{
super(buf);
}
else
{
super();
}
}
writeToBuffer(buf: Buffer, pos: number, double: boolean)
{
if (double)
{
buf.writeDoubleLE(this.x, pos);
buf.writeDoubleLE(this.y, pos + 8);
}
else
{
buf.writeFloatLE(this.x, pos);
buf.writeFloatLE(this.y, pos + 4);
}
}
}

View File

@@ -1,17 +1,13 @@
import {CommandsBase} from './CommandsBase';
import {UUID} from '../UUID';
import {Utils} from '../Utils';
import {PacketFlags} from '../../enums/PacketFlags';
import {ImprovedInstantMessageMessage} from '../messages/ImprovedInstantMessage';
import {Vector3} from '../Vector3';
import {ChatFromViewerMessage} from '../messages/ChatFromViewer';
import {ChatType} from '../../enums/ChatType';
import {InstantMessageDialog} from '../../enums/InstantMessageDialog';
import Timer = NodeJS.Timer;
import {AcceptFriendshipMessage} from '../messages/AcceptFriendship';
import {DeclineFriendshipMessage} from '../messages/DeclineFriendship';
import {InventoryOfferedEvent} from '../../events/InventoryOfferedEvent';
import {AssetType, ChatSourceType, FriendRequestEvent, GroupChatSessionJoinEvent} from '../..';
import {GroupChatSessionJoinEvent, PacketFlags} from '../..';
export class CommunicationsCommands extends CommandsBase
{
@@ -361,132 +357,6 @@ export class CommunicationsCommands extends CommandsBase
});
}
async acceptFriendRequest(event: FriendRequestEvent): Promise<void>
{
const accept: AcceptFriendshipMessage = new AcceptFriendshipMessage();
accept.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
accept.TransactionBlock = {
TransactionID: event.requestID
};
accept.FolderData = [];
accept.FolderData.push(
{
'FolderID': this.agent.inventory.findFolderForType(AssetType.CallingCard)
}
);
const sequenceNo = this.circuit.sendMessage(accept, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
async sendFriendRequest(to: UUID | string, message: string): Promise<void>
{
if (typeof to === 'string')
{
to = new UUID(to);
}
const requestID = UUID.random();
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
im.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
im.MessageBlock = {
FromGroup: false,
ToAgentID: to,
ParentEstateID: 0,
RegionID: UUID.zero(),
Position: Vector3.getZero(),
Offline: 0,
Dialog: InstantMessageDialog.FriendshipOffered,
ID: requestID,
Timestamp: Math.floor(new Date().getTime() / 1000),
FromAgentName: Utils.StringToBuffer(agentName),
Message: Utils.StringToBuffer(message),
BinaryBucket: Utils.StringToBuffer('')
};
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = this.circuit.sendMessage(im, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
private async respondToInventoryOffer(event: InventoryOfferedEvent, response: InstantMessageDialog): Promise<void>
{
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
const folder = this.agent.inventory.findFolderForType(event.type);
const binary = Buffer.allocUnsafe(16);
folder.writeToBuffer(binary, 0);
im.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
im.MessageBlock = {
FromGroup: false,
ToAgentID: event.from,
ParentEstateID: 0,
RegionID: UUID.zero(),
Position: Vector3.getZero(),
Offline: 0,
Dialog: response,
ID: event.requestID,
Timestamp: Math.floor(new Date().getTime() / 1000),
FromAgentName: Utils.StringToBuffer(agentName),
Message: Utils.StringToBuffer(''),
BinaryBucket: binary
};
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = this.circuit.sendMessage(im, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
async acceptInventoryOffer(event: InventoryOfferedEvent): Promise<void>
{
if (event.source === ChatSourceType.Object)
{
return await this.respondToInventoryOffer(event, InstantMessageDialog.TaskInventoryAccepted);
}
else
{
return await this.respondToInventoryOffer(event, InstantMessageDialog.InventoryAccepted);
}
}
async rejectInventoryOffer(event: InventoryOfferedEvent): Promise<void>
{
if (event.source === ChatSourceType.Object)
{
return await this.respondToInventoryOffer(event, InstantMessageDialog.TaskInventoryDeclined);
}
else
{
return await this.respondToInventoryOffer(event, InstantMessageDialog.InventoryDeclined);
}
}
async rejectFriendRequest(event: FriendRequestEvent): Promise<void>
{
const reject: DeclineFriendshipMessage = new DeclineFriendshipMessage();
reject.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
reject.TransactionBlock = {
TransactionID: event.requestID
};
const sequenceNo = this.circuit.sendMessage(reject, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
sendGroupMessage(groupID: UUID | string, message: string): Promise<number>
{
return new Promise<number>((resolve, reject) =>

View File

@@ -0,0 +1,311 @@
import {CommandsBase} from './CommandsBase';
import {Region} from '../Region';
import {Agent} from '../Agent';
import {Bot} from '../../Bot';
import {Subscription} from 'rxjs/internal/Subscription';
import {Message} from '../../enums/Message';
import {Packet} from '../Packet';
import {OnlineNotificationMessage} from '../messages/OnlineNotification';
import {OfflineNotificationMessage} from '../messages/OfflineNotification';
import {TerminateFriendshipMessage} from '../messages/TerminateFriendship';
import {AssetType, Friend, FriendOnlineEvent, FriendRemovedEvent, FriendRequestEvent, FriendRightsEvent, MapInfoReplyEvent, MapLocation, PacketFlags, RightsFlags, UUID, Vector3} from '../..';
import {AcceptFriendshipMessage} from '../messages/AcceptFriendship';
import {ImprovedInstantMessageMessage} from '../messages/ImprovedInstantMessage';
import {InstantMessageDialog} from '../../enums/InstantMessageDialog';
import {Utils} from '../Utils';
import {DeclineFriendshipMessage} from '../messages/DeclineFriendship';
import {ChangeUserRightsMessage} from '../messages/ChangeUserRights';
import {FindAgentMessage} from '../messages/FindAgent';
import {IPAddress} from '../IPAddress';
import {FilterResponse} from '../../enums/FilterResponse';
import {GrantUserRightsMessage} from '../messages/GrantUserRights';
export class FriendCommands extends CommandsBase
{
friendMessages: Subscription;
friendsList: {
[key: string]: Friend
} = {};
constructor(region: Region, agent: Agent, bot: Bot)
{
super(region, agent, bot);
// FriendResponse is handled by Comms because it's part of the InstantMessageImproved module.
// We don't handle it here because it's always accompanied by an OnlineNotificationMessage.
this.friendMessages = this.circuit.subscribeToMessages([
Message.OnlineNotification,
Message.OfflineNotification,
Message.TerminateFriendship,
Message.ChangeUserRights
], async (packet: Packet) =>
{
switch (packet.message.id)
{
case Message.OnlineNotification:
{
const msg = packet.message as OnlineNotificationMessage;
for (const agentEntry of msg.AgentBlock)
{
const uuidStr = agentEntry.AgentID.toString();
if (this.friendsList[uuidStr] === undefined)
{
this.friendsList[uuidStr] = await this.bot.clientCommands.grid.avatarKey2Name(agentEntry.AgentID) as Friend;
this.friendsList[uuidStr].online = false;
this.friendsList[uuidStr].myRights = RightsFlags.None;
this.friendsList[uuidStr].theirRights = RightsFlags.None;
}
if (this.friendsList[uuidStr].online !== true)
{
this.friendsList[uuidStr].online = true;
const friendOnlineEvent = new FriendOnlineEvent();
friendOnlineEvent.friend = this.friendsList[uuidStr];
friendOnlineEvent.online = true;
this.bot.clientEvents.onFriendOnline.next(friendOnlineEvent);
}
}
break;
}
case Message.OfflineNotification:
{
const msg = packet.message as OfflineNotificationMessage;
for (const agentEntry of msg.AgentBlock)
{
const uuidStr = agentEntry.AgentID.toString();
if (this.friendsList[uuidStr] === undefined)
{
this.friendsList[uuidStr] = await this.bot.clientCommands.grid.avatarKey2Name(agentEntry.AgentID) as Friend;
this.friendsList[uuidStr].online = false;
this.friendsList[uuidStr].myRights = RightsFlags.None;
this.friendsList[uuidStr].theirRights = RightsFlags.None;
}
if (this.friendsList[uuidStr].online !== false)
{
this.friendsList[uuidStr].online = false;
const friendOnlineEvent = new FriendOnlineEvent();
friendOnlineEvent.friend = this.friendsList[uuidStr];
friendOnlineEvent.online = false;
this.bot.clientEvents.onFriendOnline.next(friendOnlineEvent);
}
}
break;
}
case Message.TerminateFriendship:
{
const msg = packet.message as TerminateFriendshipMessage;
const friendID = msg.ExBlock.OtherID;
const uuidStr = friendID.toString();
if (this.friendsList[uuidStr] !== undefined)
{
const event = new FriendRemovedEvent();
event.friend = this.friendsList[uuidStr];
this.bot.clientEvents.onFriendRemoved.next(event);
delete this.friendsList[uuidStr];
}
break;
}
case Message.ChangeUserRights:
{
const msg = packet.message as ChangeUserRightsMessage;
for (const rightsEntry of msg.Rights)
{
let uuidStr = '';
if (rightsEntry.AgentRelated.equals(this.agent.agentID))
{
// My rights
uuidStr = msg.AgentData.AgentID.toString();
if (this.friendsList[uuidStr] === undefined)
{
this.friendsList[uuidStr] = await this.bot.clientCommands.grid.avatarKey2Name(rightsEntry.AgentRelated) as Friend;
this.friendsList[uuidStr].online = false;
this.friendsList[uuidStr].myRights = RightsFlags.None;
this.friendsList[uuidStr].theirRights = RightsFlags.None;
}
this.friendsList[uuidStr].myRights = rightsEntry.RelatedRights;
}
else
{
uuidStr = rightsEntry.AgentRelated.toString();
if (this.friendsList[uuidStr] === undefined)
{
this.friendsList[uuidStr] = await this.bot.clientCommands.grid.avatarKey2Name(rightsEntry.AgentRelated) as Friend;
this.friendsList[uuidStr].online = false;
this.friendsList[uuidStr].myRights = RightsFlags.None;
this.friendsList[uuidStr].theirRights = RightsFlags.None;
}
this.friendsList[uuidStr].theirRights = rightsEntry.RelatedRights;
}
const friendRightsEvent = new FriendRightsEvent();
friendRightsEvent.friend = this.friendsList[uuidStr];
friendRightsEvent.theirRights = this.friendsList[uuidStr].theirRights;
friendRightsEvent.myRights = this.friendsList[uuidStr].myRights;
this.bot.clientEvents.onFriendRights.next(friendRightsEvent);
}
break;
}
}
});
}
async grantFriendRights(friend: Friend | UUID | string, rights: RightsFlags)
{
let friendKey = UUID.zero();
if (friend instanceof UUID)
{
friendKey = friend;
}
else if (friend instanceof Friend)
{
friendKey = friend.getKey();
}
else if (typeof friend === 'string')
{
friendKey = new UUID(friend);
}
else
{
throw new Error('"Friend" parameter must be Friend, UUID or string');
}
const request: GrantUserRightsMessage = new GrantUserRightsMessage();
request.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
request.Rights = [
{
'AgentRelated': friendKey,
'RelatedRights': rights
}
];
const sequenceNo = this.circuit.sendMessage(request, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
async getFriendMapLocation(friend: Friend | UUID | string): Promise<MapLocation>
{
let friendKey = UUID.zero();
if (friend instanceof UUID)
{
friendKey = friend;
}
else if (friend instanceof Friend)
{
friendKey = friend.getKey();
}
else if (typeof friend === 'string')
{
friendKey = new UUID(friend);
}
else
{
throw new Error('"Friend" parameter must be Friend, UUID or string');
}
const request: FindAgentMessage = new FindAgentMessage();
request.AgentBlock = {
'Hunter': this.agent.agentID,
'Prey': friendKey,
'SpaceIP': IPAddress.zero()
};
request.LocationBlock = [
{
GlobalX: 0.0,
GlobalY: 0.0
}
];
this.circuit.sendMessage(request, PacketFlags.Reliable);
const response: FindAgentMessage = await this.circuit.waitForMessage<FindAgentMessage>(Message.FindAgent, 10000, (filterMsg: FindAgentMessage) =>
{
if (filterMsg.AgentBlock.Hunter.equals(this.agent.agentID) && filterMsg.AgentBlock.Prey.equals(friendKey))
{
return FilterResponse.Finish;
}
return FilterResponse.NoMatch;
});
const globalPos = Utils.RegionCoordinatesToHandle(response.LocationBlock[0].GlobalX, response.LocationBlock[0].GlobalY);
const mapInfo = await this.bot.clientCommands.grid.getRegionMapInfo(globalPos.regionX, globalPos.regionY);
return {
'regionName': mapInfo.block.name,
'mapImage': mapInfo.block.mapImage,
'regionHandle': globalPos.regionHandle,
'regionX': globalPos.regionX,
'regionY': globalPos.regionY,
'localX': Math.floor(globalPos.localX),
'localY': Math.floor(globalPos.localY),
'avatars': mapInfo.avatars
};
}
async acceptFriendRequest(event: FriendRequestEvent): Promise<void>
{
const accept: AcceptFriendshipMessage = new AcceptFriendshipMessage();
accept.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
accept.TransactionBlock = {
TransactionID: event.requestID
};
accept.FolderData = [];
accept.FolderData.push(
{
'FolderID': this.agent.inventory.findFolderForType(AssetType.CallingCard)
}
);
const sequenceNo = this.circuit.sendMessage(accept, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
async rejectFriendRequest(event: FriendRequestEvent): Promise<void>
{
const reject: DeclineFriendshipMessage = new DeclineFriendshipMessage();
reject.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
reject.TransactionBlock = {
TransactionID: event.requestID
};
const sequenceNo = this.circuit.sendMessage(reject, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
async sendFriendRequest(to: UUID | string, message: string): Promise<void>
{
if (typeof to === 'string')
{
to = new UUID(to);
}
const requestID = UUID.random();
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
im.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
im.MessageBlock = {
FromGroup: false,
ToAgentID: to,
ParentEstateID: 0,
RegionID: UUID.zero(),
Position: Vector3.getZero(),
Offline: 0,
Dialog: InstantMessageDialog.FriendshipOffered,
ID: requestID,
Timestamp: Math.floor(new Date().getTime() / 1000),
FromAgentName: Utils.StringToBuffer(agentName),
Message: Utils.StringToBuffer(message),
BinaryBucket: Utils.StringToBuffer('')
};
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = this.circuit.sendMessage(im, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
shutdown()
{
this.friendMessages.unsubscribe();
}
}

View File

@@ -1,4 +1,3 @@
import {Packet} from '../Packet';
import * as Long from 'long';
import {MapItemReplyMessage} from '../messages/MapItemReply';
import {Message} from '../../enums/Message';
@@ -15,8 +14,11 @@ import {FilterResponse} from '../../enums/FilterResponse';
import {MapNameRequestMessage} from '../messages/MapNameRequest';
import {GridLayerType} from '../../enums/GridLayerType';
import {MapBlock} from '../MapBlock';
import {MapInfoRangeReplyEvent, MapInfoReplyEvent, PacketFlags, RegionInfoReplyEvent} from '../..';
import {Avatar, MapInfoRangeReplyEvent, MapInfoReplyEvent, PacketFlags, RegionInfoReplyEvent, Vector2} from '../..';
import {TimeoutError} from '../TimeoutError';
import {UUIDNameRequestMessage} from '../messages/UUIDNameRequest';
import {UUIDNameReplyMessage} from '../messages/UUIDNameReply';
export class GridCommands extends CommandsBase
{
getRegionByName(regionName: string)
@@ -69,7 +71,7 @@ export class GridCommands extends CommandsBase
waterHeight = region.WaterHeight;
agents = region.Agents;
mapImageID = region.MapImageID;
handle = Utils.RegionCoordinatesToHandle(region.X * 256, region.Y * 256)
handle = Utils.RegionCoordinatesToHandle(region.X * 256, region.Y * 256).regionHandle;
};
resolve(reply);
}
@@ -130,7 +132,7 @@ export class GridCommands extends CommandsBase
});
// Now get the region handle
const regionHandle: Long = Utils.RegionCoordinatesToHandle(gridX * 256, gridY * 256);
const regionHandle: Long = Utils.RegionCoordinatesToHandle(gridX * 256, gridY * 256).regionHandle;
const mi = new MapItemRequestMessage();
mi.AgentData = {
@@ -173,10 +175,10 @@ export class GridCommands extends CommandsBase
{
responseMsg2.Data.forEach((data) =>
{
response.avatars.push({
X: data.X,
Y: data.Y
});
response.avatars.push(new Vector2([
data.X,
data.Y
]));
});
resolve(response);
}).catch((err) =>
@@ -249,7 +251,7 @@ export class GridCommands extends CommandsBase
});
}
name2Key(name: string): Promise<UUID>
avatarName2Key(name: string): Promise<UUID>
{
const check = name.split('.');
if (check.length > 1)
@@ -313,4 +315,83 @@ export class GridCommands extends CommandsBase
});
});
}
avatarKey2Name(uuid: UUID | UUID[]): Promise<Avatar | Avatar[]>
{
return new Promise<Avatar | Avatar[]>(async (resolve, reject) =>
{
const req = new UUIDNameRequestMessage();
req.UUIDNameBlock = [];
let arr = true;
if (!Array.isArray(uuid))
{
arr = false;
uuid = [uuid];
}
const waitingFor: any = {};
let remaining = 0;
for (const id of uuid)
{
waitingFor[id.toString()] = null;
req.UUIDNameBlock.push({'ID': id});
remaining++;
}
this.circuit.sendMessage(req, PacketFlags.Reliable);
try
{
await this.circuit.waitForMessage<UUIDNameReplyMessage>(Message.UUIDNameReply, 10000, (reply: UUIDNameReplyMessage): FilterResponse =>
{
let found = false;
for (const name of reply.UUIDNameBlock)
{
if (waitingFor[name.ID.toString()] !== undefined)
{
found = true;
if (waitingFor[name.ID.toString()] === null)
{
waitingFor[name.ID.toString()] = {
'firstName': Utils.BufferToStringSimple(name.FirstName),
'lastName': Utils.BufferToStringSimple(name.LastName)
};
remaining--;
}
}
}
if (remaining < 1)
{
return FilterResponse.Finish;
}
else if (found)
{
return FilterResponse.Match;
}
return FilterResponse.NoMatch;
});
if (!arr)
{
const result = waitingFor[uuid[0].toString()];
const av = new Avatar(uuid[0], result.firstName, result.lastName);
resolve(av);
}
else
{
const response: Avatar[] = [];
for (const k of uuid)
{
const result = waitingFor[k.toString()];
const av = new Avatar(k, result.firstName, result.lastName);
response.push(av);
}
resolve(response);
}
}
catch (e)
{
reject(e);
}
});
}
}

View File

@@ -1,5 +1,9 @@
import {CommandsBase} from './CommandsBase';
import {InventoryFolder} from '../InventoryFolder';
import {ChatSourceType, InventoryOfferedEvent, PacketFlags, UUID, Vector3} from '../..';
import {InstantMessageDialog} from '../../enums/InstantMessageDialog';
import {ImprovedInstantMessageMessage} from '../messages/ImprovedInstantMessage';
import {Utils} from '../Utils';
export class InventoryCommands extends CommandsBase
{
@@ -11,4 +15,61 @@ export class InventoryCommands extends CommandsBase
{
return this.agent.inventory.getRootFolderLibrary();
}
}
private async respondToInventoryOffer(event: InventoryOfferedEvent, response: InstantMessageDialog): Promise<void>
{
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
const folder = this.agent.inventory.findFolderForType(event.type);
const binary = Buffer.allocUnsafe(16);
folder.writeToBuffer(binary, 0);
im.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
im.MessageBlock = {
FromGroup: false,
ToAgentID: event.from,
ParentEstateID: 0,
RegionID: UUID.zero(),
Position: Vector3.getZero(),
Offline: 0,
Dialog: response,
ID: event.requestID,
Timestamp: Math.floor(new Date().getTime() / 1000),
FromAgentName: Utils.StringToBuffer(agentName),
Message: Utils.StringToBuffer(''),
BinaryBucket: binary
};
im.EstateBlock = {
EstateID: 0
};
const sequenceNo = this.circuit.sendMessage(im, PacketFlags.Reliable);
return await this.circuit.waitForAck(sequenceNo, 10000);
}
async acceptInventoryOffer(event: InventoryOfferedEvent): Promise<void>
{
if (event.source === ChatSourceType.Object)
{
return await this.respondToInventoryOffer(event, InstantMessageDialog.TaskInventoryAccepted);
}
else
{
return await this.respondToInventoryOffer(event, InstantMessageDialog.InventoryAccepted);
}
}
async rejectInventoryOffer(event: InventoryOfferedEvent): Promise<void>
{
if (event.source === ChatSourceType.Object)
{
return await this.respondToInventoryOffer(event, InstantMessageDialog.TaskInventoryDeclined);
}
else
{
return await this.respondToInventoryOffer(event, InstantMessageDialog.InventoryDeclined);
}
}
}

View File

@@ -0,0 +1,25 @@
import {UUID} from '../UUID';
export class Avatar
{
constructor(private avatarKey: UUID, private firstName: string, private lastName: string)
{
}
getName(): string
{
return this.firstName + ' ' + this.lastName;
}
getFirstName(): string
{
return this.firstName;
}
getLastName(): string
{
return this.lastName;
}
getKey(): UUID
{
return this.avatarKey;
}
}

View File

@@ -0,0 +1,9 @@
import {Avatar} from './Avatar';
import {RightsFlags} from '../..';
export class Friend extends Avatar
{
online: boolean;
theirRights: RightsFlags = RightsFlags.None;
myRights: RightsFlags = RightsFlags.None;
}

View File

@@ -0,0 +1,10 @@
import * as Long from 'long';
export interface GlobalPosition
{
regionHandle: Long;
regionX: number;
regionY: number;
localX: number;
localY: number;
}

View File

@@ -0,0 +1,14 @@
import {UUID} from '../../UUID';
import * as Long from 'long';
import {Vector2} from '../../Vector2';
export interface MapLocation {
'regionName': string;
'mapImage': UUID;
'regionHandle': Long,
'regionX': number,
'regionY': number,
'localX': number,
'localY': number,
'avatars': Vector2[]
}

7
lib/enums/RightsFlags.ts Normal file
View File

@@ -0,0 +1,7 @@
export enum RightsFlags
{
None = 0,
CanSeeOnline = 1,
CanSeeOnMap = 2,
CanModifyObjects = 4
}

View File

@@ -0,0 +1,7 @@
import {Friend} from '..';
export class FriendOnlineEvent
{
friend: Friend;
online: boolean;
}

View File

@@ -0,0 +1,6 @@
import {Friend} from '..';
export class FriendRemovedEvent
{
friend: Friend;
}

View File

@@ -0,0 +1,8 @@
import {Friend, RightsFlags} from '..';
export class FriendRightsEvent
{
friend: Friend;
myRights: RightsFlags;
theirRights: RightsFlags;
}

View File

@@ -1,10 +1,8 @@
import {MapBlock} from '../classes/MapBlock';
import {Vector2} from '..';
export class MapInfoReplyEvent
{
block: MapBlock;
avatars: {
X: number,
Y: number
}[]
avatars: Vector2[]
}

View File

@@ -41,6 +41,15 @@ import {ParcelInfoReplyEvent} from './events/ParcelInfoReplyEvent';
import {ScriptDialogEvent} from './events/ScriptDialogEvent';
import {EventQueueStateChangeEvent} from './events/EventQueueStateChangeEvent';
import {RegionFlags} from './enums/RegionFlags';
import {Friend} from './classes/public/Friend';
import {FriendOnlineEvent} from './events/FriendOnlineEvent';
import {Avatar} from './classes/public/Avatar';
import {RightsFlags} from './enums/RightsFlags';
import {FriendRightsEvent} from './events/FriendRightsEvent';
import {FriendRemovedEvent} from './events/FriendRemovedEvent';
import {GlobalPosition} from './classes/public/interfaces/GlobalPosition';
import {MapLocation} from './classes/public/interfaces/MapLocation';
import {Vector2} from './classes/Vector2';
export {
Bot,
@@ -53,6 +62,7 @@ export {
BotOptionFlags,
UUID,
Vector3,
Vector2,
// Flags
AgentFlags,
@@ -69,6 +79,7 @@ export {
SoundFlags,
TeleportFlags,
RegionFlags,
RightsFlags,
// Events
ChatEvent,
@@ -88,5 +99,16 @@ export {
RegionInfoReplyEvent,
TeleportEvent,
ScriptDialogEvent,
EventQueueStateChangeEvent
EventQueueStateChangeEvent,
FriendOnlineEvent,
FriendRightsEvent,
FriendRemovedEvent,
// Public Classes
Avatar,
Friend,
// Public Interfaces
GlobalPosition,
MapLocation
};

View File

@@ -1,6 +1,6 @@
{
"name": "@caspertech/node-metaverse",
"version": "0.4.9",
"version": "0.5.0",
"description": "A node.js interface for Second Life.",
"main": "dist/index.js",
"types": "dist/index.d.ts",