UNPKG

@microsoft/teams.api

Version:

<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t

275 lines (271 loc) 8.96 kB
import { Account } from './models/account.mjs'; import { MentionEntity } from './models/entity/mention-entity.mjs'; import { InputHint } from './models/input-hint.mjs'; import { TextFormat } from './models/text-format.mjs'; import { Attachment } from './models/attachment/attachment.mjs'; import { CardAttachmentType, CardAttachmentTypes } from './models/attachment/card-attachment.mjs'; import { AttachmentLayout } from './models/attachment/attachment-layout.mjs'; import { SuggestedActions } from './models/suggested-actions.mjs'; import { Importance } from './models/importance.mjs'; import { DeliveryMode } from './models/delivery-mode.mjs'; import { IActivity, Activity } from './activities/activity.mjs'; import { ITypingActivity } from './activities/typing.mjs'; import { IMessageUpdateActivity } from './activities/message/message-update.mjs'; /** * any activity type that has a `text` property */ type TextActivity = IMessageActivity | IMessageUpdateActivity | ITypingActivity; type StripMentionsTextOptions = { /** * the account to remove mentions for * by default, all at-mentions listed in `entities` are removed. */ accountId?: string; /** * when `true`, the inner text of the tag * will not be removed * Eg. input: Hello <at>my-bot</at>! How are you? * output: Hello my-bot! How are you? */ tagOnly?: boolean; }; /** * remove "\<at>...\</at>" text from an activity * @param activity the activity */ declare function stripMentionsText<TActivity extends TextActivity>(activity: TActivity, { accountId, tagOnly }?: StripMentionsTextOptions): TActivity['text']; interface IMessageActivity extends IActivity<'message'> { /** * The text content of the message. */ text: string; /** * The text to speak. */ speak?: string; /** * Indicates whether your bot is accepting, * expecting, or ignoring user input after the message is delivered to the client. Possible * values include: 'acceptingInput', 'ignoringInput', 'expectingInput' */ inputHint?: InputHint; /** * The text to display if the channel cannot render cards. */ summary?: string; /** * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml' */ textFormat?: TextFormat; /** * The layout hint for multiple attachments. Default: list. Possible values include: 'list', * 'carousel' */ attachmentLayout?: AttachmentLayout; /** * Attachments */ attachments?: Attachment[]; /** * The suggested actions for the activity. */ suggestedActions?: SuggestedActions; /** * The importance of the activity. Possible values include: 'low', 'normal', 'high' */ importance?: Importance; /** * A delivery hint to signal to the recipient alternate delivery paths for the activity. * The default delivery mode is "default". Possible values include: 'normal', 'notification' */ deliveryMode?: DeliveryMode; /** * The time at which the activity should be considered to be "expired" and should not be * presented to the recipient. */ expiration?: Date; /** * A value that is associated with the activity. */ value?: any; /** * remove "\<at>...\</at>" text from an activity */ stripMentionsText(options?: StripMentionsTextOptions): IMessageActivity; /** * is the recipient account mentioned */ isRecipientMentioned(): boolean; /** * get a mention by the account id if exists */ getAccountMention(accountId: string): MentionEntity | undefined; } declare class MessageActivity extends Activity<'message'> implements IMessageActivity { /** * The text content of the message. */ text: string; /** * The text to speak. */ speak?: string; /** * Indicates whether your bot is accepting, * expecting, or ignoring user input after the message is delivered to the client. Possible * values include: 'acceptingInput', 'ignoringInput', 'expectingInput' */ inputHint?: InputHint; /** * The text to display if the channel cannot render cards. */ summary?: string; /** * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml' */ textFormat?: TextFormat; /** * The layout hint for multiple attachments. Default: list. Possible values include: 'list', * 'carousel' */ attachmentLayout?: AttachmentLayout; /** * Attachments */ attachments?: Attachment[]; /** * The suggested actions for the activity. */ suggestedActions?: SuggestedActions; /** * The importance of the activity. Possible values include: 'low', 'normal', 'high' */ importance?: Importance; /** * A delivery hint to signal to the recipient alternate delivery paths for the activity. * The default delivery mode is "default". Possible values include: 'normal', 'notification' */ deliveryMode?: DeliveryMode; /** * The time at which the activity should be considered to be "expired" and should not be * presented to the recipient. */ expiration?: Date; /** * A value that is associated with the activity. */ value?: any; constructor(text?: string, value?: Omit<Partial<IMessageActivity>, 'type'>); /** * initialize from interface */ static from(activity: IMessageActivity): MessageActivity; /** * convert to interface */ toInterface(): IMessageActivity; /** * copy to a new instance */ clone(options?: Omit<Partial<IMessageActivity>, 'type'>): MessageActivity; /** * The text content of the message. */ withText(value: string): this; /** * The text to speak. */ withSpeak(value: string): this; /** * Indicates whether your bot is accepting, * expecting, or ignoring user input after the message is delivered to the client. Possible * values include: 'acceptingInput', 'ignoringInput', 'expectingInput' */ withInputHint(value: InputHint): this; /** * The text to display if the channel cannot render cards. */ withSummary(value: string): this; /** * Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml' */ withTextFormat(value: TextFormat): this; /** * The layout hint for multiple attachments. Default: list. Possible values include: 'list', * 'carousel' */ withAttachmentLayout(value: AttachmentLayout): this; /** * The suggested actions for the activity. */ withSuggestedActions(value: SuggestedActions): this; /** * The importance of the activity. Possible values include: 'low', 'normal', 'high' */ withImportance(value: Importance): this; /** * A delivery hint to signal to the recipient alternate delivery paths for the activity. * The default delivery mode is "default". Possible values include: 'normal', 'notification' */ withDeliveryMode(value: DeliveryMode): this; /** * The time at which the activity should be considered to be "expired" and should not be * presented to the recipient. */ withExpiration(value: Date): this; /** * Append text */ addText(text: string): this; /** * Attachments */ addAttachments(...value: Attachment[]): this; /** * `@mention` an account * @param account the account to mention * @param options options to customize the mention */ addMention(account: Account, options?: AddMentionOptions): this; /** * Add a card attachment */ addCard<T extends CardAttachmentType>(type: T, content: CardAttachmentTypes[T]['content']): this; /** * remove "\<at>...\</at>" text from an activity */ stripMentionsText(options?: StripMentionsTextOptions): this; /** * is the recipient account mentioned */ isRecipientMentioned(): boolean; /** * get a mention by the account id if exists */ getAccountMention(accountId: string): MentionEntity | undefined; /** * Add stream info, making * this a final stream message */ addStreamFinal(): this; } /** * options for adding a mention * to an activity */ type AddMentionOptions = { /** * if `true`, append the mention `text` to the `activity.text` * @default true */ readonly addText?: boolean; /** * the `text` to use for the mention * * @default `account.name` * @remark * this text should not include `<at>` or `</at>` */ readonly text?: string; }; export { type AddMentionOptions as A, type IMessageActivity as I, MessageActivity as M, type StripMentionsTextOptions as S, stripMentionsText as s };