<commit_before>
# Local modules
from common import debug
from common import admin
from common import chrono
from common import telegram

from user.bibleuser_utils import *

from common.constants import *

def foreach_user(fn):
    debug.log('Running ' + str(fn) + ' for each user')
    
    # Read user database
    query = get_user_query()
    query.filter('active =', True)

    try:
        for user in query.run(batch_size=500):
            fn(database.get_uid(user))
    except Exception as e:
        debug.log(str(e))
 
def blast_msg(msg):
    debug.log('Blasting message: ' + msg)

    def send(uid):
        if not debug.debug() or admin.access(uid):
            telegram.send_msg(msg, uid)
    
    foreach_user(send)


# Telegram message parsing
def parse_payload(msg):
    if msg is None:
        return None

    text = msg.get('text')
    if text is not None:
        return text

    audio = msg.get('audio')
    if audio is not None:
        return audio

    document = msg.get('document')
    if document is not None:
        return document<commit_msg>Fixing bug in blast msg<commit_after>
# Local modules
from common import debug
from common import admin
from common import chrono
from common import telegram

from user.bibleuser_utils import *

from common.constants import *

def foreach_user(fn):
    debug.log('Running ' + str(fn) + ' for each user')
    
    # Read user database
    query = get_user_query()
    query.filter('active =', True)

    try:
        for user in query.run(batch_size=500):
            fn(get_uid(user))
    except Exception as e:
        debug.log(str(e))
 
def blast_msg(msg):
    debug.log('Blasting message: ' + msg)

    def send(uid):
        if not debug.debug() or admin.access(uid):
            telegram.send_msg(msg, uid)
    
    foreach_user(send)


# Telegram message parsing
def parse_payload(msg):
    if msg is None:
        return None

    text = msg.get('text')
    if text is not None:
        return text

    audio = msg.get('audio')
    if audio is not None:
        return audio

    document = msg.get('document')
    if document is not None:
        return document
{'fraction_non_alphanumeric': 0.09472701819878675, 'fraction_numerical': 0.0027998133457769483, 'mean_word_length': 2.5733333333333333, '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': '5290483', 'n_tokens_mistral': 664, 'n_tokens_neox': 643, 'n_words': 209}