本文整理匯總了Python中DatabaseManager.DatabaseManager.getUserStats方法的典型用法代碼示例。如果您正苦於以下問題:Python DatabaseManager.getUserStats方法的具體用法?Python DatabaseManager.getUserStats怎麽用?Python DatabaseManager.getUserStats使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DatabaseManager.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.getUserStats方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import getUserStats [as 別名]
#.........這裏部分代碼省略.........
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
'''
author = str(comment.author)
parent = self._getParentComment(comment)
# check if it's in reply to the user info from the bot
if str(parent.author) == self.username:
# get the comment above it
parent = self._getParentComment(parent)