<commit_before><?php
namespace PhpSlackBot;

abstract class Base {
    private $name;
    private $client;
    private $user;
    private $context;
    abstract protected function configure();
    abstract protected function execute($message, $context);

    public function getName() {
        $this->configure();
        return $this->name;
    }

    public function getClient() {
        return $this->client;
    }

    public function setName($name) {
        $this->name = $name;
    }

    public function setClient($client) {
        $this->client = $client;
    }

    public function setChannel($channel) {
        $this->channel = $channel;
    }

    public function setUser($user) {
        $this->user = $user;
    }

    public function getCurrentUser() {
        return $this->user;
    }

    public function setContext($context) {
        $this->context = $context;
    }

    public function getCurrentContext() {
        return $this->context;
    }

    public function getCurrentChannel() {
        return $this->channel;
    }

    protected function send($channel, $username, $message) {
        $response = array(
                          'id' => time(),
                          'type' => 'message',
                          'channel' => $channel,
                          'text' => (!is_null($username) ? '<@'.$username.'> ' : '').$message
                          );
        $this->client->send(json_encode($response));
    }

    protected function getUserNameFromUserId($userId) {
        $username = 'unknown';
        foreach ($this->context['users'] as $user) {
            if ($user['id'] == $userId) {
                $username = $user['name'];
            }
        }
        return $username;
    }

    protected function getChannelIdFromChannelName($channelName) {
        $channelName = str_replace('#', '', $channelName);
        foreach ($this->context['channels'] as $channel) {
            if ($channel['name'] == $channelName) {
                return $channel['id'];
            }
        }
        return false;
    }

    protected function getChannelNameFromChannelId($channelId) {
        foreach ($this->context['channels'] as $channel) {
            if ($channel['id'] == $channelId) {
                return $channel['name'];
            }
        }
        return false;
    }

    protected function getImIdFromUserId($userId) {
        foreach ($this->context['ims'] as $im) {
            if ($im['user'] == $userId) {
                return $im['id'];
            }
        }
        return false;
    }

}
<commit_msg>Added groups in checking for channels (#8)<commit_after><?php
namespace PhpSlackBot;

abstract class Base {
    private $name;
    private $client;
    private $user;
    private $context;
    abstract protected function configure();
    abstract protected function execute($message, $context);

    public function getName() {
        $this->configure();
        return $this->name;
    }

    public function getClient() {
        return $this->client;
    }

    public function setName($name) {
        $this->name = $name;
    }

    public function setClient($client) {
        $this->client = $client;
    }

    public function setChannel($channel) {
        $this->channel = $channel;
    }

    public function setUser($user) {
        $this->user = $user;
    }

    public function getCurrentUser() {
        return $this->user;
    }

    public function setContext($context) {
        $this->context = $context;
    }

    public function getCurrentContext() {
        return $this->context;
    }

    public function getCurrentChannel() {
        return $this->channel;
    }

    protected function send($channel, $username, $message) {
        $response = array(
                          'id' => time(),
                          'type' => 'message',
                          'channel' => $channel,
                          'text' => (!is_null($username) ? '<@'.$username.'> ' : '').$message
                          );
        $this->client->send(json_encode($response));
    }

    protected function getUserNameFromUserId($userId) {
        $username = 'unknown';
        foreach ($this->context['users'] as $user) {
            if ($user['id'] == $userId) {
                $username = $user['name'];
            }
        }
        return $username;
    }

    protected function getChannelIdFromChannelName($channelName) {
        $channelName = str_replace('#', '', $channelName);
        foreach ($this->context['channels'] as $channel) {
            if ($channel['name'] == $channelName) {
                return $channel['id'];
            }
        }
        foreach ($this->context['groups'] as $group) {
            if ($group['name'] == $channelName) {
                return $group['id'];
            }
        }
        return false;
    }

    protected function getChannelNameFromChannelId($channelId) {
        foreach ($this->context['channels'] as $channel) {
            if ($channel['id'] == $channelId) {
                return $channel['name'];
            }
        }
        foreach ($this->context['groups'] as $group) {
            if ($group['id'] == $channelId) {
                return $group['name'];
            }
        }
        return false;
    }

    protected function getImIdFromUserId($userId) {
        foreach ($this->context['ims'] as $im) {
            if ($im['user'] == $userId) {
                return $im['id'];
            }
        }
        return false;
    }

}

{'fraction_non_alphanumeric': 0.142495020822017, 'fraction_numerical': 0.0001810610175629187, 'mean_word_length': 1.8054850177755206, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, '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': '3481864', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1459, 'n_words': 330}