<commit_before><?php namespace ThreadMeUp\Slack;

class Chat {

    protected $client;
    protected $channel;

    public function __construct(Client $client, $channel)
    {
        $this->client = $client;
        $this->channel = $channel;
    }

    public function send($message = null, $attachments = null)
    {
        $config = $this->client->getConfig();
        $query = array_merge(array('text' => $message, 'channel' => $this->channel, 'attachments' => json_encode($attachments)), $config);
        $request = $this->client->request('chat.postMessage', $query)->send();
        $response = new Response($request);
        if ($this->client->debug)
        {
            if ($response->isOkay())
            {
                echo $this->client->config['username'].' ['.$this->channel.']: '.$message.PHP_EOL;
                return true;
            }
            else
            {
                echo '[Error] '.$response->getError().'.'.PHP_EOL;
                return false;
            }
        }
    }
}<commit_msg>Don't echo status response on success, this corrupts valid json output when being called via API, causes requests to look like they failed. Add performed query to Error output, helps debug query issues.<commit_after><?php namespace ThreadMeUp\Slack;

class Chat {

    protected $client;
    protected $channel;

    public function __construct(Client $client, $channel)
    {
        $this->client = $client;
        $this->channel = $channel;
    }

    public function send($message = null, $attachments = null)
    {
        $config = $this->client->getConfig();
        $query = array_merge(array('text' => $message, 'channel' => $this->channel, 'attachments' => json_encode($attachments)), $config);
        $request = $this->client->request('chat.postMessage', $query)->send();
        $response = new Response($request);
        if ($this->client->debug)
        {
            if ($response->isOkay())
            {
                //echo $this->client->config['username'].' ['.$this->channel.']: '.$message.PHP_EOL;
                return true;
            }
            else
            {
                echo '[Error] '.$response->getError().'.'.PHP_EOL;
		echo '[Query] '.var_export($this->client->request('chat.postMessage', $query)->getQuery(), true);
                return false;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.15785019043588658, 'fraction_numerical': 0.0, 'mean_word_length': 2.1731543624161076, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, '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': '2039419', 'n_tokens_mistral': 656, 'n_tokens_neox': 640, 'n_words': 149}