Exemple #1
0
def main():
    try:
        count = 0
        while True:
            count += 1
            if count % SAVE_INTERVAL == 0:
                _save_cache()

            time.sleep(1)

            message = parse_next_msg()
            if not message:
                continue

            karma_changes = KARMA_ACTION.findall(message.text)
            if not karma_changes:
                continue

            logging.debug('karma changes: {}'.format(str(karma_changes)))
            process_karma_changes(message, karma_changes)
    finally:
        logging.info('Script ended, saving karma cache to file')
        # making sure we store karma cache before exiting the script, see
        # https://stackoverflow.com/questions/3850261/doing-something-before-program-exit
        _save_cache()
Exemple #2
0
def main():
    db_session.global_init()
    check_connection()

    while True:
        time.sleep(1)

        # Processes all interaction but karma changes
        message = parse_next_msg()
        if not message:
            continue

        # Finds and processes karma changes
        karma_changes = KARMA_ACTION.findall(message.text)
        if not karma_changes:
            continue

        logging.info(f"Karma changes: {str(karma_changes)}")
        process_karma_changes(message, karma_changes)
Exemple #3
0
def main():
    try:
        count = 0
        while True:
            count += 1

            message = parse_next_msg()
            if not message:
                continue

            karma_changes = KARMA_ACTION.findall(message.text)
            if not karma_changes:
                continue

            logging.debug('karma changes: {}'.format(str(karma_changes)))
            """add exclusion list for channels to do karma in"""
            """give feedback if channel does not accept karma?"""
            process_karma_changes(message, karma_changes)
    finally:
        logging.info('Script ended, saving karma cache to file')