Skip to content

Commit

Permalink
status: Fix issue in kicking members from group
Browse files Browse the repository at this point in the history
This commit is to fix the issue where a member is getting kicked for 2 times
  • Loading branch information
harshithpabbati committed Jan 28, 2020
1 parent aa5b8df commit 4547b60
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions status/management/commands/get_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,19 @@ def kickMembersFromGroup(thread):
for agent in telegramAgents:
bot = telegram.Bot(token=agent[0])
for user in shouldKick:
kick = True
exceptions = StatusException.objects.filter(isPaused=True)
for exception in exceptions:
if exception.user != user:
profile = Profile.objects.get(user=user)
bot.kick_chat_member(chat_id=agent[1], user_id=profile.telegram_id)
bot.unban_chat_member(
chat_id=agent[1],
user_id=profile.telegram_id
)
if user == exception.user:
kick = False
break
if kick:
profile = Profile.objects.get(user=user)
bot.kick_chat_member(chat_id=agent[1], user_id=profile.telegram_id)
bot.unban_chat_member(
chat_id=agent[1],
user_id=profile.telegram_id
)


class Command(BaseCommand):
Expand Down

0 comments on commit 4547b60

Please sign in to comment.