CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-slack--types

Comprehensive TypeScript type definitions for building Slack applications and integrations with the Node Slack SDK

94

1.11x
Overview
Eval results
Files

task.mdevals/scenario-4/

Pin Event Handler

Build a Slack event handler that processes pin and unpin events, maintaining a record of pinned items in a channel. The handler should work with Slack's Events API pin events.

Capabilities

Process pin events

  • When a pin added event is received for a message item, it adds the message details (channel, timestamp, user who pinned, and pin time) to the pinned items list and returns the updated list @test
  • When a pin removed event is received for a message item, it removes that message from the pinned items list and returns the updated list @test

Validate event structure

  • When processing an event with missing required fields (e.g., missing type), it throws an error @test
  • When processing a pin event with an unsupported item type, it returns the list unchanged @test

Track pinned items

  • It initializes with an empty list of pinned items @test
  • When multiple pin events are processed in sequence, it correctly maintains the list of all pinned items @test

Implementation

@generates

API

/**
 * Represents a pinned item in a channel
 */
export interface PinnedItem {
  channel: string;
  message_ts: string;
  pinned_by: string;
  pinned_at: number;
}

/**
 * Processes Slack pin events and manages a list of pinned items
 */
export class PinEventHandler {
  private pinnedItems: PinnedItem[];

  constructor();

  /**
   * Processes a pin or unpin event
   * @param event - The pin event from Slack
   * @returns The updated list of pinned items
   * @throws Error if the event structure is invalid
   */
  processEvent(event: any): PinnedItem[];

  /**
   * Gets the current list of pinned items
   * @returns The current list of pinned items
   */
  getPinnedItems(): PinnedItem[];
}

Dependencies { .dependencies }

@slack/types { .dependency }

Provides type definitions for Slack Events API, including pin events.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-slack--types

tile.json