From beddac4f83b0fc3dffbb0d87bbd0c266ba611726 Mon Sep 17 00:00:00 2001 From: Yuya Tanaka Date: Fri, 25 May 2018 11:58:08 +0900 Subject: [PATCH 1/2] Add missing methods to d.ts --- lib/Botkit.d.ts | 49 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/lib/Botkit.d.ts b/lib/Botkit.d.ts index af8622095..b80485e66 100644 --- a/lib/Botkit.d.ts +++ b/lib/Botkit.d.ts @@ -2,13 +2,15 @@ import * as express from 'express'; import * as http from "http" declare namespace botkit { - function botframeworkbot(configuration: BotFrameworkConfiguration): BotFrameworkController; - function consolebot(configuration: ConsoleConfiguration): ConsoleController; - function facebookbot(configuration: FacebookConfiguration): FacebookController; function slackbot(configuration: SlackConfiguration): SlackController; function sparkbot(configuration: CiscoSparkConfiguration): CiscoSparkController; + function facebookbot(configuration: FacebookConfiguration): FacebookController; function twilioipmbot(configuration: TwilioIPMConfiguration): TwilioIPMController; function twiliosmsbot(configuration: TwilioSMSConfiguration): TwilioSMSController; + function botframeworkbot(configuration: BotFrameworkConfiguration): BotFrameworkController; + function teamsbot(configuration: TeamsConfiguration): TeamsController; + function consolebot(configuration: ConsoleConfiguration): ConsoleController; + function jabberbot(configuration: JabberConfiguration): JabberController; function socketbot(configuration: WebConfiguration): WebController; function anywhere(configuration: WebConfiguration): WebController; @@ -20,16 +22,22 @@ declare namespace botkit { no: RegExp; quit: RegExp; }; - createConversation(message: M, cb: (err: Error, convo: Conversation) => void): void; + say(message: string | M, cb?: (err: Error, res?: any) => void): void + replyWithQuestion(src: M, question: string | M, cb: ConversationCallback): void reply(src: M, resp: string | M, cb?: (err: Error, res: any) => void): void; + findConversation(message: M, cb: (convo?: Conversation) => void): void; + createConversation(message: M, cb: (err: Error, convo: Conversation) => void): void; startConversation(message: M, cb: (err: Error, convo: Conversation) => void): void; + + // abstract function + send(src: M, cb?: (err: Error, res?: any) => void): void; } interface BotFrameworkBot extends Bot { } interface BotFrameworkConfiguration extends Configuration { } interface BotFrameworkController extends Controller { - createWebhookEndpoints(webserver: any, bot: TwilioSMSBot, cb?: () => void): this; + createWebhookEndpoints(webserver: any, bot: BotFrameworkBot, cb?: () => void): this; } interface BotFrameworkMessage extends Message { } @@ -217,6 +225,22 @@ declare namespace botkit { name: string; emails: string[]; } + interface JabberBot extends Bot { + } + interface JabberConfiguration extends Configuration { + } + interface JabberController extends Controller { + } + interface JabberMessage extends Message { + } + interface JabberSpawnConfiguration { + client: { + jid?: string, + password?: string, + host?: string, + port?: number + } + } interface Message { action?: string; channel?: string; @@ -465,6 +489,19 @@ declare namespace botkit { interface Team { id: string; } + interface TeamsBot extends Bot { + } + interface TeamsConfiguration extends Configuration { + clientId?: string; + clientSecret?: string; + } + interface TeamsController extends Controller { + createWebhookEndpoints(): this; + } + interface TeamsMessage extends Message { + } + interface TeamsSpawnConfiguration { + } interface TwilioIPMBot extends Bot { readonly api: any; } @@ -499,8 +536,6 @@ declare namespace botkit { } interface WebBot extends Bot { connected: boolean; - send(src: WebMessage, cb?: (err: Error, res: any) => void): void; - findConversation(message: WebMessage, cb: (convo?: Conversation) => void): void; } interface WebConfiguration extends Configuration { replyWithTyping?: boolean; From 3b332da0808a8cbe77628b4c13e8ddf575679171 Mon Sep 17 00:00:00 2001 From: Yuya Tanaka Date: Fri, 8 Jun 2018 17:25:36 +0900 Subject: [PATCH 2/2] Add more definitions of TeamsBot to d.ts --- lib/Botkit.d.ts | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/lib/Botkit.d.ts b/lib/Botkit.d.ts index b80485e66..bb06bb053 100644 --- a/lib/Botkit.d.ts +++ b/lib/Botkit.d.ts @@ -489,7 +489,57 @@ declare namespace botkit { interface Team { id: string; } + interface TeamsAPI { + getUserById(conversationId: string, userId: string, cb: (err: Error, user_profile: any) => void); + getUserByUpn(conversationId: string, upn: string, cb: (err: Error, user_profile: any) => void); + getConversationMembers(conversationId: string, cb: (err: Error, members: any[]) => void); + getTeamRoster(teamId: string, cb: (err: Error, members: any[]) => void); + updateMessage(conversationId: string, messageId: string, replacement: TeamsMessage, cb: (err: Error, results: any) => void) + getChannels(teamId: string, cb: (err: Error, channels: any[]) => void); + } + interface TeamsAttachment { + content: TeamsAttachmentContent; + contentType: string; + + title(v: string): this; + subtitle(v: string): this; + text(v: string): this; + image(object: _TeamsAttachmentContentImage): this; + image(url: string, alt?: string): this; + button(object: _TeamsAttachmentContentButtonAction): this; + button(type: string, title: string, value: string): this; + tap(object: _TeamsAttachmentContentTapAction): this; + tap(type: string, title: string, payload: string): this; + } + interface TeamsAttachmentContent { + title?: string; + subtitle?: string; + text?: string; + images?: _TeamsAttachmentContentImage[]; + buttons?: _TeamsAttachmentContentButtonAction[]; + tap?: _TeamsAttachmentContentTapAction; + } + interface _TeamsAttachmentContentButtonAction { + type: string; + title: string; + image?: string; + value: string; + } + interface _TeamsAttachmentContentImage { + url: string; + alt?: string; + } + interface _TeamsAttachmentContentTapAction { + type: string; + value: string; + } interface TeamsBot extends Bot { + api: TeamsAPI; + + createHero(object: TeamsAttachmentContent): TeamsAttachment; + createHero(title?: string, subtitle?: string, text?: string, images?: _TeamsAttachmentContentImage[], buttons?: _TeamsAttachmentContentButtonAction[], tap?: _TeamsAttachmentContentTapAction): TeamsAttachment; + createThumbnail(object: TeamsAttachmentContent): TeamsAttachment; + createThumbnail(title?: string, subtitle?: string, text?: string, images?: _TeamsAttachmentContentImage[], buttons?: _TeamsAttachmentContentButtonAction[], tap?: _TeamsAttachmentContentTapAction): TeamsAttachment; } interface TeamsConfiguration extends Configuration { clientId?: string; @@ -499,8 +549,30 @@ declare namespace botkit { createWebhookEndpoints(): this; } interface TeamsMessage extends Message { + // for outgoing message + summary: string, + attachments?: TeamsAttachment[]; + attachmentLayout?: 'list' | 'grid'; + // for incoming events + type?: [ + 'direct_message' | + 'direct_mention' | + 'mention' | + 'bot_channel_join' | + 'user_channel_join' | + 'bot_channel_leave' | + 'user_channel_leave' | + 'channelDeleted' | + 'channelRenamed' | + 'channelCreated' | + 'invoke' | + 'composeExtension' + ] + raw_message?: any } interface TeamsSpawnConfiguration { + serviceUrl: string + team?: string // GUID } interface TwilioIPMBot extends Bot { readonly api: any;