Example #1
0
 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)
Example #2
0
 def test_get_url(self):
     assert Vkfunc.get_url(1) == 'https://vk.com/durov'