<commit_before>from .channel_db import ChannelDb
from .server import Server
from . import settings


class FlowBot(object):

    def __init__(self):
        """Initialize the bot with an active flow instance."""
        self.server = Server()
        self.account_id = self.server.flow.account_id()
        self._commands = self._register_commands()
        self.channel_db = ChannelDb(self.server)

    def reply(self, response_msg, original_message):
        """Reply to the original message in the same channel."""
        self.server.flow.send_message(
            cid=original_message.get('channelId'),
            oid=settings.ORG_ID,
            msg=response_msg
        )

    def mentioned(self, message):
        """Determine if this bot was mentioned in the message."""
        username_mention = '@' + settings.FLOWBOT_USERNAME.lower()
        return username_mention in message.get('text', '').lower()

    def from_admin(self, message):
        """Determine if this message was sent from an admin of the org."""
        if message['senderAccountId'] == self.account_id:
            return False

        for member in self.server.flow.enumerate_channel_members(message['channelId']):  # NOQA
            if member['accountId'] == message['senderAccountId']:<commit_msg>Added the handle message method.<commit_after>from .channel_db import ChannelDb
from .server import Server
from . import settings


class FlowBot(object):

    def __init__(self):
        """Initialize the bot with an active flow instance."""
        self.server = Server()
        self.account_id = self.server.flow.account_id()
        self._commands = self._register_commands()
        self.channel_db = ChannelDb(self.server)

    def reply(self, response_msg, original_message):
        """Reply to the original message in the same channel."""
        self.server.flow.send_message(
            cid=original_message.get('channelId'),
            oid=settings.ORG_ID,
            msg=response_msg
        )

    def handle_message(self, notification_type, message):
        """Handle an incoming flow message."""
        for m in message.get('regularMessages', []):
            self._process_commands(m)

    def mentioned(self, message):
        """Determine if this bot was mentioned in the message."""
        username_mention = '@' + settings.FLOWBOT_USERNAME.lower()
        return username_mention in message.get('text', '').lower()

    def from_admin(self, message):
        """Determine if this message was sent from an admin of the org."""
        if message['senderAccountId'] == self.account_id:
            return False

        for member in self.server.flow.enumerate_channel_members(message['channelId']):  # NOQA
            if member['accountId'] == message['senderAccountId']:
{'fraction_non_alphanumeric': 0.10963335729690869, 'fraction_numerical': 0.0, 'mean_word_length': 2.870653685674548, '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': '1713596', 'n_tokens_mistral': 744, 'n_tokens_neox': 726, 'n_words': 207}