diff --git a/dist/buildinfo.json b/dist/buildinfo.json index ec71e180..ced02c03 100644 --- a/dist/buildinfo.json +++ b/dist/buildinfo.json @@ -1 +1 @@ -{"sha": "3cce4ce", "timestamp": 1697203145} +{"sha": "3713d4d", "timestamp": 1697520630} diff --git a/dist/index.js b/dist/index.js index 08d57847..67d7f611 100644 --- a/dist/index.js +++ b/dist/index.js @@ -41,9 +41,9 @@ var ENV = { // 检查更新的分支 UPDATE_BRANCH: "master", // 当前版本 - BUILD_TIMESTAMP: 1697203145, + BUILD_TIMESTAMP: 1697520630, // 当前版本 commit id - BUILD_VERSION: "3cce4ce", + BUILD_VERSION: "3713d4d", I18N: null, LANGUAGE: "zh-cn", // 使用流模式 diff --git a/dist/timestamp b/dist/timestamp index 745108d3..a2e8d554 100644 --- a/dist/timestamp +++ b/dist/timestamp @@ -1 +1 @@ -1697203145 +1697520630 diff --git a/src/chat.js b/src/chat.js index 89de5aae..f13b19f8 100644 --- a/src/chat.js +++ b/src/chat.js @@ -184,7 +184,7 @@ export async function chatWithLLM(text, context, modifier) { const llm = loadLLM(context); if (llm === null) { - return sendMessageToTelegramWithContext(context)('LLM is not enable'); + return sendMessageToTelegramWithContext(context)('LLM is not enable'); } const answer = await requestCompletionsFromLLM(text, context, llm, modifier, onStream); context.CURRENT_CHAT_CONTEXT.parse_mode = parseMode; diff --git a/src/context.js b/src/context.js index d2796464..1b585bac 100644 --- a/src/context.js +++ b/src/context.js @@ -1,5 +1,6 @@ import {CONST, DATABASE, ENV} from './env.js'; -// import {TelegramMessage} from './type.d.ts'; +// eslint-disable-next-line no-unused-vars +import './type.js'; /** * 上下文信息 diff --git a/src/env.js b/src/env.js index b27e4cd3..c29e8211 100644 --- a/src/env.js +++ b/src/env.js @@ -201,9 +201,8 @@ export function initEnv(env, i18n) { // AUTO SET VALUES if (!ENV.OPENAI_API_BASE) { - ENV.OPENAI_API_BASE=`${ENV.OPENAI_API_DOMAIN}/v1` + ENV.OPENAI_API_BASE=`${ENV.OPENAI_API_DOMAIN}/v1`; } - } ENV.I18N = i18n((ENV.LANGUAGE || 'cn').toLowerCase()); ENV.SYSTEM_INIT_MESSAGE = ENV.I18N.env.system_init_message; diff --git a/src/message.js b/src/message.js index 23cdd949..0a19afd2 100644 --- a/src/message.js +++ b/src/message.js @@ -4,7 +4,8 @@ import {sendMessageToTelegramWithContext} from './telegram.js'; import {handleCommandMessage} from './command.js'; import {errorToString} from './utils.js'; import {chatWithLLM} from './chat.js'; -// import {TelegramMessage, TelegramWebhookRequest} from './type.d.ts'; +// eslint-disable-next-line no-unused-vars +import './type.js'; /** diff --git a/src/type.d.ts b/src/type.d.ts deleted file mode 100644 index b30a3114..00000000 --- a/src/type.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* eslint-disable */ - -type TelegramWebhookRequest = { - update_id: number; - message?: TelegramMessage; - edited_message?: TelegramMessage; -} - -type TelegramMessage = { - message_id: number; - from: TelegramUser; - chat: TelegramChat; - date: number; - text: string; - entities?: TelegramMessageEntity[]; - reply_to_message?: TelegramMessage; -} - -type TelegramUser = { - id: number; - is_bot: boolean; - first_name: string; - last_name?: string; - username?: string; - language_code?: string; -} - -type TelegramChat = { - id: number; - type: string; -} - -type TelegramMessageEntity = { - type: string; - offset: number; - length: number; - url?: string; - user?: TelegramUser; -} - -export { TelegramWebhookRequest, TelegramMessage, TelegramUser, TelegramChat, TelegramMessageEntity }; diff --git a/src/type.js b/src/type.js new file mode 100644 index 00000000..399dd7c9 --- /dev/null +++ b/src/type.js @@ -0,0 +1,42 @@ +/** + * @typedef {Object} TelegramUser + * @property {number} id - The ID of the user. + * @property {boolean} is_bot - True, if the user is a bot. + * @property {string} first_name - The first name of the user. + * @property {string} [last_name] - The last name of the user. + * @property {string} [username] - The username of the user. + * @property {string} [language_code] - The language code of the user. + */ + +/** + * @typedef {Object} TelegramChat + * @property {number} id - The ID of the chat. + * @property {string} type - The type of the chat. + */ + +/** + * @typedef {Object} TelegramMessageEntity + * @property {string} type - Type of the entity. + * @property {number} offset - Offset in UTF-16 code units to the start of the entity. + * @property {number} length - Length of the entity in UTF-16 code units. + * @property {string} [url] - URL of the entity. + * @property {TelegramUser} [user] - The user this entity refers to. + */ + +/** + * @typedef {Object} TelegramMessage + * @property {number} message_id - The message's unique identifier. + * @property {TelegramUser} from - The user that sent the message. + * @property {TelegramChat} chat - The chat where the message was sent. + * @property {number} date - The date the message was sent. + * @property {string} text - The text of the message. + * @property {TelegramMessageEntity[]} [entities] - An array of message entities. + * @property {TelegramMessage} [reply_to_message] - The message that this message is a reply to. + */ + +/** + * @typedef {Object} TelegramWebhookRequest + * @property {number} update_id - The update's unique identifier. + * @property {TelegramMessage} message - The message + * @property {TelegramMessage} edited_message - The edited message + */