<commit_before>import json

import hangups

import plugins

from utils import text_to_segments, simple_parse_to_segments, get_conv_name


_internal = {} # non-persistent internal state independent of config.json/memory.json

_internal["broadcast"] = { "message": "", "conversations": [] } # /bot broadcast

def _initialise(Handlers, bot=None):
    admin_commands = ["broadcast", "users", "hangouts", "rename", "leave", "reload", "quit", "config", "whereami"]
    user_commands = ["echo", "echoparsed", "whoami"]
    try:
        plugins.register_admin_command(admin_commands)
        plugins.register_user_command(user_commands)
    except Exception as e:
        if "register_admin_command" in dir(Handlers) and "register_user_command" in dir(Handlers):
            print(_("DEFAULT: LEGACY FRAMEWORK MODE"))
            Handlers.register_admin_command(admin_commands)
            Handlers.register_user_command(user_commands)
        else:
            print(_("DEFAULT: OBSOLETE FRAMEWORK MODE"))
            return admin_commands + user_commands
    return []


def echo(bot, event, *args):
    """echo back requested text"""

    # Check if the first argument is a known conv_id match
    if args[0] in list(bot.memory.get_by_path(["conv_data"]).keys()):
        text = ' '.join(args[1:])
        conv_id = args[0]

    else:
        text = ' '.join(args)
        conv_id = event.conv_id
<commit_msg>readded "user" command<commit_after>import json

import hangups

import plugins

from utils import text_to_segments, simple_parse_to_segments, get_conv_name


_internal = {} # non-persistent internal state independent of config.json/memory.json

_internal["broadcast"] = { "message": "", "conversations": [] } # /bot broadcast

def _initialise(Handlers, bot=None):
    admin_commands = ["broadcast", "users", "user", "hangouts", "rename", "leave", "reload", "quit", "config", "whereami"]
    user_commands = ["echo", "echoparsed", "whoami"]
    try:
        plugins.register_admin_command(admin_commands)
        plugins.register_user_command(user_commands)
    except Exception as e:
        if "register_admin_command" in dir(Handlers) and "register_user_command" in dir(Handlers):
            print(_("DEFAULT: LEGACY FRAMEWORK MODE"))
            Handlers.register_admin_command(admin_commands)
            Handlers.register_user_command(user_commands)
        else:
            print(_("DEFAULT: OBSOLETE FRAMEWORK MODE"))
            return admin_commands + user_commands
    return []


def echo(bot, event, *args):
    """echo back requested text"""

    # Check if the first argument is a known conv_id match
    if args[0] in list(bot.memory.get_by_path(["conv_data"]).keys()):
        text = ' '.join(args[1:])
        conv_id = args[0]

    else:
        text = ' '.join(args)
        conv_id = event.conv_id

{'fraction_non_alphanumeric': 0.12141592920353983, 'fraction_numerical': 0.0021238938053097347, 'mean_word_length': 3.5580645161290323, 'pattern_counts': {'":': 4, '<': 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': '97392', 'n_tokens_mistral': 871, 'n_tokens_neox': 860, 'n_words': 207}