bot18
Version:
A high-frequency cryptocurrency trading bot by Zenbot creator @carlos8f
61 lines (60 loc) • 2.02 kB
TypeScript
import { CodedError, ErrorCode } from './errors';
import { MessageAttachment } from './methods';
/**
* A client for Slack's Incoming Webhooks
*/
export declare class IncomingWebhook {
/**
* The webhook URL
*/
private url;
/**
* Default arguments for posting messages with this webhook
*/
private defaults;
constructor(url: string, defaults?: IncomingWebhookDefaultArguments);
/**
* Send a notification to a conversation
* @param message the message (a simple string, or an object describing the message)
* @param callback
*/
send(message: string | IncomingWebhookSendArguments): Promise<IncomingWebhookResult>;
send(message: string | IncomingWebhookSendArguments, callback: IncomingWebhookResultCallback): void;
/**
* Processes an HTTP response into an IncomingWebhookResult.
* @param response
*/
private buildResult(response);
}
export interface IncomingWebhookDefaultArguments {
username?: string;
icon_emoji?: string;
icon_url?: string;
channel?: string;
text?: string;
link_names?: boolean;
}
export interface IncomingWebhookSendArguments extends IncomingWebhookDefaultArguments {
attachments?: MessageAttachment[];
unfurl_links?: boolean;
unful_media?: boolean;
}
export interface IncomingWebhookResult {
text: string;
}
export interface IncomingWebhookResultCallback {
(error: IncomingWebhookSendError, result: IncomingWebhookResult): void;
}
export declare type IncomingWebhookSendError = IncomingWebhookRequestError | IncomingWebhookReadError | IncomingWebhookHTTPError;
export interface IncomingWebhookRequestError extends CodedError {
code: ErrorCode.IncomingWebhookRequestError;
original: Error;
}
export interface IncomingWebhookReadError extends CodedError {
code: ErrorCode.IncomingWebhookReadError;
original: Error;
}
export interface IncomingWebhookHTTPError extends CodedError {
code: ErrorCode.IncomingWebhookHTTPError;
original: Error;
}