Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
snakeying authored Nov 9, 2024
1 parent 598eb3c commit bab41e5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
This folder contains the built output assets for the worker "gpt-telegram-worker" generated at 2024-11-09T13:35:16.857Z.
This folder contains the built output assets for the worker "gpt-telegram-worker" generated at 2024-11-09T13:57:03.321Z.
3 changes: 1 addition & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/index.js.map

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions src/api/telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ export class TelegramBot {
const newModel = query.data.split('_')[1];
console.log('Switching to model:', newModel);
try {
await this.clearContext(userId);
await this.setCurrentModel(userId, newModel);
await this.sendMessageWithFallback(chatId, translate('model_changed', language) + newModel);
await this.clearContext(userId);
} catch (error) {
console.error('Error switching model:', error);
await this.sendMessageWithFallback(chatId, translate('error', language) + ': ' + (error instanceof Error ? error.message : 'Unknown error'));
Expand Down Expand Up @@ -332,8 +332,6 @@ export class TelegramBot {
await this.redis.set(`model:${userId}`, model);
console.log(`Switching to model: ${model}`);
this.modelAPI = await this.initializeModelAPI(userId);
// 切换模型时清理上下文,避免格式问题
await this.clearContext(userId);
}

getAvailableModels(): string[] {
Expand Down Expand Up @@ -634,7 +632,7 @@ export class TelegramBot {
.replace(/\*\*\*/g, '*')
// 确保链接格式正确
.replace(/\[([^\]]+)\]\s*\(([^)]+)\)/g, '[$1]($2)')
// 确保行内代码前后有空格
// 保行内代码前后有空格
.replace(/([^\s`])`([^`]+)`([^\s`])/g, '$1 `$2` $3')
// 移除多余的转义字符
.replace(/\\([*_`\[\]()#+-=|{}.!])/g, '$1');
Expand Down

0 comments on commit bab41e5

Please sign in to comment.