def like(self, event): if self.pair_id: try: photos = ','.join([ f'photo{self.pair_id}_{photo}' for photo in Vkfunc.get_photos(self.pair_id) ]) name = " ".join(Vkfunc.get_user_name(self.pair_id)) try: db_func.add_to_whitelist(event.user_id, self.pair_id, photos, name, Vkfunc.get_url(self.pair_id)) except IntegrityError: db_func.add_to_users(Vkfunc.get_user(event.user_id)) db_func.add_to_whitelist(event.user_id, self.pair_id, photos, name, Vkfunc.get_url(self.pair_id)) self.pair_id, url = next(self.search_list) while self.pair_id in self.marked_list: self.pair_id, url = next(self.search_list) photos = ','.join([ f'photo{self.pair_id}_{photo}' for photo in Vkfunc.get_photos(self.pair_id) ]) return self.search_message(event, url, photos) except StopIteration: self.search(event, offset=len(list(self.search_list))) else: return self.clarify_message(event)
def start(self, event): try: return Vkfunc.write_msg( event.user_id, f'Хай, {db_func.user_info(event.user_id)["first_name"]}!', kb.start_keyboard(dict())) except NoResultFound: db_func.add_to_users(Vkfunc.get_user(event.user_id)) return self.start(event)
def test_get_user(self): assert Vkfunc.get_user(1) == data.pavel_durov_user_data