def guildwars2_filter_cm(comments, array_anet_names):
    for cm in comments:
        logging.info("comment")
        if cm.author.name in array_anet_names:
            logging.info("comment from anet: " + cm.name)
            row = bot_submissions()
            title = cm.link_title
            if (len(title) + len(cm.author.name) + 3) > 300:
                title = title[: 300 - len(cm.author.name) - 3 - 3]
                title += "..."
            row.title = title + " [" + cm.author.name + "]"
            row.type = "link"
            row.subreddit = "gw2devtrack"
            row.submitted = False
            row.content = cm.permalink.replace("//www.reddit.com", "//np.reddit.com") + "?context=1000"
            session.add(row)
        continue  # DISALLOWS COMMENTS TO BE PARSED FPR GW2 LINKS
        if re.search("http.*?:\/\/.*?guildwars2.com\/", cm.body) != None:
            logging.info("comment with gw2 link: " + cm.name)
            all_links = re.findall("http.*?:\/\/.*?guildwars2.com\/[^ \])\s]*", cm.body)
            for link in all_links:
                if link != "":
                    try:
                        prepare_comment(cm.name, False, guildwars2.locate_origin(link))
                    except Exception as e:
                        logging.error(e)
                        session.rollback()
                    else:
                        session.commit()
def guildwars2_filter_cm(comments, array_anet_names):
    for cm in comments:
        logging.info("comment")
        if cm.author.name in array_anet_names:
            logging.info("comment from anet: " + cm.name)
            row = bot_submissions()
            title = cm.link_title
            if (len(title) + len(cm.author.name) + 3) > 300:
                title = title[:300 - len(cm.author.name) - 3 - 3]
                title += '...'
            row.title = title + ' [' + cm.author.name + ']'
            row.type = 'link'
            row.subreddit = 'gw2devtrack'
            row.submitted = False
            row.content = cm.permalink.replace('//www.reddit.com','//np.reddit.com') + '?context=1000'
            session.add(row)
        continue # DISALLOWS COMMENTS TO BE PARSED FPR GW2 LINKS
        if re.search('http.*?:\/\/.*?guildwars2.com\/', cm.body) != None:
            logging.info("comment with gw2 link: " + cm.name)
            all_links = re.findall('http.*?:\/\/.*?guildwars2.com\/[^ \])\s]*', cm.body)
            for link in all_links:
                if link != '':
                    try:
                        prepare_comment(cm.name, False, guildwars2.locate_origin(link))
                    except Exception as e:
                        logging.error(e)
                        session.rollback()
                    else:
                        session.commit()
 def addSubmission(self, _subreddit, _title, _content, _type, _submitted=False):
     row = bot_submissions()
     row.title = _title
     row.type = _type
     row.subreddit = _subreddit
     row.content = _content
     row.submitted = _submitted
     session.add(row)
     session.commit()
Esempio n. 4
0
 def addSubmission(self,
                   _subreddit,
                   _title,
                   _content,
                   _type,
                   _submitted=False):
     row = bot_submissions()
     row.title = _title
     row.type = _type
     row.subreddit = _subreddit
     row.content = _content
     row.submitted = _submitted
     session.add(row)
     session.commit()
def guildwars2_filter_sm(submissions, array_anet_names):
    for sm in submissions:
        logging.info("submission")
        if sm.author.name in array_anet_names:
            logging.info("submission from anet: " + sm.name)
            row = bot_submissions()
            title = sm.title
            if (len(title) + len(sm.author.name) + 3) > 300:
                title = title[: 300 - len(sm.author.name) - 3 - 3]
                title += "..."
            row.title = title + " [" + sm.author.name + "]"
            row.type = "link"
            row.subreddit = "gw2devtrack"
            row.submitted = False
            row.content = sm.permalink.replace("//www.reddit.com", "//np.reddit.com") + "?context=1000"
            session.add(row)
        if re.search("http.*?:\/\/.*?guildwars2.com\/", sm.selftext) != None:
            logging.info("submission with gw2 link in selftext: " + sm.name)
            all_links = re.findall("http.*?:\/\/.*?guildwars2.com\/[^ \])\s]*", sm.selftext)
            for link in all_links:
                if link != "":
                    try:
                        prepare_comment(sm.name, False, guildwars2.locate_origin(link)[1])
                    except Exception as e:
                        session.rollback()
                        logging.error(e)
        session.commit()
        if re.search("http.*?:\/\/.*?guildwars2.com\/", sm.url) != None:
            logging.info("submission with gw2 link in url: " + sm.name)
            all_links = re.findall("http.*?:\/\/.*?guildwars2.com\/[^ \])]*", sm.url)
            for link in all_links:
                if link != "":
                    try:
                        prepare_comment(sm.name, False, guildwars2.locate_origin(link)[1])
                    except Exception as e:
                        logging.error(e)
                        session.rollback()
        session.commit()
def guildwars2_filter_sm(submissions, array_anet_names):
    for sm in submissions:
        logging.info('submission')
        if sm.author.name in array_anet_names:
            logging.info("submission from anet: " + sm.name )
            row = bot_submissions()
            title = sm.title
            if (len(title) + len(sm.author.name) + 3) > 300:
                title = title[:300 - len(sm.author.name) - 3 - 3]
                title += '...'
            row.title = title + ' [' + sm.author.name + ']'
            row.type = 'link'
            row.subreddit = 'gw2devtrack'
            row.submitted = False
            row.content = sm.permalink.replace('//www.reddit.com','//np.reddit.com') + '?context=1000'
            session.add(row)
        if re.search('http.*?:\/\/.*?guildwars2.com\/', sm.selftext) != None:
            logging.info("submission with gw2 link in selftext: " + sm.name)
            all_links = re.findall('http.*?:\/\/.*?guildwars2.com\/[^ \])\s]*', sm.selftext)
            for link in all_links:
                if link != '':
                    try:
                        prepare_comment(sm.name, False, guildwars2.locate_origin(link)[1])
                    except Exception as e:
                        session.rollback()
                        logging.error(e)
        session.commit()
        if re.search('http.*?:\/\/.*?guildwars2.com\/', sm.url) != None:
            logging.info("submission with gw2 link in url: " +  sm.name)
            all_links = re.findall('http.*?:\/\/.*?guildwars2.com\/[^ \])]*', sm.url)
            for link in all_links:
                if link != '':
                    try:
                        prepare_comment(sm.name, False, guildwars2.locate_origin(link)[1])
                    except Exception as e:
                        logging.error(e)
                        session.rollback()
        session.commit()