Exemple #1
0
 def remove_post(self):
     """
     Удаляет пост из ВКонтакте
     """
     try:
         owner_id, vk_id = re.findall(r'https?://vk\.com/wall(-?\d+)_(\d+)', self.vk_post)[0]
         api=API(self.group.account_to_post.access_token)
         api.wall.delete(owner_id=owner_id, post_id=vk_id)
     except Exception, ex:
         save_err_to_db(ex, ErrorLog)
Exemple #2
0
    def publish(self):
        """
        Публикация поста
        """

        try:
            vk_id = re.findall(r'https?://vk\.com/wall(-?\d+_\d+)', self.link)[0]
            vk_post = clone_post(
                api=API(self.group.account_to_post.access_token),
                post=vk_id,
                to_id="-%s" % self.group.gid,
                album=self.group.album,
                cut_out={'hashtags': self.cut_out_hashtags, 'links_from_message': self.cut_out_links_from_message, 'attachment_links': self.cut_out_link_attachments},
                ac_key=self.group.account_to_post.ac_key,
                watermark_file=settings.MEDIA_ROOT + '/' + self.group.watermark.name if self.group.add_watermark is True and self.group.watermark != '' else ''
            )

            self.posted = True
            self.vk_post = vk_post
            self.when_posted = datetime.now()
        except Exception, ex:
            self.error_on_post = True
            save_err_to_db(ex, ErrorLog, template=ERROR_TEMPLATE, vk_id=vk_id, owner_id="-%s" % self.group.gid, album=self.group.album)