mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
refactor: type-safe applyFormatting
This commit is contained in:
parent
14474ede62
commit
f9eaf1c295
@ -9,6 +9,16 @@ import axios from 'axios';
|
|||||||
import { BaseChatbotService } from '../../base-chatbot.service';
|
import { BaseChatbotService } from '../../base-chatbot.service';
|
||||||
import { OpenaiService } from '../../openai/services/openai.service';
|
import { OpenaiService } from '../../openai/services/openai.service';
|
||||||
|
|
||||||
|
interface RichTextNode {
|
||||||
|
text?: string;
|
||||||
|
type?: string;
|
||||||
|
children?: RichTextNode[];
|
||||||
|
bold?: boolean;
|
||||||
|
italic?: boolean;
|
||||||
|
underline?: boolean;
|
||||||
|
url?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class TypebotService extends BaseChatbotService<TypebotModel, any> {
|
export class TypebotService extends BaseChatbotService<TypebotModel, any> {
|
||||||
private openaiService: OpenaiService;
|
private openaiService: OpenaiService;
|
||||||
|
|
||||||
@ -196,9 +206,8 @@ export class TypebotService extends BaseChatbotService<TypebotModel, any> {
|
|||||||
/**
|
/**
|
||||||
* Apply rich text formatting for TypeBot messages
|
* Apply rich text formatting for TypeBot messages
|
||||||
*/
|
*/
|
||||||
private applyFormatting(element: any): string {
|
private applyFormatting(element: string | RichTextNode | undefined): string {
|
||||||
if (typeof element === 'string') return element;
|
if (!element || typeof element === 'string') return element || '';
|
||||||
if (!element) return '';
|
|
||||||
|
|
||||||
let text = '';
|
let text = '';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user