|
@@ -564,8 +564,6 @@ export class TestService {
|
|
|
authKey?: string,
|
|
authKey?: string,
|
|
|
initMsg?: string
|
|
initMsg?: string
|
|
|
): Promise<any> {
|
|
): Promise<any> {
|
|
|
- let client: TelegramClient | null = null
|
|
|
|
|
-
|
|
|
|
|
try {
|
|
try {
|
|
|
const sessionResult = await this.resolveSenderSession(senderId, session, dcId, authKey)
|
|
const sessionResult = await this.resolveSenderSession(senderId, session, dcId, authKey)
|
|
|
if ('error' in sessionResult) {
|
|
if ('error' in sessionResult) {
|
|
@@ -577,6 +575,14 @@ export class TestService {
|
|
|
await this.tgClientService.connect(sessionString)
|
|
await this.tgClientService.connect(sessionString)
|
|
|
this.app.log.info('TelegramClient 连接完成')
|
|
this.app.log.info('TelegramClient 连接完成')
|
|
|
|
|
|
|
|
|
|
+ const client = this.tgClientService.getClient()
|
|
|
|
|
+ if (!client) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ success: false,
|
|
|
|
|
+ message: 'TelegramClient 未初始化或连接失败'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const waitTime = Math.floor(Math.random() * 21) + 20
|
|
const waitTime = Math.floor(Math.random() * 21) + 20
|
|
|
this.app.log.info(`连接成功后等待 ${waitTime} 秒,避免新 Session 被限制`)
|
|
this.app.log.info(`连接成功后等待 ${waitTime} 秒,避免新 Session 被限制`)
|
|
|
await new Promise(resolve => setTimeout(resolve, waitTime * 1000))
|
|
await new Promise(resolve => setTimeout(resolve, waitTime * 1000))
|
|
@@ -750,8 +756,6 @@ export class TestService {
|
|
|
message: string
|
|
message: string
|
|
|
data?: { chatId: string; inviteResults: { total: number; success: number; failed: number; errors: string[] } }
|
|
data?: { chatId: string; inviteResults: { total: number; success: number; failed: number; errors: string[] } }
|
|
|
}> {
|
|
}> {
|
|
|
- let client: TelegramClient | null = null
|
|
|
|
|
-
|
|
|
|
|
try {
|
|
try {
|
|
|
if (!members || members.length === 0) {
|
|
if (!members || members.length === 0) {
|
|
|
return { success: false, message: '成员列表不能为空' }
|
|
return { success: false, message: '成员列表不能为空' }
|
|
@@ -771,6 +775,11 @@ export class TestService {
|
|
|
await this.tgClientService.connect(sessionString)
|
|
await this.tgClientService.connect(sessionString)
|
|
|
this.app.log.info('TelegramClient 连接完成')
|
|
this.app.log.info('TelegramClient 连接完成')
|
|
|
|
|
|
|
|
|
|
+ const client = this.tgClientService.getClient()
|
|
|
|
|
+ if (!client) {
|
|
|
|
|
+ return { success: false, message: 'TelegramClient 未初始化或连接失败' }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const waitTime = Math.floor(Math.random() * 21) + 20
|
|
const waitTime = Math.floor(Math.random() * 21) + 20
|
|
|
this.app.log.info(`连接成功后等待 ${waitTime} 秒,避免新 Session 被限制`)
|
|
this.app.log.info(`连接成功后等待 ${waitTime} 秒,避免新 Session 被限制`)
|
|
|
await new Promise(resolve => setTimeout(resolve, waitTime * 1000))
|
|
await new Promise(resolve => setTimeout(resolve, waitTime * 1000))
|