Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix users being banned permanently #192

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/helpers/newcomers/kickCandidates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function kickCandidates(chat: Chat, candidates: Candidate[]) {
kickChatMemberProxy(
chat.id,
candidate.id,
chat.banUsers ? 0 : parseInt(`${new Date().getTime() / 1000 + 45}`)
chat.banUsers
)
} catch (err) {
report(err, addKickedUser.name)
Expand All @@ -52,14 +52,18 @@ export async function kickCandidates(chat: Chat, candidates: Candidate[]) {
async function kickChatMemberProxy(
id: number,
candidateId: number,
duration: number
banUsers: boolean
) {
try {
if (!chatMembersBeingKicked[id]) {
chatMembersBeingKicked[id] = {}
}
chatMembersBeingKicked[id][candidateId] = true
await bot.telegram.kickChatMember(id, candidateId, duration)
if (banUsers) {
await bot.telegram.kickChatMember(id, candidateId)
} else {
await bot.telegram.unbanChatMember(id, candidateId) // kick without ban
}
} catch (err) {
report(err, kickChatMemberProxy.name)
} finally {
Expand Down
10 changes: 5 additions & 5 deletions src/helpers/newcomers/kickChatMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export async function kickChatMember(chat: DocumentType<Chat>, user: User) {
// Try kicking the member
try {
await addKickedUser(chat, user.id)
await bot.telegram.kickChatMember(
chat.id,
user.id,
chat.banUsers ? 0 : parseInt(`${new Date().getTime() / 1000 + 45}`)
)
if (chat.banUsers) {
await bot.telegram.kickChatMember(chat.id, user.id)
} else {
await bot.telegram.unbanChatMember(chat.id, user.id) // kick without ban
}
} catch (err) {
report(err, kickChatMember.name)
}
Expand Down