<commit_before>from django.utils.formats import localize
from django.conf import settings
from doctocnet.celery import app
from moderation.models import SocialUser, Follower
from messenger.models import Campaign, Message, Receipt
from dm.api import senddm
from celery.utils.log import get_task_logger
from moderation.social import followersids
import logging
import random
import time
import datetime

logger = logging.getLogger(__name__)
celery_logger = get_task_logger(__name__)

def hoursago(hours):
    delta = datetime.timedelta(hours=hours)
    return datetime.datetime.now() - delta

def randinterval():
    return random.randint(20, 30)/10.0

def _format(message, socialuser, campaign):
    d = {
        'screen_name' : socialuser.profile.screen_name_tag(),
    }
    return message.content.format(**d)

@app.task
def handle_campaign(name):
    celery_logger.debug("Task launched for campaign %s", name)
    logger.debug("Task launched for campaign %s", name)
    try:
        campaign = Campaign.objects.get(name=name)
    except Campaign.DoesNotExist:<commit_msg>improve messenger task<commit_after>from django.utils.formats import localize
from django.conf import settings
from doctocnet.celery import app
from moderation.models import SocialUser, Follower
from messenger.models import Campaign, Message, Receipt
from dm.api import senddm
from celery.utils.log import get_task_logger
from moderation.social import followersids
import logging
import random
import time
import datetime

logger = logging.getLogger(__name__)
celery_logger = get_task_logger(__name__)

def hoursago(hours):
    delta = datetime.timedelta(hours=hours)
    return datetime.datetime.now() - delta

def randinterval():
    return random.randint(300, 600)/10.0

def _format(message, socialuser, campaign):
    d = {
        'screen_name' : socialuser.profile.screen_name_tag(),
    }
    return message.content.format(**d)

@app.task
def handle_campaign(name):
    celery_logger.debug("Task launched for campaign %s", name)
    logger.debug("Task launched for campaign %s", name)
    try:
        campaign = Campaign.objects.get(name=name)
    except Campaign.DoesNotExist:
{'fraction_non_alphanumeric': 0.08800370541917554, 'fraction_numerical': 0.007410838351088467, 'mean_word_length': 4.79088471849866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6850563', 'n_tokens_mistral': 650, 'n_tokens_neox': 610, 'n_words': 177}