当前位置: 首页>>代码示例>>Python>>正文


Python DatabaseHandler.updateTCGCardlist方法代码示例

本文整理汇总了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()
开发者ID:Nihilate,项目名称:YugiohLinkBot,代码行数:58,代码来源:YugiohLinkBot.py


注:本文中的DatabaseHandler.updateTCGCardlist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。