import re

class Parser:
    MENTION_REGEX = "^<@(|[WU].+?)>(.*)"

    def __init__(self, starterbot_id):
        self.starterbot_id = starterbot_id

    def parse_bot_commands(self, slack_events):
        """
            Parses a list of events coming from the Slack RTM API to find bot commands.
            If a bot command is found, this function returns a tuple of command and channel.
            If its not found, then this function returns None, None.
        """
        for event in slack_events:
            if event["type"] == "message" and not "subtype" in event:
                user_mention_id = event["user"]
                user_id, message = self.parse_direct_mention(event["text"])
                if user_id == self.starterbot_id:
                    return message, event["channel"], user_mention_id
        return None, None, None

    def parse_direct_mention(self, message_text):
        """
            Finds a direct mention (a mention that is at the beginning) in message text
            and returns the user ID which was mentioned. If there is no direct mention, returns None
        """
        matches = re.search(self.MENTION_REGEX, message_text)
        # the first group contains the username, the second group contains the remaining message
        return (matches.group(1), matches.group(2).strip()) if matches else (None, None)
51b2fd85af0851b491e1ed09e008a6cf3c3566a9
<mask token>


class Parser:
    <mask token>

    def __init__(self, starterbot_id):
        self.starterbot_id = starterbot_id
    <mask token>

    def parse_direct_mention(self, message_text):
        """
            Finds a direct mention (a mention that is at the beginning) in message text
            and returns the user ID which was mentioned. If there is no direct mention, returns None
        """
        matches = re.search(self.MENTION_REGEX, message_text)
        return (matches.group(1), matches.group(2).strip()) if matches else (
            None, None)

<mask token>


class Parser:
    <mask token>

    def __init__(self, starterbot_id):
        self.starterbot_id = starterbot_id

    def parse_bot_commands(self, slack_events):
        """
            Parses a list of events coming from the Slack RTM API to find bot commands.
            If a bot command is found, this function returns a tuple of command and channel.
            If its not found, then this function returns None, None.
        """
        for event in slack_events:
            if event['type'] == 'message' and not 'subtype' in event:
                user_mention_id = event['user']
                user_id, message = self.parse_direct_mention(event['text'])
                if user_id == self.starterbot_id:
                    return message, event['channel'], user_mention_id
        return None, None, None

    def parse_direct_mention(self, message_text):
        """
            Finds a direct mention (a mention that is at the beginning) in message text
            and returns the user ID which was mentioned. If there is no direct mention, returns None
        """
        matches = re.search(self.MENTION_REGEX, message_text)
        return (matches.group(1), matches.group(2).strip()) if matches else (
            None, None)

<mask token>


class Parser:
    MENTION_REGEX = '^<@(|[WU].+?)>(.*)'

    def __init__(self, starterbot_id):
        self.starterbot_id = starterbot_id

    def parse_bot_commands(self, slack_events):
        """
            Parses a list of events coming from the Slack RTM API to find bot commands.
            If a bot command is found, this function returns a tuple of command and channel.
            If its not found, then this function returns None, None.
        """
        for event in slack_events:
            if event['type'] == 'message' and not 'subtype' in event:
                user_mention_id = event['user']
                user_id, message = self.parse_direct_mention(event['text'])
                if user_id == self.starterbot_id:
                    return message, event['channel'], user_mention_id
        return None, None, None

    def parse_direct_mention(self, message_text):
        """
            Finds a direct mention (a mention that is at the beginning) in message text
            and returns the user ID which was mentioned. If there is no direct mention, returns None
        """
        matches = re.search(self.MENTION_REGEX, message_text)
        return (matches.group(1), matches.group(2).strip()) if matches else (
            None, None)

import re


class Parser:
    MENTION_REGEX = '^<@(|[WU].+?)>(.*)'

    def __init__(self, starterbot_id):
        self.starterbot_id = starterbot_id

    def parse_bot_commands(self, slack_events):
        """
            Parses a list of events coming from the Slack RTM API to find bot commands.
            If a bot command is found, this function returns a tuple of command and channel.
            If its not found, then this function returns None, None.
        """
        for event in slack_events:
            if event['type'] == 'message' and not 'subtype' in event:
                user_mention_id = event['user']
                user_id, message = self.parse_direct_mention(event['text'])
                if user_id == self.starterbot_id:
                    return message, event['channel'], user_mention_id
        return None, None, None

    def parse_direct_mention(self, message_text):
        """
            Finds a direct mention (a mention that is at the beginning) in message text
            and returns the user ID which was mentioned. If there is no direct mention, returns None
        """
        matches = re.search(self.MENTION_REGEX, message_text)
        return (matches.group(1), matches.group(2).strip()) if matches else (
            None, None)

import re

class Parser:
    MENTION_REGEX = "^<@(|[WU].+?)>(.*)"

    def __init__(self, starterbot_id):
        self.starterbot_id = starterbot_id

    def parse_bot_commands(self, slack_events):
        """
            Parses a list of events coming from the Slack RTM API to find bot commands.
            If a bot command is found, this function returns a tuple of command and channel.
            If its not found, then this function returns None, None.
        """
        for event in slack_events:
            if event["type"] == "message" and not "subtype" in event:
                user_mention_id = event["user"]
                user_id, message = self.parse_direct_mention(event["text"])
                if user_id == self.starterbot_id:
                    return message, event["channel"], user_mention_id
        return None, None, None

    def parse_direct_mention(self, message_text):
        """
            Finds a direct mention (a mention that is at the beginning) in message text
            and returns the user ID which was mentioned. If there is no direct mention, returns None
        """
        matches = re.search(self.MENTION_REGEX, message_text)
        # the first group contains the username, the second group contains the remaining message
        return (matches.group(1), matches.group(2).strip()) if matches else (None, None)