import { WebClient } from "@slack/web-api"
/**
* List Conversation History
* Fetch top-level messages from a channel, DM or group DM, newest first (thread replies need Get Thread Replies). A bot token (channels:history) can read public channels the app is in. Private channels, DMs and group DMs need a user token from someone in them, with groups:history, im:history or mpim:history. Paginate with `response_metadata.next_cursor`.
*/
export async function main(
slack_auth: RT.Slack,
channel: string,
oldest?: string,
latest?: string,
inclusive?: boolean,
limit?: number,
cursor?: string
) {
const web = new WebClient(slack_auth.token)
const response = await web.conversations.history(
dropEmpty({ channel, oldest, latest, inclusive, limit, cursor })
)
return { response: response }
}
function dropEmpty<T extends { [key: string]: any }>(params: T) {
return Object.fromEntries(
Object.entries(params).filter(
([, v]) => v != null && v !== "" && !(Array.isArray(v) && v.length === 0)
)
) as T
}
Submitted by hugo989 9 days ago
import { WebClient } from "@slack/web-api"
/**
* List Conversation History
* Fetch top-level messages from a channel, DM or group DM, newest first (thread replies need Get Thread Replies). A bot token (channels:history) can read public channels the app is in. Private channels, DMs and group DMs need a user token from someone in them, with groups:history, im:history or mpim:history. Paginate with `response_metadata.next_cursor`.
*/
export async function main(
slack_auth: RT.Slack,
channel: string,
oldest?: string,
latest?: string,
inclusive?: boolean,
limit?: number,
cursor?: string
) {
const web = new WebClient(slack_auth.token)
const response = await web.conversations.history(
dropEmpty({ channel, oldest, latest, inclusive, limit, cursor })
)
return { response: response }
}
function dropEmpty<T extends { [key: string]: any }>(params: T) {
return Object.fromEntries(
Object.entries(params).filter(
([, v]) => v !== undefined && v !== null && v !== ""
)
) as T
}
Submitted by hugo989 22 days ago
import { WebClient } from "@slack/web-api";
/*
@param: {string} channel - Conversation ID to fetch history for.
*/
type Slack = {
token: string;
};
export async function main(slack_auth: Slack, channel: string) {
const web = new WebClient(slack_auth.token);
let response = await web.conversations.history({
channel: channel,
});
return { response: response };
}
Submitted by hugo989 142 days ago