本文整理汇总了Python中DatabaseHandler.updateTCGCardlist方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseHandler.updateTCGCardlist方法的具体用法?Python DatabaseHandler.updateTCGCardlist怎么用?Python DatabaseHandler.updateTCGCardlist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseHandler
的用法示例。
在下文中一共展示了DatabaseHandler.updateTCGCardlist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import DatabaseHandler [as 别名]
# 或者: from DatabaseHandler import updateTCGCardlist [as 别名]
def run(self):
try:
print("Starting stream")
commentStream = praw.helpers.comment_stream(self.reddit, self.subredditList, limit=1000, verbosity=0)
for comment in commentStream:
if ((time.time() - self.updateTime) > Config.tcgUpdateInterval * 60 * 60):
DatabaseHandler.updateTCGCardlist()
self.updateTime = time.time()
if ((time.time() - self.submissionsLastProcessed) > Config.submissionProcessingInterval * 60 * 60):
self.submissionProcessor.processSubmissions(100)
self.submissionsLastProcessed = time.time()
#print("Found comment")
#If we've already seen this comment, ignore it
if DatabaseHandler.commentExists(comment.id):
continue
#If the post has been deleted, getting the author will return an error
try:
author = comment.author.name
except Exception as e:
continue
#If this is one of our own comments, ignore it
if (author == 'YugiohLinkBot'):
continue
reply = self.requestHandler.buildResponse(comment.body)
try:
if reply:
cards = re.findall('\[\*\*(.+?)\*\*\]\(', reply)
for card in cards:
DatabaseHandler.addRequest(card, author, comment.subreddit)
if("VENT THREAD" in comment.link_title):
reply = self.submissionProcessor.convertCase(True, reply)
elif("happiness thread" in comment.link_title):
reply = self.submissionProcessor.convertCase(False, reply)
DatabaseHandler.addComment(comment.id, author, comment.subreddit, True)
comment.reply(reply)
print("Comment made.\n")
else:
if ('{' in comment.body and '}' in comment.body):
print('')
DatabaseHandler.addComment(comment.id, author, comment.subreddit, False)
except Exception as e:
print("Reddit probably broke when replying:" + str(e) + '\n')
except Exception as e:
print("Error with comment stream: " + str(e))
traceback.print_exc()