<commit_before>
# coding=utf-8

# Python std modules
import json

# Local modules
from common import debug
from common.action import action_classes
from common.telegram import telegram_utils

from user import user_utils

import modules

INTRO_MSG = "Hello {}, I'm Biblica Bot! I hope I will be helpful as a tool for you to handle the Bible!"
COMMAND_MSG = "Here are some things I can do:"
COMMAND_LIST = "\n".join([(action.identifier() + " - " + action.description()) for action in modules.get_actions() if action.is_command()])
HELP_MSG = INTRO_MSG + "\n\n" + COMMAND_MSG + "\n" + COMMAND_LIST

class StartAction(action_classes.Action):
    def identifier(self):
        return "/start"

    def name(self):
        return "Start Bot"

    def description(self):
        return "Start the Bot"

    def resolve(self, userObj, msg):
        # Register User
        userJson = msg.get("from")
        userId = user_utils.get_uid(userJson.get("id"))

        # This runs to update the user"s info, or register
        if userJson is not None:
            debug.log("Updating user info")
            user_utils.set_profile(
                userJson.get("id"), 
                userJson.get("username"), 
                userJson.get("first_name"), 
                userJson.get("last_name"))

        # If this is the user"s first time registering
        if userObj is None:
            debug.log_cmd("New user!")
            userObj = user_utils.get_user(userId)

            HelpAction().resolve(userObj, msg)
<commit_msg>Setting start to match as long as msg is not null<commit_after>
# coding=utf-8

# Python std modules
import json

# Local modules
from common import debug
from common.action import action_classes
from common.telegram import telegram_utils

from user import user_utils

import modules

INTRO_MSG = "Hello {}, I'm Biblica Bot! I hope I will be helpful as a tool for you to handle the Bible!"
COMMAND_MSG = "Here are some things I can do:"
COMMAND_LIST = "\n".join([(action.identifier() + " - " + action.description()) for action in modules.get_actions() if action.is_command()])
HELP_MSG = INTRO_MSG + "\n\n" + COMMAND_MSG + "\n" + COMMAND_LIST

class StartAction(action_classes.Action):
    def identifier(self):
        return "/start"

    def name(self):
        return "Start Bot"

    def description(self):
        return "Start the Bot"

    def match(self, msg):
        return msg is not None

    def resolve(self, userObj, msg):
        # Register User
        userJson = msg.get("from")
        userId = user_utils.get_uid(userJson.get("id"))

        # This runs to update the user"s info, or register
        if userJson is not None:
            debug.log("Updating user info")
            user_utils.set_profile(
                userJson.get("id"), 
                userJson.get("username"), 
                userJson.get("first_name"), 
                userJson.get("last_name"))

        # If this is the user"s first time registering
        if userObj is None:
            debug.log_cmd("New user!")
            userObj = user_utils.get_user(userId)

            HelpAction().resolve(userObj, msg)

{'fraction_non_alphanumeric': 0.10197578075207138, 'fraction_numerical': 0.0006373486297004461, 'mean_word_length': 2.5833333333333335, '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': '2032931', 'n_tokens_mistral': 924, 'n_tokens_neox': 894, 'n_words': 292}