feat: Add WhatsApp poll support (#248)
Implements issue #123 - WhatsApp Poll Support ## Gateway Protocol - Add `poll` RPC method with params: to, question, options (2-12), selectableCount ## ActiveWebListener - Add `sendPoll(to, poll)` method to interface - Implementation uses Baileys poll message type ## CLI Command - `clawdbot poll --to <jid> -q <question> -o <opt1> -o <opt2> [-s count]` - Supports --dry-run, --json, --verbose flags - Validates 2-12 options ## Changes - src/gateway/protocol/schema.ts: Add PollParamsSchema - src/gateway/protocol/index.ts: Export validator and types - src/web/active-listener.ts: Add sendPoll to interface - src/web/inbound.ts: Implement sendPoll using Baileys - src/web/outbound.ts: Add sendPollWhatsApp function - src/gateway/server-methods/send.ts: Add poll handler - src/commands/poll.ts: New CLI command - src/cli/program.ts: Register poll command Closes #123
This commit is contained in:
@@ -198,6 +198,17 @@ export const SendParamsSchema = Type.Object(
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const PollParamsSchema = Type.Object(
|
||||
{
|
||||
to: NonEmptyString,
|
||||
question: NonEmptyString,
|
||||
options: Type.Array(NonEmptyString, { minItems: 2, maxItems: 12 }),
|
||||
selectableCount: Type.Optional(Type.Integer({ minimum: 1, maximum: 12 })),
|
||||
idempotencyKey: NonEmptyString,
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const AgentParamsSchema = Type.Object(
|
||||
{
|
||||
message: NonEmptyString,
|
||||
@@ -831,6 +842,7 @@ export const ProtocolSchemas: Record<string, TSchema> = {
|
||||
ErrorShape: ErrorShapeSchema,
|
||||
AgentEvent: AgentEventSchema,
|
||||
SendParams: SendParamsSchema,
|
||||
PollParams: PollParamsSchema,
|
||||
AgentParams: AgentParamsSchema,
|
||||
AgentWaitParams: AgentWaitParamsSchema,
|
||||
WakeParams: WakeParamsSchema,
|
||||
@@ -900,6 +912,7 @@ export type PresenceEntry = Static<typeof PresenceEntrySchema>;
|
||||
export type ErrorShape = Static<typeof ErrorShapeSchema>;
|
||||
export type StateVersion = Static<typeof StateVersionSchema>;
|
||||
export type AgentEvent = Static<typeof AgentEventSchema>;
|
||||
export type PollParams = Static<typeof PollParamsSchema>;
|
||||
export type AgentWaitParams = Static<typeof AgentWaitParamsSchema>;
|
||||
export type WakeParams = Static<typeof WakeParamsSchema>;
|
||||
export type NodePairRequestParams = Static<typeof NodePairRequestParamsSchema>;
|
||||
|
||||
Reference in New Issue
Block a user