示例#1
0
def reply(data):
    bot = bots[0]  # 现在只有一只小鸡了,且没了评论限制

    data, message = getNotiData(bot, data)

    if not data:
        return

    # 不要自问自答
    if 'author_name' in data and '小黄鸡' in data['author_name'].encode('utf-8'):
        return

    print 'handling comment', data, '\n'

    data['message'] = questionfilter(message)
    answer = magic(data, bot)
    data['message'] = answerfilter(answer)

    result = bot.addComment(data)

    code = result['code']
    if code == 0:
        return

    if code == 10:
        print 'some words are blocked'
    else:
        raise Exception('Error sending comment by bot %s' % bot.email)
示例#2
0
def reply(data, message):
    # 不要自问自答
    if 'author_name' in data and  '小黄鸡' in data['author_name'].encode('utf-8'):
        return

    data['message'] = answerfilter(magic(questionfilter(message)))

    current_bot_index = int(r.get('current_bot_index') or 0)
    bot = bots[current_bot_index]
    result = bot.addComment(data)

    # 如果连续8次遇到 code 1031,则认为被封了,换下一个账号
    if result['code'] == 1031:
        reach_limit_time, MAX_LIMIT_TRY = r.incr('reach_limit_time'), 8
        if int(reach_limit_time) == MAX_LIMIT_TRY:
            r.set('reach_limit_time', 0)
            current_bot_index = r.incr('current_bot_index')
            if int(current_bot_index) >= len(bots):
                r.set('current_bot_index', 0)
                raise Exception('SHIT!!!!!!ALL BOTS ARE DOWN!!!!!!!!!!')
            else:
                raise Exception('bot %s reach comment limit' % bot.email)
        else:
            print 'maybe comment limit', bot.email
    elif result['code'] == 0:
        r.set('reach_limit_time', 0)
    else:
        raise Exception('Error sending comment by bot %s' % bot.email)
示例#3
0
def reply(data):
    bot = bots[0]  # 现在只有一只小鸡了,且没了评论限制

    data, message = getNotiData(bot, data)

    if not data:
        return

    # 不要自问自答
    if '小黄鸡' in data.get('author_name', u'').encode('utf-8'):
        return

    print 'handling comment', data, '\n'

    data['message'] = questionfilter(message)
    answer = magic(data, bot)
    data['message'] = answerfilter(answer)

    result = bot.addComment(data)

    code = result['code']
    if code == 0:
        return

    if code == 10:
        print 'some words are blocked'
    else:
        raise Exception('Error sending comment by bot %s' % bot.email)
示例#4
0
def reply(data, message):
    # 不要自问自答
    if 'author_name' in data and '小黄鸡' in data['author_name'].encode('utf-8'):
        return

    data['message'] = answerfilter(magic(questionfilter(message)))

    bot = bots[0]  # 现在只有一只小鸡了,且没了评论限制
    result = bot.addComment(data)

    if result['code'] != 0:
        raise Exception('Error sending comment by bot %s' % bot.email)
示例#5
0
def reply(data):
    bot = bots[0] # 现在只有一只小鸡了,且没了评论限制

    data, message = getNotiData(bot, data)

    if not data:
        return

    # 不要自问自答
    if 'author_name' in data and '小黄鸡' in data['author_name'].encode('utf-8'):
        return

    print 'handling comment', data, '\n'

    data['message'] = answerfilter(magic(questionfilter(message)))

    result = bot.addComment(data)

    if result['code'] != 0:
        raise Exception('Error sending comment by bot %s' % bot.email)
示例#6
0
def reply(data):
    bot = bots[0]  # 现在只有一只小鸡了,且没了评论限制

    data, message = getNotiData(bot, data)

    if not data:
        return

    # 不要自问自答
    if 'author_name' in data and '小黄鸡' in data['author_name'].encode('utf-8'):
        return

    print 'handling comment', data, '\n'

    data['message'] = answerfilter(magic(questionfilter(message)))

    result = bot.addComment(data)

    if result['code'] != 0:
        raise Exception('Error sending comment by bot %s' % bot.email)