Skip to content

Commit

Permalink
Move inviter to a separate dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Himura2la committed Sep 16, 2021
1 parent 9a3e079 commit 3a96795
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions etc/vk_inviter.py → vk-inviter/vk_inviter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Himura Kazuto <[email protected]>

from time import sleep
Expand Down Expand Up @@ -54,8 +55,8 @@ def __dump(self, captcha):
def __invite_member(self, i, user, target_group, retry_count=0, captcha=None):
user_id, user_info = user
print(f'[ {i}/{len(self.members_to_invite) - 1} | {user_info["first_name"]} {user_info["last_name"]} ]', end=' ', flush=True)
if retry_count > 3:
print(f'Too many retries ({retry_count}), giving up')
if retry_count > 4:
print(f'Слишком много попыток ({retry_count}), забиваем и идём дальше...')
return False
try:
try:
Expand All @@ -67,15 +68,15 @@ def __invite_member(self, i, user, target_group, retry_count=0, captcha=None):
if captcha:
self.__dump(captcha)
if invite_response == 1:
print(f'Invited to "{target_group["name"]}"')
print(f'Приглашён в "{target_group["name"]}"')
else:
print(invite_response)
except vk.exceptions.VkAPIError as e:
if captcha and e.code != e.CAPTCHA_NEEDED:
self.__dump(captcha)
raise e
except vk.exceptions.VkAPIError as e:
print(f'{e.message} (code {e.code})')
print(f'{e.message} (ошибка {e.code})')
if e.code == e.CAPTCHA_NEEDED:
with urlopen(e.captcha_img) as f:
img_bytes = f.read()
Expand Down

0 comments on commit 3a96795

Please sign in to comment.