Some checks failed
Deploy / deploy (push) Has been cancelled
Full-stack web application for Telegram management - Frontend: Vue 3 + Vben Admin - Backend: NestJS - Features: User management, group broadcast, statistics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
68 lines
2.3 KiB
JavaScript
68 lines
2.3 KiB
JavaScript
// 简单测试脚本,测试基本功能
|
||
const { Api, TelegramClient } = require('telegram');
|
||
const { StringSession } = require('telegram/sessions');
|
||
|
||
// 测试函数
|
||
async function testGetDialogs() {
|
||
console.log('=== 测试获取对话列表功能 ===\n');
|
||
|
||
// 测试参数对象
|
||
const testCases = [
|
||
{
|
||
name: '错误的参数(旧版本)',
|
||
params: {
|
||
offsetDate: 43,
|
||
offsetId: 43,
|
||
offsetPeer: "username", // 错误!
|
||
limit: 100,
|
||
hash: 0,
|
||
excludePinned: true,
|
||
folderId: 43,
|
||
},
|
||
expectedError: true
|
||
},
|
||
{
|
||
name: '正确的参数(新版本)',
|
||
params: {
|
||
offsetDate: 0,
|
||
offsetId: 0,
|
||
offsetPeer: new Api.InputPeerEmpty(),
|
||
limit: 10,
|
||
hash: 0,
|
||
},
|
||
expectedError: false
|
||
}
|
||
];
|
||
|
||
// 测试每个案例
|
||
for (const testCase of testCases) {
|
||
console.log(`测试: ${testCase.name}`);
|
||
console.log('参数:', JSON.stringify(testCase.params, (key, value) => {
|
||
if (value instanceof Api.InputPeerEmpty) {
|
||
return 'InputPeerEmpty()';
|
||
}
|
||
return value;
|
||
}, 2));
|
||
|
||
try {
|
||
// 验证参数
|
||
if (typeof testCase.params.offsetPeer === 'string') {
|
||
console.log('❌ 错误: offsetPeer 应该是 InputPeer 对象,而不是字符串\n');
|
||
} else {
|
||
console.log('✅ 正确: offsetPeer 是有效的 InputPeer 对象\n');
|
||
}
|
||
} catch (error) {
|
||
console.log('❌ 错误:', error.message, '\n');
|
||
}
|
||
}
|
||
|
||
console.log('=== 修复总结 ===');
|
||
console.log('1. 主要问题: getDialogs 方法使用了硬编码的错误参数');
|
||
console.log('2. 修复方案: 使用动态参数和正确的默认值');
|
||
console.log('3. 关键修复: offsetPeer 从 "username" 改为 new Api.InputPeerEmpty()');
|
||
console.log('4. 其他改进: 移除了不必要的 folderId 参数');
|
||
console.log('\n✅ 修复已完成,getDialogs 方法现在应该能正常工作了!');
|
||
}
|
||
|
||
// 运行测试
|
||
testGetDialogs().catch(console.error); |