@badgerclaw/connect 1.2.2 → 1.2.3

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/SETUP.md CHANGED
@@ -97,8 +97,9 @@ Use these commands in any BadgerClaw room or DM where your bot is present.
97
97
  | Command | Description |
98
98
  |---------|-------------|
99
99
  | `/bot help` | Show all available commands |
100
- | `/bot talk on` | **Enable auto-reply** — bot responds to every message without needing an @mention. Great for 1-on-1 rooms. |
101
- | `/bot talk off` | **Disable auto-reply** bot only responds when @mentioned. Use in busy group rooms. |
100
+ | `/bot talk on` | **Enable auto-reply** — bot responds to every message without needing an @mention. If multiple bots are in the room, you'll be asked to specify which one. |
101
+ | `/bot talk on @botname` | **Enable auto-reply for a specific bot** use when multiple bots are in the room. |
102
+ | `/bot talk off` | **Disable auto-reply for ALL bots** — kill switch. All bots in the room go quiet and only respond when @mentioned. |
102
103
  | `/bot add <name>` | Invite a bot to the current room (e.g. `/bot add jarvis`) |
103
104
  | `/bot list` | List all your bots and their connection status |
104
105
 
@@ -106,6 +107,7 @@ Use these commands in any BadgerClaw room or DM where your bot is present.
106
107
 
107
108
  - **New installs:** Auto-reply is **ON by default** in all rooms
108
109
  - **Per-room toggle:** `/bot talk on` and `/bot talk off` override the default for that specific room
110
+ - **Multi-bot rooms:** If multiple bots are present, `/bot talk on` asks which bot to enable. `/bot talk off` silences all bots at once.
109
111
  - **@mentions always work:** Even with auto-reply off, the bot responds when @mentioned
110
112
 
111
113
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@badgerclaw/connect",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "BadgerClaw channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -80,15 +80,15 @@ export async function handleBotCommand(params: {
80
80
  " Works in: Any room or DM",
81
81
  "",
82
82
  "/bot talk on",
83
- " Enable auto-reply mode. The bot will respond to every",
84
- " message in this room without needing an @mention.",
85
- " Perfect for 1-on-1 rooms with your AI assistant.",
83
+ " Enable auto-reply for this bot. It will respond to",
84
+ " every message without needing an @mention.",
85
+ " If multiple bots are in the room, specify which one:",
86
+ " /bot talk on @botname",
86
87
  " Works in: Any room or DM",
87
88
  "",
88
89
  "/bot talk off",
89
- " Disable auto-reply mode. The bot will only respond",
90
- " when @mentioned. Use this in busy group rooms where",
91
- " you don't want the bot responding to everything.",
90
+ " Disable auto-reply for ALL bots in this room.",
91
+ " Bots will only respond when @mentioned.",
92
92
  " Works in: Any room or DM",
93
93
  "",
94
94
  "/bot add <botname>",
@@ -126,20 +126,69 @@ export async function handleBotCommand(params: {
126
126
  }
127
127
 
128
128
  case "talk": {
129
+ // Resolve bot members in the room
130
+ const botSuffix = "_bot:badger.signout.io";
131
+ let roomBots: string[] = [];
132
+ try {
133
+ const members = await client.getJoinedRoomMembers(roomId);
134
+ roomBots = members.filter((m: string) => m.includes(botSuffix) && m !== selfUserId);
135
+ } catch {
136
+ // If we can't list members, proceed as single-bot
137
+ }
138
+ const multipleBots = roomBots.length > 0; // other bots besides self
139
+
140
+ // Check if a specific bot was mentioned: /bot talk on @botname
141
+ const mentionArg = parts.slice(3).join(" ").trim();
142
+ const mentionedBot = mentionArg
143
+ ? mentionArg.startsWith("@") ? mentionArg : `@${mentionArg}`
144
+ : null;
145
+
146
+ // If a bot was mentioned and it's not us, ignore the command (let that bot handle it)
147
+ if (mentionedBot) {
148
+ const mentionLower = mentionedBot.toLowerCase();
149
+ const selfLower = selfUserId.toLowerCase();
150
+ // Match full userId or just the localpart
151
+ const selfLocalpart = selfLower.split(":")[0]; // @test_bot
152
+ if (!selfLower.startsWith(mentionLower) && !mentionLower.startsWith(selfLocalpart)) {
153
+ // Not addressed to us — ignore silently
154
+ return false;
155
+ }
156
+ }
157
+
129
158
  if (arg === "on") {
159
+ // Multiple bots + no specific mention → ask which bot
160
+ if (multipleBots && !mentionedBot) {
161
+ const botList = [selfUserId, ...roomBots]
162
+ .map((b, i) => ` ${i + 1}. ${b.split(":")[0]}`)
163
+ .join("\n");
164
+ await client.sendMessage(roomId, {
165
+ msgtype: "m.text",
166
+ body: [
167
+ "🦡 Multiple bots in this room:",
168
+ "",
169
+ botList,
170
+ "",
171
+ "Specify which bot: /bot talk on @botname",
172
+ ].join("\n"),
173
+ });
174
+ return true;
175
+ }
176
+
130
177
  const config = loadRoomConfig();
131
- // Store with lowercase key to match OpenClaw's lowercased groupId
132
178
  const normalizedRoomId = roomId.toLowerCase();
133
179
  config[normalizedRoomId] = { ...config[normalizedRoomId], autoReply: true };
134
180
  saveRoomConfig(config);
135
181
  setGroupActivation(roomId, "always");
182
+ const selfName = selfUserId.split(":")[0];
136
183
  await client.sendMessage(roomId, {
137
184
  msgtype: "m.text",
138
- body: "✅ Auto-reply enabled — I'll respond to every message in this room.",
185
+ body: `✅ Auto-reply enabled for ${selfName} — I'll respond to every message in this room.`,
139
186
  });
140
187
  return true;
141
188
  }
189
+
142
190
  if (arg === "off") {
191
+ // Off is a kill switch — disable auto-reply regardless of how many bots
143
192
  const config = loadRoomConfig();
144
193
  const normalizedRoomId = roomId.toLowerCase();
145
194
  config[normalizedRoomId] = { ...config[normalizedRoomId], autoReply: false };
@@ -147,13 +196,14 @@ export async function handleBotCommand(params: {
147
196
  setGroupActivation(roomId, "mention");
148
197
  await client.sendMessage(roomId, {
149
198
  msgtype: "m.text",
150
- body: "✅ Auto-reply disabled — I'll only respond when @mentioned.",
199
+ body: "✅ Auto-reply disabled for all bots bots will only respond when @mentioned.",
151
200
  });
152
201
  return true;
153
202
  }
203
+
154
204
  await client.sendMessage(roomId, {
155
205
  msgtype: "m.text",
156
- body: "Usage: /bot talk on or /bot talk off",
206
+ body: "Usage: /bot talk on [@botname] or /bot talk off",
157
207
  });
158
208
  return true;
159
209
  }