<commit_before># coding=utf-8
"""
Veröffentlich die Favoriten der Curatoren als Retweets

@author <NAME> <<EMAIL>>
"""
import vertx
import mutex
import time
from com.xhaus.jyson import JysonCodec as json
from oauth import Consumer
from core.event_bus import EventBus
from util import parse_date
from datetime import datetime, timedelta

config = vertx.config()

curators = []
friends = []
aday = datetime.now() - timedelta(1)

def update_favorites(timer_id):
    EventBus.send('log.event', "update_favorites")
    for curator in curators:
        EventBus.send('log.event', "user.favorites.list")
        EventBus.send('user.favorites.list', curator)
    
def curators_received(message):
    global curators
    curators = json.loads(message.body)
    
def friends_received(message):
    global friends
    friends = json.loads(message.body)
        
def favorites_received(message):
    data = json.loads(message.body)
    for tweet in data['favorites']:
        created_at = parse_date(tweet['created_at'])
        if created_at > aday: # Retweet is recent
            if tweet['user']['id'] in friends: # Tweet is by an account we follow
                EventBus.send('log.event', "retweet.create")
                EventBus.send("retweet.create", tweet['id'])

EventBus.register_handler('curators.list.result', False, curators_received)
EventBus.register_handler('friends.list.result', False, friends_received)<commit_msg>Keine Antworten retweeten. Fixes #1.<commit_after># coding=utf-8
"""
Veröffentlich die Favoriten der Curatoren als Retweets

@author <NAME> <<EMAIL>>
"""
import vertx
import mutex
import time
from com.xhaus.jyson import JysonCodec as json
from oauth import Consumer
from core.event_bus import EventBus
from util import parse_date
from datetime import datetime, timedelta

config = vertx.config()

curators = []
friends = []
aday = datetime.now() - timedelta(1)

def update_favorites(timer_id):
    EventBus.send('log.event', "update_favorites")
    for curator in curators:
        EventBus.send('log.event', "user.favorites.list")
        EventBus.send('user.favorites.list', curator)
    
def curators_received(message):
    global curators
    curators = json.loads(message.body)
    
def friends_received(message):
    global friends
    friends = json.loads(message.body)
        
def favorites_received(message):
    data = json.loads(message.body)
    for tweet in data['favorites']:
        created_at = parse_date(tweet['created_at'])
        if created_at > aday: # Retweet is recent
            if tweet['user']['id'] in friends: # Tweet is by an account we follow
                if tweet['text'][0] is not '@': # Tweet is not a reply
                    # Of course there is: tweet['in_reply_to_screen_name'] but a reply may be a valid candidate for a retweet, as 
                    # an old school RT creates this type of tweet
                    EventBus.send('log.event', "retweet.create")
                    EventBus.send("retweet.create", tweet['id'])

EventBus.register_handler('curators.list.result', False, curators_received)
EventBus.register_handler('friends.list.result', False, friends_received)
{'fraction_non_alphanumeric': 0.10860590663702763, 'fraction_numerical': 0.001905366783105748, 'mean_word_length': 3.5718432510885343, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2084918', 'n_tokens_mistral': 982, 'n_tokens_neox': 951, 'n_words': 256}