Get group member list, Get group roles, Send group invite
This commit is contained in:
5
dist/Bot.js
vendored
5
dist/Bot.js
vendored
@@ -16,6 +16,7 @@ const TeleportEventType_1 = require("./enums/TeleportEventType");
|
||||
const ClientCommands_1 = require("./classes/ClientCommands");
|
||||
const DisconnectEvent_1 = require("./events/DisconnectEvent");
|
||||
const StartPingCheck_1 = require("./classes/messages/StartPingCheck");
|
||||
const FilterResponse_1 = require("./enums/FilterResponse");
|
||||
class Bot {
|
||||
constructor(login, options) {
|
||||
this.ping = null;
|
||||
@@ -151,9 +152,9 @@ class Bot {
|
||||
if (this.clientEvents !== null) {
|
||||
this.clientEvents.onCircuitLatency.next(pingTime);
|
||||
}
|
||||
return true;
|
||||
return FilterResponse_1.FilterResponse.Finish;
|
||||
}
|
||||
return false;
|
||||
return FilterResponse_1.FilterResponse.NoMatch;
|
||||
}).bind(this, {
|
||||
pingID: this.pingNumber,
|
||||
timeSent: new Date().getTime()
|
||||
|
||||
2
dist/Bot.js.map
vendored
2
dist/Bot.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/classes/Circuit.d.ts
vendored
3
dist/classes/Circuit.d.ts
vendored
@@ -8,6 +8,7 @@ import { Message } from '../enums/Message';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import 'rxjs/add/operator/filter';
|
||||
import { ClientEvents } from "./ClientEvents";
|
||||
import { FilterResponse } from '../enums/FilterResponse';
|
||||
export declare class Circuit {
|
||||
secureSessionID: UUID;
|
||||
sessionID: UUID;
|
||||
@@ -38,7 +39,7 @@ export declare class Circuit {
|
||||
waitForAck(ack: number, timeout: number): Promise<void>;
|
||||
init(): void;
|
||||
shutdown(): void;
|
||||
waitForMessage(id: Message, timeout: number, filter?: (packet: Packet) => boolean): Promise<Packet>;
|
||||
waitForMessage(id: Message, timeout: number, filter?: (packet: Packet) => FilterResponse): Promise<Packet>;
|
||||
sendPacket(packet: Packet): void;
|
||||
ackReceived(sequenceNumber: number): void;
|
||||
sendAck(sequenceNumber: number): void;
|
||||
|
||||
26
dist/classes/Circuit.js
vendored
26
dist/classes/Circuit.js
vendored
@@ -8,6 +8,7 @@ const Message_1 = require("../enums/Message");
|
||||
const CompletePingCheck_1 = require("./messages/CompletePingCheck");
|
||||
const Subject_1 = require("rxjs/Subject");
|
||||
require("rxjs/add/operator/filter");
|
||||
const FilterResponse_1 = require("../enums/FilterResponse");
|
||||
class Circuit {
|
||||
constructor(clientEvents) {
|
||||
this.client = null;
|
||||
@@ -107,14 +108,33 @@ class Circuit {
|
||||
timeout: null,
|
||||
subscription: null
|
||||
};
|
||||
handleObj.timeout = setTimeout(() => {
|
||||
const timeoutFunc = () => {
|
||||
if (handleObj.subscription !== null) {
|
||||
handleObj.subscription.unsubscribe();
|
||||
reject(new Error('Timeout'));
|
||||
}
|
||||
}, timeout);
|
||||
};
|
||||
handleObj.timeout = setTimeout(timeoutFunc, timeout);
|
||||
handleObj.subscription = this.subscribeToMessages([id], (packet) => {
|
||||
if (packet.message.id === id && (filter === undefined || filter(packet))) {
|
||||
let finish = false;
|
||||
if (packet.message.id === id) {
|
||||
if (filter === undefined) {
|
||||
finish = true;
|
||||
}
|
||||
else {
|
||||
const filterResult = filter(packet);
|
||||
if (filterResult === FilterResponse_1.FilterResponse.Finish) {
|
||||
finish = true;
|
||||
}
|
||||
else if (filterResult === FilterResponse_1.FilterResponse.Match) {
|
||||
if (handleObj.timeout !== null) {
|
||||
clearTimeout(handleObj.timeout);
|
||||
}
|
||||
handleObj.timeout = setTimeout(timeoutFunc, timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (finish) {
|
||||
if (handleObj.timeout !== null) {
|
||||
clearTimeout(handleObj.timeout);
|
||||
handleObj.timeout = null;
|
||||
|
||||
2
dist/classes/Circuit.js.map
vendored
2
dist/classes/Circuit.js.map
vendored
File diff suppressed because one or more lines are too long
8
dist/classes/EventQueueClient.js
vendored
8
dist/classes/EventQueueClient.js
vendored
@@ -72,15 +72,15 @@ class EventQueueClient {
|
||||
if (event['body'] && event['body']['instantmessage'] && event['body']['instantmessage']['message_params'] && event['body']['instantmessage']['message_params']['id']) {
|
||||
const messageParams = event['body']['instantmessage']['message_params'];
|
||||
const imSessionID = messageParams['id'];
|
||||
const requestedFolders = {
|
||||
'method': 'accept invitation',
|
||||
'session-id': imSessionID
|
||||
};
|
||||
const groupChatEvent = new GroupChatEvent_1.GroupChatEvent();
|
||||
groupChatEvent.from = new UUID_1.UUID(messageParams['from_id'].toString());
|
||||
groupChatEvent.fromName = messageParams['from_name'];
|
||||
groupChatEvent.groupID = new UUID_1.UUID(messageParams['id'].toString());
|
||||
groupChatEvent.message = messageParams['message'];
|
||||
const requestedFolders = {
|
||||
'method': 'accept invitation',
|
||||
'session-id': imSessionID
|
||||
};
|
||||
this.caps.capsRequestXML('ChatSessionRequest', requestedFolders).then((result) => {
|
||||
this.agent.addChatSession(groupChatEvent.groupID);
|
||||
const gcsje = new GroupChatSessionJoinEvent_1.GroupChatSessionJoinEvent();
|
||||
|
||||
2
dist/classes/EventQueueClient.js.map
vendored
2
dist/classes/EventQueueClient.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/classes/Utils.d.ts
vendored
1
dist/classes/Utils.d.ts
vendored
@@ -13,4 +13,5 @@ export declare class Utils {
|
||||
static UInt16ToFloat(val: number, lower: number, upper: number): number;
|
||||
static Base64EncodeString(str: string): string;
|
||||
static Base64DecodeString(str: string): string;
|
||||
static HexToLong(hex: string): Long;
|
||||
}
|
||||
|
||||
6
dist/classes/Utils.js
vendored
6
dist/classes/Utils.js
vendored
@@ -104,6 +104,12 @@ class Utils {
|
||||
const buff = new Buffer(str, 'base64');
|
||||
return buff.toString('utf8');
|
||||
}
|
||||
static HexToLong(hex) {
|
||||
while (hex.length < 16) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
return new Long(parseInt(hex.substr(8), 16), parseInt(hex.substr(0, 8), 16));
|
||||
}
|
||||
}
|
||||
exports.Utils = Utils;
|
||||
//# sourceMappingURL=Utils.js.map
|
||||
2
dist/classes/Utils.js.map
vendored
2
dist/classes/Utils.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../lib/classes/Utils.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,oDAA+C;AAE/C;IAEI,MAAM,CAAC,cAAc,CAAC,GAAW;QAE7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,CAAC,oBAAoB,CAAC,GAAW,EAAE,QAAiB;QAEtD,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CACrB,CAAC;YACG,MAAM,CAAC,EAAE,CAAC;QACd,CAAC;QACD,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAC9B,CAAC;YACG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CACJ,CAAC;YACG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;IACL,CAAC;IACD,MAAM,CAAC,cAAc,CAAC,GAAW,EAAE,QAAiB;QAMhD,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CACrB,CAAC;YACG,MAAM,CAAC;gBACH,UAAU,EAAE,CAAC;gBACb,MAAM,EAAE,EAAE;aACb,CAAC;QACN,CAAC;QACD,EAAE,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAC3B,CAAC;YACG,QAAQ,GAAG,CAAC,CAAC;QACjB,CAAC;QAED,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC;QACnB,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,I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,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;CACJ;AA1ID,sBA0IC"}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CommandsBase } from './CommandsBase';
|
||||
import { UUID } from '../UUID';
|
||||
import { ChatType } from '../../enums/ChatType';
|
||||
import { GroupInviteEvent } from '../../events/GroupInviteEvent';
|
||||
export declare class CommunicationsCommands extends CommandsBase {
|
||||
sendInstantMessage(to: UUID | string, message: string): Promise<void>;
|
||||
nearbyChat(message: string, type: ChatType, channel?: number): Promise<void>;
|
||||
@@ -12,10 +11,8 @@ export declare class CommunicationsCommands extends CommandsBase {
|
||||
stopTypingLocal(): Promise<void>;
|
||||
startTypingIM(to: UUID | string): Promise<void>;
|
||||
stopTypingIM(to: UUID | string): Promise<void>;
|
||||
acceptGroupInvite(event: GroupInviteEvent): Promise<void>;
|
||||
rejectGroupInvite(event: GroupInviteEvent): Promise<void>;
|
||||
typeInstantMessage(to: UUID | string, message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>;
|
||||
startGroupSession(sessionID: UUID | string, message: string): Promise<void>;
|
||||
sendGroupMessage(groupID: UUID | string, message: string): Promise<void>;
|
||||
typeLocalMessage(message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>;
|
||||
startGroupChatSession(sessionID: UUID | string, message: string): Promise<void>;
|
||||
sendGroupMessage(groupID: UUID | string, message: string): Promise<void>;
|
||||
}
|
||||
|
||||
132
dist/classes/commands/CommunicationsCommands.js
vendored
132
dist/classes/commands/CommunicationsCommands.js
vendored
@@ -157,62 +157,6 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
acceptGroupInvite(event) {
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID_1.UUID.zero(),
|
||||
Position: Vector3_1.Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog_1.InstantMessageDialog.GroupInvitationAccept,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
|
||||
Message: Utils_1.Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
rejectGroupInvite(event) {
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID_1.UUID.zero(),
|
||||
Position: Vector3_1.Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog_1.InstantMessageDialog.GroupInvitationDecline,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
|
||||
Message: Utils_1.Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
typeInstantMessage(to, message, thinkingTime, charactersPerSecond) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (thinkingTime === undefined) {
|
||||
@@ -257,7 +201,43 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
|
||||
}, thinkingTime);
|
||||
});
|
||||
}
|
||||
startGroupSession(sessionID, message) {
|
||||
typeLocalMessage(message, thinkingTime, charactersPerSecond) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (thinkingTime === undefined) {
|
||||
thinkingTime = 0;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.startTypingLocal().then(() => {
|
||||
this.bot.clientCommands.agent.startAnimations([new UUID_1.UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() => {
|
||||
if (charactersPerSecond === undefined) {
|
||||
charactersPerSecond = 5;
|
||||
}
|
||||
const timeToWait = (message.length / charactersPerSecond) * 1000;
|
||||
setTimeout(() => {
|
||||
this.stopTypingLocal().then(() => {
|
||||
this.bot.clientCommands.agent.stopAnimations([new UUID_1.UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() => {
|
||||
this.say(message).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}, timeToWait);
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}, thinkingTime);
|
||||
});
|
||||
}
|
||||
startGroupChatSession(sessionID, message) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof sessionID === 'string') {
|
||||
sessionID = new UUID_1.UUID(sessionID);
|
||||
@@ -307,7 +287,7 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
|
||||
}
|
||||
sendGroupMessage(groupID, message) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.startGroupSession(groupID, message).then(() => {
|
||||
this.startGroupChatSession(groupID, message).then(() => {
|
||||
if (typeof groupID === 'string') {
|
||||
groupID = new UUID_1.UUID(groupID);
|
||||
}
|
||||
@@ -342,42 +322,6 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
|
||||
});
|
||||
});
|
||||
}
|
||||
typeLocalMessage(message, thinkingTime, charactersPerSecond) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (thinkingTime === undefined) {
|
||||
thinkingTime = 0;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.startTypingLocal().then(() => {
|
||||
this.bot.clientCommands.agent.startAnimations([new UUID_1.UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() => {
|
||||
if (charactersPerSecond === undefined) {
|
||||
charactersPerSecond = 5;
|
||||
}
|
||||
const timeToWait = (message.length / charactersPerSecond) * 1000;
|
||||
setTimeout(() => {
|
||||
this.stopTypingLocal().then(() => {
|
||||
this.bot.clientCommands.agent.stopAnimations([new UUID_1.UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() => {
|
||||
this.say(message).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}, timeToWait);
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}, thinkingTime);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CommunicationsCommands = CommunicationsCommands;
|
||||
//# sourceMappingURL=CommunicationsCommands.js.map
|
||||
File diff suppressed because one or more lines are too long
24
dist/classes/commands/GridCommands.js
vendored
24
dist/classes/commands/GridCommands.js
vendored
@@ -11,6 +11,7 @@ const PacketFlags_1 = require("../../enums/PacketFlags");
|
||||
const GridItemType_1 = require("../../enums/GridItemType");
|
||||
const CommandsBase_1 = require("./CommandsBase");
|
||||
const AvatarPickerRequest_1 = require("../messages/AvatarPickerRequest");
|
||||
const FilterResponse_1 = require("../../enums/FilterResponse");
|
||||
class GridCommands extends CommandsBase_1.CommandsBase {
|
||||
getRegionHandle(regionID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -22,7 +23,12 @@ class GridCommands extends CommandsBase_1.CommandsBase {
|
||||
circuit.sendMessage(msg, PacketFlags_1.PacketFlags.Reliable);
|
||||
circuit.waitForMessage(Message_1.Message.RegionIDAndHandleReply, 10000, (packet) => {
|
||||
const filterMsg = packet.message;
|
||||
return (filterMsg.ReplyBlock.RegionID.toString() === regionID.toString());
|
||||
if (filterMsg.ReplyBlock.RegionID.toString() === regionID.toString()) {
|
||||
return FilterResponse_1.FilterResponse.Finish;
|
||||
}
|
||||
else {
|
||||
return FilterResponse_1.FilterResponse.NoMatch;
|
||||
}
|
||||
}).then((packet) => {
|
||||
const responseMsg = packet.message;
|
||||
resolve(responseMsg.ReplyBlock.RegionHandle);
|
||||
@@ -56,7 +62,10 @@ class GridCommands extends CommandsBase_1.CommandsBase {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
if (found) {
|
||||
return FilterResponse_1.FilterResponse.Finish;
|
||||
}
|
||||
return FilterResponse_1.FilterResponse.NoMatch;
|
||||
}).then((packet) => {
|
||||
const responseMsg = packet.message;
|
||||
responseMsg.Data.forEach((data) => {
|
||||
@@ -93,7 +102,12 @@ class GridCommands extends CommandsBase_1.CommandsBase {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
if (found) {
|
||||
return FilterResponse_1.FilterResponse.Finish;
|
||||
}
|
||||
else {
|
||||
return FilterResponse_1.FilterResponse.NoMatch;
|
||||
}
|
||||
}).then((packet2) => {
|
||||
const responseMsg2 = packet2.message;
|
||||
responseMsg2.Data.forEach((data) => {
|
||||
@@ -135,10 +149,10 @@ class GridCommands extends CommandsBase_1.CommandsBase {
|
||||
this.circuit.waitForMessage(Message_1.Message.AvatarPickerReply, 10000, (packet) => {
|
||||
const apr = packet.message;
|
||||
if (apr.AgentData.QueryID.toString() === queryID.toString()) {
|
||||
return true;
|
||||
return FilterResponse_1.FilterResponse.Finish;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
return FilterResponse_1.FilterResponse.NoMatch;
|
||||
}
|
||||
}).then((packet) => {
|
||||
let found = null;
|
||||
|
||||
2
dist/classes/commands/GridCommands.js.map
vendored
2
dist/classes/commands/GridCommands.js.map
vendored
File diff suppressed because one or more lines are too long
14
dist/classes/commands/GroupCommands.d.ts
vendored
14
dist/classes/commands/GroupCommands.d.ts
vendored
@@ -1,5 +1,17 @@
|
||||
import { CommandsBase } from './CommandsBase';
|
||||
import { UUID } from '../UUID';
|
||||
import { GroupInviteEvent } from '../../events/GroupInviteEvent';
|
||||
import { GroupRole } from '../GroupRole';
|
||||
import { GroupMember } from '../GroupMember';
|
||||
export declare class GroupCommands extends CommandsBase {
|
||||
sendGroupNotice(group: UUID | string, subject: string, message: string): Promise<void>;
|
||||
sendGroupNotice(groupID: UUID | string, subject: string, message: string): Promise<void>;
|
||||
sendGroupInviteBulk(groupID: UUID | string, sendTo: {
|
||||
avatarID: UUID | string;
|
||||
roleID: UUID | string | undefined;
|
||||
}[]): Promise<void>;
|
||||
sendGroupInvite(groupID: UUID | string, to: UUID | string, role: UUID | string | undefined): Promise<void>;
|
||||
acceptGroupInvite(event: GroupInviteEvent): Promise<void>;
|
||||
rejectGroupInvite(event: GroupInviteEvent): Promise<void>;
|
||||
getMemberList(groupID: UUID | string): Promise<GroupMember[]>;
|
||||
getGroupRoles(groupID: UUID | string): Promise<GroupRole[]>;
|
||||
}
|
||||
|
||||
202
dist/classes/commands/GroupCommands.js
vendored
202
dist/classes/commands/GroupCommands.js
vendored
@@ -7,10 +7,17 @@ const Utils_1 = require("../Utils");
|
||||
const PacketFlags_1 = require("../../enums/PacketFlags");
|
||||
const ImprovedInstantMessage_1 = require("../messages/ImprovedInstantMessage");
|
||||
const Vector3_1 = require("../Vector3");
|
||||
const InviteGroupRequest_1 = require("../messages/InviteGroupRequest");
|
||||
const GroupRole_1 = require("../GroupRole");
|
||||
const GroupRoleDataRequest_1 = require("../messages/GroupRoleDataRequest");
|
||||
const Message_1 = require("../../enums/Message");
|
||||
const GroupMember_1 = require("../GroupMember");
|
||||
const FilterResponse_1 = require("../../enums/FilterResponse");
|
||||
const LLSD = require("llsd");
|
||||
class GroupCommands extends CommandsBase_1.CommandsBase {
|
||||
sendGroupNotice(group, subject, message) {
|
||||
if (typeof group === 'string') {
|
||||
group = new UUID_1.UUID(group);
|
||||
sendGroupNotice(groupID, subject, message) {
|
||||
if (typeof groupID === 'string') {
|
||||
groupID = new UUID_1.UUID(groupID);
|
||||
}
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
@@ -21,7 +28,7 @@ class GroupCommands extends CommandsBase_1.CommandsBase {
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: group,
|
||||
ToAgentID: groupID,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID_1.UUID.zero(),
|
||||
Position: Vector3_1.Vector3.getZero(),
|
||||
@@ -39,6 +46,193 @@ class GroupCommands extends CommandsBase_1.CommandsBase {
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
sendGroupInviteBulk(groupID, sendTo) {
|
||||
if (typeof groupID === 'string') {
|
||||
groupID = new UUID_1.UUID(groupID);
|
||||
}
|
||||
const igr = new InviteGroupRequest_1.InviteGroupRequestMessage();
|
||||
igr.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: this.circuit.sessionID
|
||||
};
|
||||
igr.GroupData = {
|
||||
GroupID: groupID
|
||||
};
|
||||
igr.InviteData = [];
|
||||
sendTo.forEach((to) => {
|
||||
if (typeof to.avatarID === 'string') {
|
||||
to.avatarID = new UUID_1.UUID(to.avatarID);
|
||||
}
|
||||
if (to.roleID === undefined) {
|
||||
to.roleID = UUID_1.UUID.zero();
|
||||
}
|
||||
if (typeof to.roleID === 'string') {
|
||||
to.roleID = new UUID_1.UUID(to.roleID);
|
||||
}
|
||||
igr.InviteData.push({
|
||||
InviteeID: to.avatarID,
|
||||
RoleID: to.roleID
|
||||
});
|
||||
});
|
||||
const sequenceNo = this.circuit.sendMessage(igr, PacketFlags_1.PacketFlags.Reliable);
|
||||
return this.circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
sendGroupInvite(groupID, to, role) {
|
||||
const sendTo = [{
|
||||
avatarID: to,
|
||||
roleID: role
|
||||
}];
|
||||
return this.sendGroupInviteBulk(groupID, sendTo);
|
||||
}
|
||||
acceptGroupInvite(event) {
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID_1.UUID.zero(),
|
||||
Position: Vector3_1.Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog_1.InstantMessageDialog.GroupInvitationAccept,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
|
||||
Message: Utils_1.Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
rejectGroupInvite(event) {
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID_1.UUID.zero(),
|
||||
Position: Vector3_1.Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog_1.InstantMessageDialog.GroupInvitationDecline,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
|
||||
Message: Utils_1.Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
getMemberList(groupID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof groupID === 'string') {
|
||||
groupID = new UUID_1.UUID(groupID);
|
||||
}
|
||||
const result = [];
|
||||
const requestData = {
|
||||
'group_id': new LLSD.UUID(groupID.toString())
|
||||
};
|
||||
this.currentRegion.caps.capsRequestXML('GroupMemberData', requestData).then((response) => {
|
||||
if (response['members']) {
|
||||
Object.keys(response['members']).forEach((uuid) => {
|
||||
const member = new GroupMember_1.GroupMember();
|
||||
const data = response['members'][uuid];
|
||||
member.AgentID = new UUID_1.UUID(uuid);
|
||||
member.OnlineStatus = data['last_login'];
|
||||
let powers = response['defaults']['default_powers'];
|
||||
if (data['powers']) {
|
||||
powers = data['powers'];
|
||||
}
|
||||
member.IsOwner = data['owner'] === 'Y';
|
||||
let titleIndex = 0;
|
||||
if (data['title']) {
|
||||
titleIndex = data['title'];
|
||||
}
|
||||
member.Title = response['titles'][titleIndex];
|
||||
member.AgentPowers = Utils_1.Utils.HexToLong(powers);
|
||||
result.push(member);
|
||||
});
|
||||
resolve(result);
|
||||
}
|
||||
else {
|
||||
reject(new Error('Bad response'));
|
||||
}
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
getGroupRoles(groupID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const result = [];
|
||||
if (typeof groupID === 'string') {
|
||||
groupID = new UUID_1.UUID(groupID);
|
||||
}
|
||||
const grdr = new GroupRoleDataRequest_1.GroupRoleDataRequestMessage();
|
||||
grdr.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: this.circuit.sessionID
|
||||
};
|
||||
const requestID = UUID_1.UUID.random();
|
||||
grdr.GroupData = {
|
||||
GroupID: groupID,
|
||||
RequestID: requestID
|
||||
};
|
||||
let totalRoleCount = 0;
|
||||
this.circuit.sendMessage(grdr, PacketFlags_1.PacketFlags.Reliable);
|
||||
this.circuit.waitForMessage(Message_1.Message.GroupRoleDataReply, 10000, (packet) => {
|
||||
const gmr = packet.message;
|
||||
if (gmr.GroupData.RequestID.toString() === requestID.toString()) {
|
||||
totalRoleCount = gmr.GroupData.RoleCount;
|
||||
gmr.RoleData.forEach((role) => {
|
||||
const gr = new GroupRole_1.GroupRole();
|
||||
gr.RoleID = role.RoleID;
|
||||
gr.Name = Utils_1.Utils.BufferToStringSimple(role.Name);
|
||||
gr.Title = Utils_1.Utils.BufferToStringSimple(role.Title);
|
||||
gr.Description = Utils_1.Utils.BufferToStringSimple(role.Description);
|
||||
gr.Powers = role.Powers;
|
||||
gr.Members = role.Members;
|
||||
result.push(gr);
|
||||
});
|
||||
if (totalRoleCount > result.length) {
|
||||
return FilterResponse_1.FilterResponse.Match;
|
||||
}
|
||||
else {
|
||||
return FilterResponse_1.FilterResponse.Finish;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return FilterResponse_1.FilterResponse.NoMatch;
|
||||
}
|
||||
}).then(() => {
|
||||
resolve(result);
|
||||
}).catch((err) => {
|
||||
if (result.length === 0) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.GroupCommands = GroupCommands;
|
||||
//# sourceMappingURL=GroupCommands.js.map
|
||||
2
dist/classes/commands/GroupCommands.js.map
vendored
2
dist/classes/commands/GroupCommands.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/index.d.ts
vendored
3
dist/index.d.ts
vendored
@@ -8,4 +8,5 @@ import { InstantMessageEventFlags } from './enums/InstantMessageEventFlags';
|
||||
import { InstantMessageEvent } from './events/InstantMessageEvent';
|
||||
import { ChatSourceType } from './enums/ChatSourceType';
|
||||
import { BotOptionFlags } from './enums/BotOptionFlags';
|
||||
export { Bot, LoginParameters, AssetType, HTTPAssets, ClientEvents, BVH, InstantMessageEvent, InstantMessageEventFlags, ChatSourceType, BotOptionFlags };
|
||||
import { UUID } from './classes/UUID';
|
||||
export { Bot, LoginParameters, AssetType, HTTPAssets, ClientEvents, BVH, InstantMessageEvent, InstantMessageEventFlags, ChatSourceType, BotOptionFlags, UUID };
|
||||
|
||||
2
dist/index.js
vendored
2
dist/index.js
vendored
@@ -20,4 +20,6 @@ const ChatSourceType_1 = require("./enums/ChatSourceType");
|
||||
exports.ChatSourceType = ChatSourceType_1.ChatSourceType;
|
||||
const BotOptionFlags_1 = require("./enums/BotOptionFlags");
|
||||
exports.BotOptionFlags = BotOptionFlags_1.BotOptionFlags;
|
||||
const UUID_1 = require("./classes/UUID");
|
||||
exports.UUID = UUID_1.UUID;
|
||||
//# sourceMappingURL=index.js.map
|
||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;AAAA,+BAA0B;AAgBtB,cAhBI,SAAG,CAgBJ;AAfP,+DAA0D;AAgBtD,0BAhBI,iCAAe,CAgBJ;AAfnB,yDAAoD;AAkBhD,uBAlBI,2BAAY,CAkBJ;AAjBhB,uCAAkC;AAkB9B,cAlBI,SAAG,CAkBJ;AAbP,iDAA4C;AAUxC,oBAVI,qBAAS,CAUJ;AATb,mDAA8C;AAU1C,qBAVI,uBAAU,CAUJ;AATd,+EAA0E;AAatE,mCAbI,mDAAwB,CAaJ;AAZ5B,sEAAiE;AAW7D,8BAXI,yCAAmB,CAWJ;AAVvB,2DAAsD;AAYlD,yBAZI,+BAAc,CAYJ;AAXlB,2DAAsD;AAYlD,yBAZI,+BAAc,CAYJ"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;AAAA,+BAA0B;AAiBtB,cAjBI,SAAG,CAiBJ;AAhBP,+DAA0D;AAiBtD,0BAjBI,iCAAe,CAiBJ;AAhBnB,yDAAoD;AAmBhD,uBAnBI,2BAAY,CAmBJ;AAlBhB,uCAAkC;AAmB9B,cAnBI,SAAG,CAmBJ;AAdP,iDAA4C;AAWxC,oBAXI,qBAAS,CAWJ;AAVb,mDAA8C;AAW1C,qBAXI,uBAAU,CAWJ;AAVd,+EAA0E;AActE,mCAdI,mDAAwB,CAcJ;AAb5B,sEAAiE;AAY7D,8BAZI,yCAAmB,CAYJ;AAXvB,2DAAsD;AAalD,yBAbI,+BAAc,CAaJ;AAZlB,2DAAsD;AAalD,yBAbI,+BAAc,CAaJ;AAZlB,yCAAoC;AAahC,eAbI,WAAI,CAaJ"}
|
||||
@@ -141,6 +141,47 @@ function connect()
|
||||
//bot.clientCommands.comms.typeLocalMessage('Never fear, I am here!', 2000);
|
||||
//bot.clientCommands.group.sendGroupNotice('503e8ef6-e119-ff5e-2524-24f290dd3867', 'Test', 'testy testy test');
|
||||
|
||||
// Group invite example
|
||||
// Just omit the role parameter for "everyone" role
|
||||
//
|
||||
// bot.clientCommands.group.sendGroupInvite("c6424e05-6e2c-fb03-220b-ca7904d11e04", "d1cd5b71-6209-4595-9bf0-771bf689ce00");
|
||||
|
||||
// Advanced group invite example
|
||||
//
|
||||
// Retrieve group roles
|
||||
|
||||
const userToInvite = new nmv.UUID("d1cd5b71-6209-4595-9bf0-771bf689ce00");
|
||||
const groupID = new nmv.UUID("c6424e05-6e2c-fb03-220b-ca7904d11e04");
|
||||
|
||||
bot.clientCommands.group.getGroupRoles(groupID).then((roles) =>
|
||||
{
|
||||
roles.forEach((role) =>
|
||||
{
|
||||
if (role.Name === 'Officers')
|
||||
{
|
||||
bot.clientCommands.group.getMemberList(groupID).then((members) =>
|
||||
{
|
||||
let found = true;
|
||||
members.forEach((member) =>
|
||||
{
|
||||
if (member.AgentID.toString() === userToInvite.toString())
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
if (found)
|
||||
{
|
||||
console.log("User already in group, skipping invite");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.clientCommands.group.sendGroupInvite(groupID, userToInvite , role.RoleID);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// When it's time to go home, call bot.close();
|
||||
}).catch((error) =>
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ import {CompletePingCheckMessage} from './classes/messages/CompletePingCheck';
|
||||
import Timer = NodeJS.Timer;
|
||||
import {Subscription} from 'rxjs/Subscription';
|
||||
import {BotOptionFlags} from './enums/BotOptionFlags';
|
||||
import {FilterResponse} from './enums/FilterResponse';
|
||||
|
||||
export class Bot
|
||||
{
|
||||
@@ -200,7 +201,7 @@ export class Bot
|
||||
circuit.waitForMessage(Message.CompletePingCheck, 10000, ((pingData: {
|
||||
pingID: number,
|
||||
timeSent: number
|
||||
}, packet: Packet): boolean =>
|
||||
}, packet: Packet): FilterResponse =>
|
||||
{
|
||||
const cpc = packet.message as CompletePingCheckMessage;
|
||||
if (cpc.PingID.PingID === pingData.pingID)
|
||||
@@ -211,9 +212,9 @@ export class Bot
|
||||
{
|
||||
this.clientEvents.onCircuitLatency.next(pingTime);
|
||||
}
|
||||
return true;
|
||||
return FilterResponse.Finish;
|
||||
}
|
||||
return false;
|
||||
return FilterResponse.NoMatch;
|
||||
}).bind(this, {
|
||||
pingID: this.pingNumber,
|
||||
timeSent: new Date().getTime()
|
||||
|
||||
@@ -13,6 +13,7 @@ import {Subject} from 'rxjs/Subject';
|
||||
import 'rxjs/add/operator/filter';
|
||||
import Timer = NodeJS.Timer;
|
||||
import {ClientEvents} from "./ClientEvents";
|
||||
import {FilterResponse} from '../enums/FilterResponse';
|
||||
|
||||
export class Circuit
|
||||
{
|
||||
@@ -170,7 +171,7 @@ export class Circuit
|
||||
}
|
||||
}
|
||||
|
||||
waitForMessage(id: Message, timeout: number, filter?: (packet: Packet) => boolean): Promise<Packet>
|
||||
waitForMessage(id: Message, timeout: number, filter?: (packet: Packet) => FilterResponse): Promise<Packet>
|
||||
{
|
||||
return new Promise<Packet>((resolve, reject) =>
|
||||
{
|
||||
@@ -181,32 +182,60 @@ export class Circuit
|
||||
timeout: null,
|
||||
subscription: null
|
||||
};
|
||||
handleObj.timeout = setTimeout(() =>
|
||||
|
||||
const timeoutFunc = () =>
|
||||
{
|
||||
if (handleObj.subscription !== null)
|
||||
{
|
||||
handleObj.subscription.unsubscribe();
|
||||
reject(new Error('Timeout'));
|
||||
}
|
||||
}, timeout);
|
||||
};
|
||||
|
||||
handleObj.timeout = setTimeout(timeoutFunc, timeout);
|
||||
|
||||
handleObj.subscription = this.subscribeToMessages([id], (packet: Packet) =>
|
||||
{
|
||||
let finish = false;
|
||||
if (packet.message.id === id)
|
||||
{
|
||||
if (packet.message.id === id && (filter === undefined || filter(packet)))
|
||||
if (filter === undefined)
|
||||
{
|
||||
if (handleObj.timeout !== null)
|
||||
{
|
||||
clearTimeout(handleObj.timeout);
|
||||
handleObj.timeout = null;
|
||||
}
|
||||
if (handleObj.subscription !== null)
|
||||
{
|
||||
handleObj.subscription.unsubscribe();
|
||||
handleObj.subscription = null;
|
||||
}
|
||||
resolve(packet);
|
||||
finish = true;
|
||||
}
|
||||
});
|
||||
else
|
||||
{
|
||||
const filterResult = filter(packet);
|
||||
if (filterResult === FilterResponse.Finish)
|
||||
{
|
||||
finish = true;
|
||||
}
|
||||
else if (filterResult === FilterResponse.Match)
|
||||
{
|
||||
// Extend
|
||||
if (handleObj.timeout !== null)
|
||||
{
|
||||
clearTimeout(handleObj.timeout);
|
||||
}
|
||||
handleObj.timeout = setTimeout(timeoutFunc, timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (finish)
|
||||
{
|
||||
if (handleObj.timeout !== null)
|
||||
{
|
||||
clearTimeout(handleObj.timeout);
|
||||
handleObj.timeout = null;
|
||||
}
|
||||
if (handleObj.subscription !== null)
|
||||
{
|
||||
handleObj.subscription.unsubscribe();
|
||||
handleObj.subscription = null;
|
||||
}
|
||||
resolve(packet);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -280,10 +280,7 @@ export class EventQueueClient
|
||||
{
|
||||
const messageParams = event['body']['instantmessage']['message_params'];
|
||||
const imSessionID = messageParams['id'];
|
||||
const requestedFolders = {
|
||||
'method': 'accept invitation',
|
||||
'session-id': imSessionID
|
||||
};
|
||||
|
||||
|
||||
const groupChatEvent = new GroupChatEvent();
|
||||
groupChatEvent.from = new UUID(messageParams['from_id'].toString());
|
||||
@@ -291,7 +288,10 @@ export class EventQueueClient
|
||||
groupChatEvent.groupID = new UUID(messageParams['id'].toString());
|
||||
groupChatEvent.message = messageParams['message'];
|
||||
|
||||
|
||||
const requestedFolders = {
|
||||
'method': 'accept invitation',
|
||||
'session-id': imSessionID
|
||||
};
|
||||
this.caps.capsRequestXML('ChatSessionRequest', requestedFolders).then((result: any) =>
|
||||
{
|
||||
this.agent.addChatSession(groupChatEvent.groupID);
|
||||
|
||||
11
lib/classes/GroupMember.ts
Normal file
11
lib/classes/GroupMember.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import {UUID} from './UUID';
|
||||
import * as Long from 'long';
|
||||
|
||||
export class GroupMember
|
||||
{
|
||||
AgentID: UUID;
|
||||
OnlineStatus: string;
|
||||
AgentPowers: Long;
|
||||
Title: string;
|
||||
IsOwner: boolean;
|
||||
}
|
||||
12
lib/classes/GroupRole.ts
Normal file
12
lib/classes/GroupRole.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {UUID} from './UUID';
|
||||
import * as Long from 'long';
|
||||
|
||||
export class GroupRole
|
||||
{
|
||||
RoleID: UUID;
|
||||
Name: string;
|
||||
Title: string;
|
||||
Description: string;
|
||||
Powers: Long;
|
||||
Members: number;
|
||||
}
|
||||
@@ -131,4 +131,12 @@ export class Utils
|
||||
const buff = new Buffer(str, 'base64');
|
||||
return buff.toString('utf8');
|
||||
}
|
||||
static HexToLong(hex: string)
|
||||
{
|
||||
while (hex.length < 16)
|
||||
{
|
||||
hex = '0' + hex;
|
||||
}
|
||||
return new Long(parseInt(hex.substr(8), 16), parseInt(hex.substr(0, 8), 16));
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,6 @@ import {ChatFromViewerMessage} from '../messages/ChatFromViewer';
|
||||
import {ChatType} from '../../enums/ChatType';
|
||||
import {InstantMessageDialog} from '../../enums/InstantMessageDialog';
|
||||
import Timer = NodeJS.Timer;
|
||||
import {GroupInviteEvent} from '../../events/GroupInviteEvent';
|
||||
import * as LLSD from 'llsd';
|
||||
import {GroupChatSessionJoinEvent} from '../../events/GroupChatSessionJoinEvent';
|
||||
|
||||
export class CommunicationsCommands extends CommandsBase
|
||||
@@ -183,66 +181,6 @@ export class CommunicationsCommands extends CommandsBase
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
acceptGroupInvite(event: GroupInviteEvent): Promise<void>
|
||||
{
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.GroupInvitationAccept,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
rejectGroupInvite(event: GroupInviteEvent): Promise<void>
|
||||
{
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.GroupInvitationDecline,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
typeInstantMessage(to: UUID | string, message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>
|
||||
{
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
@@ -307,7 +245,61 @@ export class CommunicationsCommands extends CommandsBase
|
||||
});
|
||||
}
|
||||
|
||||
startGroupSession(sessionID: UUID | string, message: string): Promise<void>
|
||||
typeLocalMessage(message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>
|
||||
{
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
{
|
||||
if (thinkingTime === undefined)
|
||||
{
|
||||
thinkingTime = 0;
|
||||
}
|
||||
setTimeout(() =>
|
||||
{
|
||||
this.startTypingLocal().then(() =>
|
||||
{
|
||||
this.bot.clientCommands.agent.startAnimations([new UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() =>
|
||||
{
|
||||
if (charactersPerSecond === undefined)
|
||||
{
|
||||
charactersPerSecond = 5;
|
||||
}
|
||||
|
||||
const timeToWait = (message.length / charactersPerSecond) * 1000;
|
||||
setTimeout(() =>
|
||||
{
|
||||
this.stopTypingLocal().then(() =>
|
||||
{
|
||||
this.bot.clientCommands.agent.stopAnimations([new UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() =>
|
||||
{
|
||||
this.say(message).then(() =>
|
||||
{
|
||||
resolve();
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
}, timeToWait);
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
}, thinkingTime);
|
||||
});
|
||||
}
|
||||
|
||||
startGroupChatSession(sessionID: UUID | string, message: string): Promise<void>
|
||||
{
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
{
|
||||
@@ -370,7 +362,7 @@ export class CommunicationsCommands extends CommandsBase
|
||||
{
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
{
|
||||
this.startGroupSession(groupID, message).then(() =>
|
||||
this.startGroupChatSession(groupID, message).then(() =>
|
||||
{
|
||||
if (typeof groupID === 'string')
|
||||
{
|
||||
@@ -408,54 +400,4 @@ export class CommunicationsCommands extends CommandsBase
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
typeLocalMessage(message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>
|
||||
{
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
{
|
||||
if (thinkingTime === undefined)
|
||||
{
|
||||
thinkingTime = 0;
|
||||
}
|
||||
setTimeout(() =>
|
||||
{
|
||||
this.startTypingLocal().then(() =>
|
||||
{
|
||||
this.bot.clientCommands.agent.startAnimations([new UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() =>
|
||||
{
|
||||
if (charactersPerSecond === undefined)
|
||||
{
|
||||
charactersPerSecond = 5;
|
||||
}
|
||||
|
||||
const timeToWait = (message.length / charactersPerSecond) * 1000;
|
||||
setTimeout(() =>
|
||||
{
|
||||
this.stopTypingLocal().then(() =>
|
||||
{
|
||||
this.bot.clientCommands.agent.stopAnimations([new UUID('c541c47f-e0c0-058b-ad1a-d6ae3a4584d9')]).then(() =>
|
||||
{
|
||||
this.say(message).then(() =>
|
||||
{
|
||||
resolve();
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}, timeToWait);
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
}, thinkingTime);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import {RegionIDAndHandleReplyMessage} from '../messages/RegionIDAndHandleReply'
|
||||
import {CommandsBase} from './CommandsBase';
|
||||
import {AvatarPickerRequestMessage} from '../messages/AvatarPickerRequest';
|
||||
import {AvatarPickerReplyMessage} from '../messages/AvatarPickerReply';
|
||||
import {FilterResponse} from '../../enums/FilterResponse';
|
||||
export class GridCommands extends CommandsBase
|
||||
{
|
||||
getRegionHandle(regionID: UUID): Promise<Long>
|
||||
@@ -27,10 +28,17 @@ export class GridCommands extends CommandsBase
|
||||
RegionID: regionID,
|
||||
};
|
||||
circuit.sendMessage(msg, PacketFlags.Reliable);
|
||||
circuit.waitForMessage(Message.RegionIDAndHandleReply, 10000, (packet: Packet) =>
|
||||
circuit.waitForMessage(Message.RegionIDAndHandleReply, 10000, (packet: Packet): FilterResponse =>
|
||||
{
|
||||
const filterMsg = packet.message as RegionIDAndHandleReplyMessage;
|
||||
return (filterMsg.ReplyBlock.RegionID.toString() === regionID.toString());
|
||||
if (filterMsg.ReplyBlock.RegionID.toString() === regionID.toString())
|
||||
{
|
||||
return FilterResponse.Finish;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FilterResponse.NoMatch;
|
||||
}
|
||||
}).then((packet: Packet) =>
|
||||
{
|
||||
const responseMsg = packet.message as RegionIDAndHandleReplyMessage;
|
||||
@@ -60,7 +68,7 @@ export class GridCommands extends CommandsBase
|
||||
MaxY: (gridY / 256)
|
||||
};
|
||||
circuit.sendMessage(msg, PacketFlags.Reliable);
|
||||
circuit.waitForMessage(Message.MapBlockReply, 10000, (packet: Packet) =>
|
||||
circuit.waitForMessage(Message.MapBlockReply, 10000, (packet: Packet): FilterResponse =>
|
||||
{
|
||||
const filterMsg = packet.message as MapBlockReplyMessage;
|
||||
let found = false;
|
||||
@@ -71,7 +79,11 @@ export class GridCommands extends CommandsBase
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
if (found)
|
||||
{
|
||||
return FilterResponse.Finish;
|
||||
}
|
||||
return FilterResponse.NoMatch;
|
||||
}).then((packet: Packet) =>
|
||||
{
|
||||
const responseMsg = packet.message as MapBlockReplyMessage;
|
||||
@@ -106,7 +118,7 @@ export class GridCommands extends CommandsBase
|
||||
const minY = Math.floor(gridY / 256) * 256;
|
||||
const maxY = minY + 256;
|
||||
response.avatars = [];
|
||||
circuit.waitForMessage(Message.MapItemReply, 10000, (packet: Packet) =>
|
||||
circuit.waitForMessage(Message.MapItemReply, 10000, (packet: Packet): FilterResponse =>
|
||||
{
|
||||
const filterMsg = packet.message as MapItemReplyMessage;
|
||||
let found = false;
|
||||
@@ -118,7 +130,14 @@ export class GridCommands extends CommandsBase
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
if (found)
|
||||
{
|
||||
return FilterResponse.Finish;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FilterResponse.NoMatch;
|
||||
}
|
||||
}).then((packet2: Packet) =>
|
||||
{
|
||||
const responseMsg2 = packet2.message as MapItemReplyMessage;
|
||||
@@ -168,16 +187,16 @@ export class GridCommands extends CommandsBase
|
||||
};
|
||||
|
||||
this.circuit.sendMessage(aprm, PacketFlags.Reliable);
|
||||
this.circuit.waitForMessage(Message.AvatarPickerReply, 10000, (packet: Packet): boolean =>
|
||||
this.circuit.waitForMessage(Message.AvatarPickerReply, 10000, (packet: Packet): FilterResponse =>
|
||||
{
|
||||
const apr = packet.message as AvatarPickerReplyMessage;
|
||||
if (apr.AgentData.QueryID.toString() === queryID.toString())
|
||||
{
|
||||
return true;
|
||||
return FilterResponse.Finish;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return FilterResponse.NoMatch;
|
||||
}
|
||||
}).then((packet: Packet) =>
|
||||
{
|
||||
|
||||
@@ -5,14 +5,28 @@ import {Utils} from '../Utils';
|
||||
import {PacketFlags} from '../../enums/PacketFlags';
|
||||
import {ImprovedInstantMessageMessage} from '../messages/ImprovedInstantMessage';
|
||||
import {Vector3} from '../Vector3';
|
||||
import {InviteGroupRequestMessage} from '../messages/InviteGroupRequest';
|
||||
import {GroupInviteEvent} from '../../events/GroupInviteEvent';
|
||||
import {GroupRole} from '../GroupRole';
|
||||
import {GroupRoleDataRequestMessage} from '../messages/GroupRoleDataRequest';
|
||||
import {Message} from '../../enums/Message';
|
||||
import {Packet} from '../Packet';
|
||||
import {GroupRoleDataReplyMessage} from '../messages/GroupRoleDataReply';
|
||||
import {GroupMember} from '../GroupMember';
|
||||
import {GroupMembersRequestMessage} from '../messages/GroupMembersRequest';
|
||||
import {GroupMembersReplyMessage} from '../messages/GroupMembersReply';
|
||||
import {FilterResponse} from '../../enums/FilterResponse';
|
||||
import * as Long from 'long';
|
||||
import {GroupChatSessionJoinEvent} from '../../events/GroupChatSessionJoinEvent';
|
||||
import * as LLSD from 'llsd';
|
||||
|
||||
export class GroupCommands extends CommandsBase
|
||||
{
|
||||
sendGroupNotice(group: UUID | string, subject: string, message: string)
|
||||
sendGroupNotice(groupID: UUID | string, subject: string, message: string)
|
||||
{
|
||||
if (typeof group === 'string')
|
||||
if (typeof groupID === 'string')
|
||||
{
|
||||
group = new UUID(group);
|
||||
groupID = new UUID(groupID);
|
||||
}
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
@@ -23,7 +37,7 @@ export class GroupCommands extends CommandsBase
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: group,
|
||||
ToAgentID: groupID,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
@@ -41,4 +55,236 @@ export class GroupCommands extends CommandsBase
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
sendGroupInviteBulk(groupID: UUID | string, sendTo: {
|
||||
avatarID: UUID | string,
|
||||
roleID: UUID | string | undefined
|
||||
}[]): Promise<void>
|
||||
{
|
||||
if (typeof groupID === 'string')
|
||||
{
|
||||
groupID = new UUID(groupID);
|
||||
}
|
||||
const igr = new InviteGroupRequestMessage();
|
||||
igr.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: this.circuit.sessionID
|
||||
};
|
||||
igr.GroupData = {
|
||||
GroupID: groupID
|
||||
};
|
||||
igr.InviteData = [];
|
||||
sendTo.forEach((to) =>
|
||||
{
|
||||
if (typeof to.avatarID === 'string')
|
||||
{
|
||||
to.avatarID = new UUID(to.avatarID);
|
||||
}
|
||||
if (to.roleID === undefined)
|
||||
{
|
||||
to.roleID = UUID.zero();
|
||||
}
|
||||
if (typeof to.roleID === 'string')
|
||||
{
|
||||
to.roleID = new UUID(to.roleID);
|
||||
}
|
||||
igr.InviteData.push({
|
||||
InviteeID: to.avatarID,
|
||||
RoleID: to.roleID
|
||||
});
|
||||
});
|
||||
|
||||
const sequenceNo = this.circuit.sendMessage(igr, PacketFlags.Reliable);
|
||||
return this.circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
sendGroupInvite(groupID: UUID | string, to: UUID | string, role: UUID | string | undefined): Promise<void>
|
||||
{
|
||||
const sendTo = [{
|
||||
avatarID: to,
|
||||
roleID: role
|
||||
}];
|
||||
return this.sendGroupInviteBulk(groupID, sendTo);
|
||||
}
|
||||
|
||||
acceptGroupInvite(event: GroupInviteEvent): Promise<void>
|
||||
{
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.GroupInvitationAccept,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
rejectGroupInvite(event: GroupInviteEvent): Promise<void>
|
||||
{
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.GroupInvitationDecline,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
getMemberList(groupID: UUID | string): Promise<GroupMember[]>
|
||||
{
|
||||
return new Promise<GroupMember[]>((resolve, reject) =>
|
||||
{
|
||||
if (typeof groupID === 'string')
|
||||
{
|
||||
groupID = new UUID(groupID);
|
||||
}
|
||||
const result: GroupMember[] = [];
|
||||
const requestData = {
|
||||
'group_id': new LLSD.UUID(groupID.toString())
|
||||
};
|
||||
this.currentRegion.caps.capsRequestXML('GroupMemberData', requestData).then((response: any) =>
|
||||
{
|
||||
if (response['members'])
|
||||
{
|
||||
Object.keys(response['members']).forEach((uuid) =>
|
||||
{
|
||||
const member = new GroupMember();
|
||||
const data = response['members'][uuid];
|
||||
member.AgentID = new UUID(uuid);
|
||||
member.OnlineStatus = data['last_login'];
|
||||
let powers = response['defaults']['default_powers'];
|
||||
if (data['powers'])
|
||||
{
|
||||
powers = data['powers'];
|
||||
}
|
||||
member.IsOwner = data['owner'] === 'Y';
|
||||
|
||||
let titleIndex = 0;
|
||||
if (data['title'])
|
||||
{
|
||||
titleIndex = data['title'];
|
||||
}
|
||||
member.Title = response['titles'][titleIndex];
|
||||
member.AgentPowers = Utils.HexToLong(powers);
|
||||
|
||||
result.push(member);
|
||||
});
|
||||
resolve(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
reject(new Error('Bad response'));
|
||||
}
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getGroupRoles(groupID: UUID | string): Promise<GroupRole[]>
|
||||
{
|
||||
return new Promise<GroupRole[]>((resolve, reject) =>
|
||||
{
|
||||
const result: GroupRole[] = [];
|
||||
if (typeof groupID === 'string')
|
||||
{
|
||||
groupID = new UUID(groupID);
|
||||
}
|
||||
const grdr = new GroupRoleDataRequestMessage();
|
||||
grdr.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: this.circuit.sessionID
|
||||
};
|
||||
const requestID = UUID.random();
|
||||
grdr.GroupData = {
|
||||
GroupID: groupID,
|
||||
RequestID: requestID
|
||||
};
|
||||
let totalRoleCount = 0;
|
||||
|
||||
this.circuit.sendMessage(grdr, PacketFlags.Reliable);
|
||||
this.circuit.waitForMessage(Message.GroupRoleDataReply, 10000, (packet: Packet): FilterResponse =>
|
||||
{
|
||||
const gmr = packet.message as GroupRoleDataReplyMessage;
|
||||
if (gmr.GroupData.RequestID.toString() === requestID.toString())
|
||||
{
|
||||
totalRoleCount = gmr.GroupData.RoleCount;
|
||||
gmr.RoleData.forEach((role) =>
|
||||
{
|
||||
const gr = new GroupRole();
|
||||
gr.RoleID = role.RoleID;
|
||||
gr.Name = Utils.BufferToStringSimple(role.Name);
|
||||
gr.Title = Utils.BufferToStringSimple(role.Title);
|
||||
gr.Description = Utils.BufferToStringSimple(role.Description);
|
||||
gr.Powers = role.Powers;
|
||||
gr.Members = role.Members;
|
||||
result.push(gr);
|
||||
});
|
||||
if (totalRoleCount > result.length)
|
||||
{
|
||||
return FilterResponse.Match;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FilterResponse.Finish;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FilterResponse.NoMatch;
|
||||
}
|
||||
}).then(() =>
|
||||
{
|
||||
resolve(result);
|
||||
}).catch((err) =>
|
||||
{
|
||||
if (result.length === 0)
|
||||
{
|
||||
reject(err);
|
||||
}
|
||||
else
|
||||
{
|
||||
resolve(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
6
lib/enums/FilterResponse.ts
Normal file
6
lib/enums/FilterResponse.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export enum FilterResponse
|
||||
{
|
||||
NoMatch = 0,
|
||||
Match = 1,
|
||||
Finish = 2
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import {InstantMessageEventFlags} from './enums/InstantMessageEventFlags';
|
||||
import {InstantMessageEvent} from './events/InstantMessageEvent';
|
||||
import {ChatSourceType} from './enums/ChatSourceType';
|
||||
import {BotOptionFlags} from './enums/BotOptionFlags';
|
||||
import {UUID} from './classes/UUID';
|
||||
|
||||
export {
|
||||
Bot,
|
||||
@@ -23,5 +24,6 @@ export {
|
||||
InstantMessageEvent,
|
||||
InstantMessageEventFlags,
|
||||
ChatSourceType,
|
||||
BotOptionFlags
|
||||
BotOptionFlags,
|
||||
UUID
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user