Better flood handling
This commit is contained in:
parent
3ba6ef1d2d
commit
8c38d60c72
2
pom.xml
2
pom.xml
|
@ -52,7 +52,7 @@
|
|||
<dependency>
|
||||
<groupId>it.tdlight</groupId>
|
||||
<artifactId>tdlib-session-container</artifactId>
|
||||
<version>4.0.16</version>
|
||||
<version>4.0.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
|
|
|
@ -538,6 +538,8 @@ public class TransferServiceImpl implements TransferService {
|
|||
return userStatusConsumer.apply(new UserStatus(getName(user), user.id, UserStatusType.USER_PRIVACY_RESTRICTED, "")).then(Mono.empty());
|
||||
} else if (TdLightUtils.errorEquals(new TdError(result.cause().code, result.cause().message), 400, "USER_NOT_MUTUAL_CONTACT")) {
|
||||
return userStatusConsumer.apply(new UserStatus(getName(user), user.id, UserStatusType.USER_NOT_MUTUAL_CONTACT, "")).then(Mono.empty());
|
||||
} else if (TdLightUtils.errorEquals(new TdError(result.cause().code, result.cause().message), 400, "PEER_FLOOD")) {
|
||||
return userStatusConsumer.apply(new UserStatus(getName(user), user.id, UserStatusType.ADD_FLOOD, "")).then(Mono.empty());
|
||||
}
|
||||
}
|
||||
return Mono.just(result);
|
||||
|
@ -545,11 +547,20 @@ public class TransferServiceImpl implements TransferService {
|
|||
.flatMap(MonoUtils::orElseThrow)
|
||||
.timeout(Duration.ofMinutes(2))
|
||||
.onErrorResume((error) -> {
|
||||
App.getLogService().append(Level.WARN, "Can't add user \"" + getName(user) + "\" to supergroup \"" + destGroup.getSupergroupIdInt() + " " + destGroup.getTitle() + "\"");
|
||||
App.getLogService().append(Level.WARN, "Can't add user \"" + getName(user) + "\" to supergroup \"" + destGroup.getSupergroupIdInt() + " " + destGroup.getTitle() + "\" (" + error.getLocalizedMessage() + ")");
|
||||
return userStatusConsumer.apply(new UserStatus(getName(user), user.id, UserStatusType.CANT_ADD, "Can't add to destination supergroup: " + error.getLocalizedMessage())).then(Mono.empty());
|
||||
})
|
||||
.flatMap(_v -> {
|
||||
return userStatusConsumer.apply(new UserStatus(getName(user), user.id, UserStatusType.ADDED_AND_WAITING_TO_BE_REMOVED, "")).then(Mono.empty()).thenReturn(user);
|
||||
UserStatusType userStatusType;
|
||||
if (REMOVE_MEMBERS_FROM_SOURCE_SUPERGROUP) {
|
||||
userStatusType = UserStatusType.ADDED_AND_WAITING_TO_BE_REMOVED;
|
||||
} else {
|
||||
userStatusType = UserStatusType.DONE;
|
||||
}
|
||||
return userStatusConsumer
|
||||
.apply(new UserStatus(getName(user), user.id, userStatusType, ""))
|
||||
.then(Mono.empty())
|
||||
.thenReturn(user);
|
||||
});
|
||||
})
|
||||
.<User>flatMap(user -> {
|
||||
|
@ -576,7 +587,8 @@ public class TransferServiceImpl implements TransferService {
|
|||
});
|
||||
} else {
|
||||
// Don't remove the user from the source supergroup
|
||||
return Mono.just(user);
|
||||
transferredSuccessfullyUsersStats.incrementAndGet();
|
||||
return userStatusConsumer.apply(new UserStatus(getName(user), user.id, UserStatusType.DONE, "")).then(Mono.empty()).thenReturn(user);
|
||||
}
|
||||
})
|
||||
.delayElements(App.getSettingsService().getDelayBetweenAdds())
|
||||
|
|
|
@ -53,6 +53,8 @@ public class UserStatus {
|
|||
return "❌ Can't add to destination group: this user privacy settings don't allow invitations to groups";
|
||||
case USER_NOT_MUTUAL_CONTACT:
|
||||
return "❌ Can't add to destination group: this user only allows mutual contacts to invite it in the destination group";
|
||||
case ADD_FLOOD:
|
||||
return "✔️ Can't add to destination group: an userbot has been blocked by telegram for flooding";
|
||||
case CANT_ADD:
|
||||
return "❌ Can't add to destination group";
|
||||
case UNKNOWN:
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
package it.cavallium;
|
||||
|
||||
public enum UserStatusType {
|
||||
NO_ACCESS_HASH, NOT_REGULAR_USER, SCAM_USER, RESTRICTED_USER, JUST_FOUND, CANT_ADD, ADDED_AND_WAITING_TO_BE_REMOVED, DONE, CANT_REMOVE, USER_PRIVACY_RESTRICTED, USER_NOT_MUTUAL_CONTACT, CANT_REMOVE_CHAT_OWNER, UNKNOWN
|
||||
NO_ACCESS_HASH,
|
||||
NOT_REGULAR_USER,
|
||||
SCAM_USER,
|
||||
RESTRICTED_USER,
|
||||
JUST_FOUND,
|
||||
CANT_ADD,
|
||||
ADDED_AND_WAITING_TO_BE_REMOVED,
|
||||
DONE,
|
||||
CANT_REMOVE,
|
||||
USER_PRIVACY_RESTRICTED,
|
||||
USER_NOT_MUTUAL_CONTACT,
|
||||
CANT_REMOVE_CHAT_OWNER,
|
||||
ADD_FLOOD,
|
||||
UNKNOWN
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b1ab4777479c10d48d2fec8392c52a6b66d66233
|
||||
Subproject commit a04010d72b8c8eb4165697f07c3da685b1a88a50
|
Loading…
Reference in New Issue