예제 #1
0
    def report(self, type, ownerId, itemId):
        response = False
        results = 0
        dialogsManager = PyDialogsManager()
        try:
            api = vk.api()
            if type == 'post':
                results = api.wall.reportPost(owner_id=ownerId, post_id=itemId)
            elif type == 'user':
                items = ['p**n', 'spam', 'insult', 'advertisment']
                index, cancelled = dialogsManager.showRowsDialogWithTitles(
                    items)
                if cancelled:
                    return
                type = items[index]
                message, cancelled = dialogsManager.showTextFieldDialogWithText(
                    'enter_report_message')
                if cancelled:
                    return
                results = api.users.report(user_id=ownerId,
                                           type=type,
                                           comment=message)
            elif type == 'photo':
                results = api.photos.report(owner_id=ownerId, photo_id=itemId)
            elif type == 'video':
                message, cancelled = dialogsManager.showTextFieldDialogWithText(
                    'enter_report_message')
                if cancelled:
                    return
                results = api.video.report(owner_id=ownerId,
                                           video_id=itemId,
                                           comment=message)
            elif type == 'post_comment':
                results = api.wall.reportComment(owner_id=ownerId,
                                                 comment_id=itemId)
            elif type == 'photo_comment':
                results = api.photos.reportComment(owner_id=ownerId,
                                                   comment_id=itemId)
            elif type == 'video_comment':
                results = api.video.reportComment(owner_id=ownerId,
                                                  comment_id=itemId)
            else:
                raise ValueError('unsupported type of item for report')
            if isinstance(results, int) and results == 1:
                response = True

        except Exception as e:
            print('posts report exception: ' + str(e))

        if response == False:
            print('report send failed with results: ' + str(results))
            dialogsManager.showDialogWithMessage('error_reporting')
        else:
            dialogsManager.showDialogWithMessage('report_sended_successfully')
            print('report sended successfully for type: ' + str(type))
        pass
예제 #2
0
 def repostObjectWithIdentifier(self, identifier):
     analytics.log('Posts_repost')
     dialogsManager = PyDialogsManager()
     index, cancelled = dialogsManager.showRowsDialogWithTitles(
         ['repost_for_friends'])
     if cancelled:
         return {}
     if index == 0:
         text, cancelled = dialogsManager.showTextFieldDialogWithText(
             'repost_enter_message')
         if cancelled:
             return {}
         return self.doRepostForFriends(identifier, text)
     return {}