コード例 #1
0
def goodreads_bot_serve_people(subreddit='india'):
    global last_checked_comment
    for comment in get_latest_comments(subreddit):
        if comment.id in last_checked_comment:
            break
        last_checked_comment.append(comment.id)
        if 'goodreads.com' not in comment.body:
            continue
        author = comment.author
        if author.name == 'goodreadsbot':
            continue
        if is_already_replied(comment.id):
            break
        goodread_ids = get_goodreads_ids(comment.body)
        if not goodread_ids:
            continue
        spool = map(get_book_details_by_id, goodread_ids)
        message = prepare_the_message(spool)

        if len(message) > 9999:
            error = ('You have linked to many books in your comment and '
                     'my response crossed Reddit\'s 10k limit. Sorry!')
            comment.reply(error)
            log_this_comment(comment)
            replied_comments.append(comment.id)
            continue

        comment.reply(message)
        log_this_comment(comment)
        replied_comments.append(comment.id)
コード例 #2
0
def goodreads_bot_serve_people(subreddit='india'):
    global last_checked_comment
    for comment in get_latest_comments(subreddit):
        if comment.id in last_checked_comment:
            break
        last_checked_comment.append(comment.id)
        if 'goodreads.com' not in comment.body:
            continue
        author = comment.author
        if author.name == 'goodreadsbot':
            continue
        if is_already_replied(comment.id):
            break
        goodread_ids = get_goodreads_ids(comment.body)
        if not goodread_ids:
            continue
        spool = map(get_book_details_by_id, goodread_ids)
        message = prepare_the_message(spool)
        try:
            comment.reply(message)
            log_this_comment(comment)
        except praw.errors.APIException as e:
            if 'too long' in e.message:
                error = ('You have linked to many books in your comment and '
                         'my response crossed Reddit\'s 10k limit. Sorry!')
                comment.reply(error)
            replied_comments.append(comment.id)
コード例 #3
0
ファイル: main.py プロジェクト: Gbear605/Reddit-GoodReads-Bot
def goodreads_bot_serve_people(subreddit='india'):
    global last_checked_comment
    for comment in get_latest_comments(subreddit):
        if comment.id in last_checked_comment:
            break
        last_checked_comment.append(comment.id)
        if 'goodreads.com' not in comment.body:
            continue
        if is_already_replied(comment.id):
            break
        goodread_ids = get_goodreads_ids(comment.body)
        if not goodread_ids:
            continue
        spool = map(get_book_details_by_id, goodread_ids)
        message = prepare_the_message(spool)
        comment.reply(message)
        log_this_comment(comment)
コード例 #4
0
ファイル: main.py プロジェクト: GrimDerp/Reddit-GoodReads-Bot
def goodreads_bot_serve_people(subreddit='india'):
    global last_checked_comment
    for comment in get_latest_comments(subreddit):
        if comment.id in last_checked_comment:
            break
        last_checked_comment.append(comment.id)
        if 'goodreads.com' not in comment.body:
            continue
        if is_already_replied(comment.id):
            break
        goodread_ids = get_goodreads_ids(comment.body)
        if not goodread_ids:
            continue
        spool = map(get_book_details_by_id, goodread_ids)
        message = prepare_the_message(spool)
        comment.reply(message)
        log_this_comment(comment)