antenna-openclaw-plugin 1.2.16 → 1.2.17
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/index.ts +33 -10
- package/package.json +1 -1
- package/skills/antenna/EVENTS.md +7 -2
package/index.ts
CHANGED
|
@@ -48,6 +48,7 @@ let _supabaseUrl: string | null = null;
|
|
|
48
48
|
const _lastScanTime = new Map<string, number>();
|
|
49
49
|
const SCAN_DEBOUNCE_MS = 30_000;
|
|
50
50
|
const _knownDeviceIds = new Set<string>();
|
|
51
|
+
const _channelContext = new Map<string, string>(); // device_id → chatId (e.g. discord channel ID)
|
|
51
52
|
|
|
52
53
|
function getConfig(api: any): AntennaConfig {
|
|
53
54
|
const cfg = api.config?.plugins?.entries?.antenna?.config ?? {};
|
|
@@ -122,23 +123,35 @@ function cronJobId(deviceA: string, deviceB: string): string {
|
|
|
122
123
|
return `antenna-follow-${safe(deviceA)}-${safe(deviceB)}`;
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
/** Send a real-time notification to a user via openclaw
|
|
126
|
+
/** Send a real-time notification to a user via openclaw message send */
|
|
126
127
|
function notifyUser(
|
|
127
128
|
channel: string,
|
|
128
129
|
userId: string,
|
|
129
130
|
message: string,
|
|
130
131
|
logger: any,
|
|
131
132
|
): void {
|
|
133
|
+
const deviceId = `${channel}:${userId}`;
|
|
134
|
+
const chatId = _channelContext.get(deviceId);
|
|
135
|
+
|
|
132
136
|
try {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
if (chatId) {
|
|
138
|
+
// Use message send with known chat context
|
|
139
|
+
execSync(
|
|
140
|
+
`openclaw message send --channel ${channel} --target ${chatId} -m ${JSON.stringify(message)}`,
|
|
141
|
+
{ timeout: 30_000, encoding: "utf-8" },
|
|
142
|
+
);
|
|
143
|
+
} else {
|
|
144
|
+
// Fallback: try deliver
|
|
145
|
+
execSync(
|
|
146
|
+
`openclaw agent` +
|
|
147
|
+
` --message ${JSON.stringify(message)}` +
|
|
148
|
+
` --deliver` +
|
|
149
|
+
` --agent main` +
|
|
150
|
+
` --to ${channel}:${userId}`,
|
|
151
|
+
{ timeout: 30_000, encoding: "utf-8" },
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
logger.info(`Antenna: notified ${channel}:${userId} (chat=${chatId || 'deliver'})`);
|
|
142
155
|
} catch (err: any) {
|
|
143
156
|
logger.warn(`Antenna: notify failed for ${channel}:${userId}: ${err.message}`);
|
|
144
157
|
}
|
|
@@ -1315,6 +1328,16 @@ export default function register(api: any) {
|
|
|
1315
1328
|
const cfg = getConfig(api);
|
|
1316
1329
|
let hint = "";
|
|
1317
1330
|
|
|
1331
|
+
// --- Track chat context for notifications ---
|
|
1332
|
+
const senderId = ctx?.SenderId || ctx?.senderId;
|
|
1333
|
+
const ch = ctx?.Channel || ctx?.channel;
|
|
1334
|
+
const chatId = ctx?.ChatId || ctx?.chatId || ctx?.chat_id;
|
|
1335
|
+
if (senderId && ch && chatId) {
|
|
1336
|
+
const deviceId = `${ch}:${senderId}`;
|
|
1337
|
+
_channelContext.set(deviceId, chatId);
|
|
1338
|
+
_knownDeviceIds.add(deviceId);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1318
1341
|
// --- Auto-scan on location ---
|
|
1319
1342
|
if (cfg.autoScanOnLocation === false) return {};
|
|
1320
1343
|
|
package/package.json
CHANGED
package/skills/antenna/EVENTS.md
CHANGED
|
@@ -90,8 +90,13 @@ Generate a GPS link for setting event location.
|
|
|
90
90
|
|
|
91
91
|
### When someone shares an event link
|
|
92
92
|
1. Extract the code from `antenna.fyi/events/CODE`
|
|
93
|
-
2. Call `antenna_event_join(code)` — this
|
|
94
|
-
|
|
93
|
+
2. Call `antenna_event_join(code)` — this checks everything:
|
|
94
|
+
- If no profile → "Create a profile first"
|
|
95
|
+
- If event requires approval and no `application_context` provided → returns `needs_screening: true` + `screening_questions` array
|
|
96
|
+
- If screening questions returned: **ask the user each question**, collect answers, then call `antenna_event_join(code, application_context="collected answers")` again
|
|
97
|
+
- If join succeeds with `status: pending` → tell user "waiting for organizer approval"
|
|
98
|
+
- If join succeeds with `status: active` → user is in!
|
|
99
|
+
3. Auto check-in happens automatically if event has started + GPS within 1km
|
|
95
100
|
|
|
96
101
|
### When someone says "who's here" at an event
|
|
97
102
|
1. Call `antenna_event_scan(code)`
|