當前位置: 首頁>>代碼示例>>Python>>正文


Python DatabaseManager.hasOfferBeenAccepted方法代碼示例

本文整理匯總了Python中DatabaseManager.DatabaseManager.hasOfferBeenAccepted方法的典型用法代碼示例。如果您正苦於以下問題:Python DatabaseManager.hasOfferBeenAccepted方法的具體用法?Python DatabaseManager.hasOfferBeenAccepted怎麽用?Python DatabaseManager.hasOfferBeenAccepted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DatabaseManager.DatabaseManager的用法示例。


在下文中一共展示了DatabaseManager.hasOfferBeenAccepted方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import hasOfferBeenAccepted [as 別名]

#.........這裏部分代碼省略.........
            self._acceptMade(comment)
        elif task == 2:
            self._successOnDeal(comment)
        elif task == 3:
            self._scamOnDeal(comment)
        elif task == 4:
            self._reportUser(comment)
        elif task == 5 or task == 6:
            self._cancelDeal(comment)
        else:
            self._replyWithError(comment, 'Err')


    def _offerMade(self, comment):

        '''
            posts the users stats and creates the offer
            pre:  praw comment object
            post: replies to comment with the users stats
        '''

        offer = self._parseComment(comment, '!offer')
        # check if there was no offer attached to the statement
        if not offer:
            if not self.debug:
                comment.reply('''Please provide an offer with the !offer statement.
                                 \n\nMake another comment with an offer after the stament.''')
                self.db.addCommentToReplied(comment.id)
            else:
                print('''Please provide an offer with the !offer statement.
                        \n\nMake another comment with an offer after the stament.''')
        # then if an offer has already been accepted, let the user know
        # that this offer can't be used
        elif self.db.hasOfferBeenAccepted(comment.submission.id):
            if not self.debug:
                comment.reply('Sorry, an offer has already been accepted on this thread.')
                self.db.addCommentToReplied(comment.id)
            else:
                print('Sorry, an offer has already been accepted on this thread.')
        # Reply to the offer statement with the stats of the user offering
        else:
            reply = '{} has offered {}\n\nHere are the users stats:\n\n'.format(str(comment.author),
                                                                                offer)
            stats = self.db.getUserStats(str(comment.author))

            # add info to the reply
            reply += templates.USER_STATS.format(stats[0], stats[1],
                                                 stats[2], stats[3])
            # if the user is new, add a warning
            if self._shouldAddNewUserWarning(str(comment.author)):
                reply += templates.WARNING

            if not self.debug:
                comment.reply(reply)
                self.db.addCommentToReplied(comment.id)
            else:
                print(reply)


    def _acceptMade(self, comment):

        '''
            method for dealing with the op accepting
            pre:  praw comment object
            post: a thread entry is created with the offer, replies
                  with a confirmation
開發者ID:NickHurst,項目名稱:ReputationManager,代碼行數:70,代碼來源:ReputationManager.py


注:本文中的DatabaseManager.DatabaseManager.hasOfferBeenAccepted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。