@elizaos/plugin-bluebubbles 2.0.0-alpha.3 → 2.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/{src/actions/index.ts → dist/actions/index.js} +1 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/sendMessage.d.ts +6 -0
- package/dist/actions/sendMessage.d.ts.map +1 -0
- package/dist/actions/sendMessage.js +127 -0
- package/dist/actions/sendMessage.js.map +1 -0
- package/dist/actions/sendReaction.d.ts +6 -0
- package/dist/actions/sendReaction.d.ts.map +1 -0
- package/dist/actions/sendReaction.js +143 -0
- package/dist/actions/sendReaction.js.map +1 -0
- package/dist/client.d.ts +72 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +272 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +33 -0
- package/dist/constants.d.ts.map +1 -0
- package/{src/constants.ts → dist/constants.js} +18 -22
- package/dist/constants.js.map +1 -0
- package/dist/environment.d.ts +44 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +99 -0
- package/dist/environment.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/chatContext.d.ts +6 -0
- package/dist/providers/chatContext.d.ts.map +1 -0
- package/dist/providers/chatContext.js +82 -0
- package/dist/providers/chatContext.js.map +1 -0
- package/dist/providers/chatState.d.ts +6 -0
- package/dist/providers/chatState.d.ts.map +1 -0
- package/dist/providers/chatState.js +64 -0
- package/dist/providers/chatState.js.map +1 -0
- package/dist/providers/index.d.ts +6 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/{src/providers/index.ts → dist/providers/index.js} +2 -1
- package/dist/providers/index.js.map +1 -0
- package/dist/service.d.ts +87 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +363 -0
- package/dist/service.js.map +1 -0
- package/dist/types.d.ts +140 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +76 -3
- package/__tests__/integration.test.ts +0 -260
- package/build.ts +0 -16
- package/src/actions/sendMessage.ts +0 -175
- package/src/actions/sendReaction.ts +0 -186
- package/src/client.ts +0 -389
- package/src/environment.ts +0 -120
- package/src/index.ts +0 -68
- package/src/providers/chatContext.ts +0 -105
- package/src/providers/chatState.ts +0 -90
- package/src/service.ts +0 -502
- package/src/types.ts +0 -165
- package/tsconfig.json +0 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,KAAK,MAAM,EAWZ,MAAM,eAAe,CAAC;AA6CvB,eAAO,MAAM,iBAAiB,EAAE,MAkH/B,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send message action for BlueBubbles
|
|
3
|
+
*/
|
|
4
|
+
import { composePromptFromState, logger, ModelType, } from "@elizaos/core";
|
|
5
|
+
import { BLUEBUBBLES_SERVICE_NAME } from "../constants";
|
|
6
|
+
const sendMessageTemplate = `
|
|
7
|
+
# Task: Generate a response to send via iMessage (BlueBubbles)
|
|
8
|
+
{{recentMessages}}
|
|
9
|
+
|
|
10
|
+
# Instructions: Write a response to send to the user via iMessage. Be conversational and friendly.
|
|
11
|
+
Your response should be appropriate for iMessage - keep it relatively concise but engaging.
|
|
12
|
+
`;
|
|
13
|
+
const examples = [
|
|
14
|
+
[
|
|
15
|
+
{
|
|
16
|
+
name: "{{user1}}",
|
|
17
|
+
content: {
|
|
18
|
+
text: "Can you send a message to John saying I'll be late?",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "{{agentName}}",
|
|
23
|
+
content: {
|
|
24
|
+
text: "I'll send that message to John for you.",
|
|
25
|
+
action: "SEND_BLUEBUBBLES_MESSAGE",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
{
|
|
31
|
+
name: "{{user1}}",
|
|
32
|
+
content: {
|
|
33
|
+
text: "Reply to this iMessage for me",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "{{agentName}}",
|
|
38
|
+
content: {
|
|
39
|
+
text: "I'll compose and send a reply for you.",
|
|
40
|
+
action: "SEND_BLUEBUBBLES_MESSAGE",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
];
|
|
45
|
+
export const sendMessageAction = {
|
|
46
|
+
name: "SEND_BLUEBUBBLES_MESSAGE",
|
|
47
|
+
description: "Send a message via iMessage through BlueBubbles",
|
|
48
|
+
similes: [
|
|
49
|
+
"SEND_IMESSAGE",
|
|
50
|
+
"TEXT_MESSAGE",
|
|
51
|
+
"IMESSAGE_REPLY",
|
|
52
|
+
"BLUEBUBBLES_SEND",
|
|
53
|
+
"APPLE_MESSAGE",
|
|
54
|
+
],
|
|
55
|
+
examples,
|
|
56
|
+
validate: async (runtime, _message) => {
|
|
57
|
+
const service = runtime.getService(BLUEBUBBLES_SERVICE_NAME);
|
|
58
|
+
return service?.getIsRunning() ?? false;
|
|
59
|
+
},
|
|
60
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
61
|
+
const service = runtime.getService(BLUEBUBBLES_SERVICE_NAME);
|
|
62
|
+
const currentState = state ?? (await runtime.composeState(message));
|
|
63
|
+
if (!service || !service.getIsRunning()) {
|
|
64
|
+
logger.error("BlueBubbles service is not available");
|
|
65
|
+
if (callback) {
|
|
66
|
+
await callback({
|
|
67
|
+
text: "Sorry, the iMessage service is currently unavailable.",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return { success: false, error: "BlueBubbles service not available" };
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
// Get the room to find the target
|
|
74
|
+
const room = await runtime.getRoom(message.roomId);
|
|
75
|
+
if (!room?.channelId) {
|
|
76
|
+
logger.error("No channel ID found for room");
|
|
77
|
+
if (callback) {
|
|
78
|
+
await callback({
|
|
79
|
+
text: "Unable to determine the message recipient.",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return { success: false, error: "No channel ID" };
|
|
83
|
+
}
|
|
84
|
+
// Generate response if state is available
|
|
85
|
+
const prompt = composePromptFromState({
|
|
86
|
+
state: currentState,
|
|
87
|
+
template: sendMessageTemplate,
|
|
88
|
+
});
|
|
89
|
+
const response = await runtime.useModel(ModelType.TEXT_LARGE, {
|
|
90
|
+
prompt,
|
|
91
|
+
});
|
|
92
|
+
const responseText = typeof response === "string"
|
|
93
|
+
? response
|
|
94
|
+
: (response.text ?? "");
|
|
95
|
+
if (!responseText.trim()) {
|
|
96
|
+
logger.warn("Generated empty response, skipping send");
|
|
97
|
+
return { success: false, error: "Empty response generated" };
|
|
98
|
+
}
|
|
99
|
+
// Send the message
|
|
100
|
+
const result = await service.sendMessage(room.channelId, responseText, message.content.inReplyTo);
|
|
101
|
+
logger.info(`Sent BlueBubbles message: ${result.guid}`);
|
|
102
|
+
const content = {
|
|
103
|
+
text: responseText,
|
|
104
|
+
source: "bluebubbles",
|
|
105
|
+
metadata: {
|
|
106
|
+
messageGuid: result.guid,
|
|
107
|
+
chatGuid: room.channelId,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
if (callback) {
|
|
111
|
+
await callback(content);
|
|
112
|
+
}
|
|
113
|
+
return { success: true, text: responseText };
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
117
|
+
logger.error(`Failed to send BlueBubbles message: ${errorMessage}`);
|
|
118
|
+
if (callback) {
|
|
119
|
+
await callback({
|
|
120
|
+
text: "Failed to send the iMessage. Please try again.",
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return { success: false, error: errorMessage };
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=sendMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessage.js","sourceRoot":"","sources":["../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAKL,sBAAsB,EAGtB,MAAM,EAEN,SAAS,GAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGxD,MAAM,mBAAmB,GAAG;;;;;;CAM3B,CAAC;AAEF,MAAM,QAAQ,GAAsB;IAClC;QACE;YACE,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE;gBACP,IAAI,EAAE,qDAAqD;aAC5D;SACF;QACD;YACE,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,yCAAyC;gBAC/C,MAAM,EAAE,0BAA0B;aACnC;SACF;KACF;IACD;QACE;YACE,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE;gBACP,IAAI,EAAE,+BAA+B;aACtC;SACF;QACD;YACE,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,wCAAwC;gBAC9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M,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzD,MAAM,CAAC,KAAK,CAAC,uCAAuC,YAAY,EAAE,CAAC,CAAC;YAEpE,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,QAAQ,CAAC;oBACb,IAAI,EAAE,gDAAgD;iBACvD,CAAC,CAAC;YACL,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QACjD,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendReaction.d.ts","sourceRoot":"","sources":["../../src/actions/sendReaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAMP,MAAM,eAAe,CAAC;AAsCvB,eAAO,MAAM,kBAAkB,EAAE,MAsJhC,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send reaction action for the BlueBubbles plugin.
|
|
3
|
+
*/
|
|
4
|
+
import { composePromptFromState, logger, ModelType, parseJSONObjectFromText, } from "@elizaos/core";
|
|
5
|
+
import { BLUEBUBBLES_SERVICE_NAME } from "../constants.js";
|
|
6
|
+
const SEND_REACTION_TEMPLATE = `# Task: Extract BlueBubbles reaction parameters
|
|
7
|
+
|
|
8
|
+
Based on the conversation, determine what reaction to add or remove.
|
|
9
|
+
|
|
10
|
+
Recent conversation:
|
|
11
|
+
{{recentMessages}}
|
|
12
|
+
|
|
13
|
+
Extract the following:
|
|
14
|
+
1. emoji: The emoji reaction to add (heart, thumbsup, thumbsdown, haha, exclamation, question, or any emoji)
|
|
15
|
+
2. messageId: The message ID to react to (or "last" for the last message)
|
|
16
|
+
3. remove: true to remove the reaction, false to add it
|
|
17
|
+
|
|
18
|
+
Respond with a JSON object:
|
|
19
|
+
\`\`\`json
|
|
20
|
+
{
|
|
21
|
+
"emoji": "❤️",
|
|
22
|
+
"messageId": "last",
|
|
23
|
+
"remove": false
|
|
24
|
+
}
|
|
25
|
+
\`\`\`
|
|
26
|
+
`;
|
|
27
|
+
export const sendReactionAction = {
|
|
28
|
+
name: "BLUEBUBBLES_SEND_REACTION",
|
|
29
|
+
similes: ["BLUEBUBBLES_REACT", "BB_REACTION", "IMESSAGE_REACT"],
|
|
30
|
+
description: "Add or remove a reaction on a message via BlueBubbles",
|
|
31
|
+
validate: async (_runtime, message, _state) => {
|
|
32
|
+
return message.content.source === "bluebubbles";
|
|
33
|
+
},
|
|
34
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
35
|
+
const bbService = runtime.getService(BLUEBUBBLES_SERVICE_NAME);
|
|
36
|
+
const currentState = state ?? (await runtime.composeState(message));
|
|
37
|
+
if (!bbService || !bbService.isConnected()) {
|
|
38
|
+
if (callback) {
|
|
39
|
+
await callback({
|
|
40
|
+
text: "BlueBubbles service is not available.",
|
|
41
|
+
source: "bluebubbles",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return { success: false, error: "BlueBubbles service not available" };
|
|
45
|
+
}
|
|
46
|
+
// Extract parameters using LLM
|
|
47
|
+
const prompt = await composePromptFromState({
|
|
48
|
+
template: SEND_REACTION_TEMPLATE,
|
|
49
|
+
state: currentState,
|
|
50
|
+
});
|
|
51
|
+
let reactionInfo = null;
|
|
52
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
53
|
+
const response = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
54
|
+
prompt,
|
|
55
|
+
});
|
|
56
|
+
const parsed = parseJSONObjectFromText(response);
|
|
57
|
+
if (parsed?.emoji) {
|
|
58
|
+
reactionInfo = {
|
|
59
|
+
emoji: String(parsed.emoji),
|
|
60
|
+
messageId: String(parsed.messageId || "last"),
|
|
61
|
+
remove: Boolean(parsed.remove),
|
|
62
|
+
};
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!reactionInfo || !reactionInfo.emoji) {
|
|
67
|
+
if (callback) {
|
|
68
|
+
await callback({
|
|
69
|
+
text: "I couldn't understand the reaction. Please specify an emoji.",
|
|
70
|
+
source: "bluebubbles",
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return { success: false, error: "Could not extract reaction parameters" };
|
|
74
|
+
}
|
|
75
|
+
// Get chat context
|
|
76
|
+
const stateData = (currentState.data || {});
|
|
77
|
+
const chatGuid = stateData.chatGuid;
|
|
78
|
+
let messageGuid = reactionInfo.messageId;
|
|
79
|
+
if (!chatGuid) {
|
|
80
|
+
if (callback) {
|
|
81
|
+
await callback({
|
|
82
|
+
text: "I couldn't determine the chat to react in.",
|
|
83
|
+
source: "bluebubbles",
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return { success: false, error: "Could not determine chat" };
|
|
87
|
+
}
|
|
88
|
+
// If "last", get the last message GUID from context
|
|
89
|
+
if (messageGuid === "last" || !messageGuid) {
|
|
90
|
+
messageGuid = stateData.lastMessageGuid;
|
|
91
|
+
if (!messageGuid) {
|
|
92
|
+
if (callback) {
|
|
93
|
+
await callback({
|
|
94
|
+
text: "I couldn't find the message to react to.",
|
|
95
|
+
source: "bluebubbles",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return { success: false, error: "Could not find message to react to" };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Send reaction - we only support adding reactions, not removing
|
|
102
|
+
// The BlueBubbles API handles remove through a negative reaction type internally
|
|
103
|
+
const reactionValue = reactionInfo.remove
|
|
104
|
+
? `-${reactionInfo.emoji}`
|
|
105
|
+
: reactionInfo.emoji;
|
|
106
|
+
const result = await bbService.sendReaction(chatGuid, messageGuid, reactionValue);
|
|
107
|
+
if (!result.success) {
|
|
108
|
+
if (callback) {
|
|
109
|
+
await callback({
|
|
110
|
+
text: `Failed to ${reactionInfo.remove ? "remove" : "add"} reaction.`,
|
|
111
|
+
source: "bluebubbles",
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return { success: false, error: "Failed to send reaction" };
|
|
115
|
+
}
|
|
116
|
+
logger.debug(`${reactionInfo.remove ? "Removed" : "Added"} reaction ${reactionInfo.emoji} on ${messageGuid}`);
|
|
117
|
+
if (callback) {
|
|
118
|
+
await callback({
|
|
119
|
+
text: reactionInfo.remove
|
|
120
|
+
? "Reaction removed."
|
|
121
|
+
: `Reacted with ${reactionInfo.emoji}.`,
|
|
122
|
+
source: message.content.source,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return { success: true };
|
|
126
|
+
},
|
|
127
|
+
examples: [
|
|
128
|
+
[
|
|
129
|
+
{
|
|
130
|
+
name: "{{user1}}",
|
|
131
|
+
content: { text: "React to that message with a heart" },
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "{{agent}}",
|
|
135
|
+
content: {
|
|
136
|
+
text: "I'll add a heart reaction.",
|
|
137
|
+
actions: ["BLUEBUBBLES_SEND_REACTION"],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=sendReaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendReaction.js","sourceRoot":"","sources":["../../src/actions/sendReaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EACL,sBAAsB,EACtB,MAAM,EACN,SAAS,EACT,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,MAAM,sBAAsB,GAAG;;;;;;;;;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AAO,CAAC,MAAgB;aACzC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,QAAQ,EAAE;QACR;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,EAAE,IAAI,EAAE,oCAAoC,EAAE;aACxD;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,4BAA4B;oBAClC,OAAO,EAAE,CAAC,2BAA2B,CAAC;iBACvC;aACF;SACF;KACF;CACF,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { BlueBubblesChat, BlueBubblesConfig, BlueBubblesMessage, BlueBubblesProbeResult, SendAttachmentOptions, SendMessageOptions, SendMessageResult } from "./types";
|
|
2
|
+
export declare class BlueBubblesClient {
|
|
3
|
+
private baseUrl;
|
|
4
|
+
private password;
|
|
5
|
+
constructor(config: BlueBubblesConfig);
|
|
6
|
+
private request;
|
|
7
|
+
/**
|
|
8
|
+
* Probes the BlueBubbles server to check connectivity and capabilities
|
|
9
|
+
*/
|
|
10
|
+
probe(timeoutMs?: number): Promise<BlueBubblesProbeResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Sends a text message
|
|
13
|
+
*/
|
|
14
|
+
sendMessage(chatGuid: string, text: string, options?: SendMessageOptions): Promise<SendMessageResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Sends an attachment
|
|
17
|
+
*/
|
|
18
|
+
sendAttachment(chatGuid: string, attachmentPath: string, options?: SendAttachmentOptions): Promise<SendMessageResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Sends an attachment from a buffer
|
|
21
|
+
*/
|
|
22
|
+
sendAttachmentBuffer(chatGuid: string, buffer: Uint8Array, filename: string, mimeType: string, caption?: string): Promise<SendMessageResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Gets information about a chat
|
|
25
|
+
*/
|
|
26
|
+
getChat(chatGuid: string): Promise<BlueBubblesChat>;
|
|
27
|
+
/**
|
|
28
|
+
* Lists all chats
|
|
29
|
+
*/
|
|
30
|
+
listChats(limit?: number, offset?: number): Promise<BlueBubblesChat[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets messages for a chat
|
|
33
|
+
*/
|
|
34
|
+
getMessages(chatGuid: string, limit?: number, offset?: number): Promise<BlueBubblesMessage[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Marks a chat as read
|
|
37
|
+
*/
|
|
38
|
+
markChatRead(chatGuid: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Sends a reaction to a message
|
|
41
|
+
*/
|
|
42
|
+
reactToMessage(chatGuid: string, messageGuid: string, reaction: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Edits a message (requires private API)
|
|
45
|
+
*/
|
|
46
|
+
editMessage(messageGuid: string, newText: string, backwardsCompatMessage?: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Unsends a message (requires private API)
|
|
49
|
+
*/
|
|
50
|
+
unsendMessage(messageGuid: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Resolves a target (handle or chat GUID) to a chat GUID
|
|
53
|
+
*/
|
|
54
|
+
resolveTarget(target: string): Promise<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new group chat
|
|
57
|
+
*/
|
|
58
|
+
createGroupChat(participants: string[], name?: string, message?: string): Promise<BlueBubblesChat>;
|
|
59
|
+
/**
|
|
60
|
+
* Adds a participant to a group chat
|
|
61
|
+
*/
|
|
62
|
+
addParticipant(chatGuid: string, handle: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Removes a participant from a group chat
|
|
65
|
+
*/
|
|
66
|
+
removeParticipant(chatGuid: string, handle: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Renames a group chat
|
|
69
|
+
*/
|
|
70
|
+
renameGroupChat(chatGuid: string, newName: string): Promise<void>;
|
|
71
|
+
}
|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