<commit_before>package main

import (
	"github.com/cadena-monde/slackbot"
	"os"
	"flag"
)

var (
	channel, message string
	slackURL        = os.Getenv("SLACKBOT_URL")
	token           = os.Getenv("SLACKBOT_TOKEN")
)

func main() {
	parseFlags()
	postMessage();
}

func parseFlags() {
	flag.StringVar(&channel, "channel", "", "Channel. Ex: #random")
	flag.StringVar(&message, "message", "", "Message to be sent to the channel")
	flag.Parse()

	if channel == "" || message == "" {
		flag.Usage()
		os.Exit(1)
	}
}

func postMessage() {
	b := slackbot.New(slackURL, token)
	b.PostMessage(channel, message)
}<commit_msg>Adds -stdin option to read messages from the stdin<commit_after>package main

import (
	"bytes"
	"flag"
	"fmt"
	"github.com/cadena-monde/slackbot"
	"os"
	"strings"
)

var (
	channel, message string
	stdin            bool
	slackURL         = os.Getenv("SLACKBOT_URL")
	token            = os.Getenv("SLACKBOT_TOKEN")
)

func main() {
	parseFlags()
	if stdin {
		readFromStdin()
	}
	postMessage()
}

func readFromStdin() {
	input := bytes.NewBuffer([]byte{})
	input.ReadFrom(os.Stdin)

	inputString := input.String()
	if inputString != "" {
		message = fmt.Sprintf("%s\n```%s```", message, input.String())
		message = strings.Replace(message, "\r", "", -1)
	}
}

func parseFlags() {
	flag.StringVar(&channel, "channel", "", "Channel. Ex: #random")
	flag.StringVar(&message, "message", "", "Message to be sent to the channel")
	flag.BoolVar(&stdin, "stdin", false, "Read message from stdin")
	flag.Parse()

	if channel == "" || (message == "" && !stdin) {
		flag.Usage()
		os.Exit(1)
	}
}

func postMessage() {
	b := slackbot.New(slackURL, token)
	b.PostMessage(channel, message)
}
{'fraction_non_alphanumeric': 0.17779090372120496, 'fraction_numerical': 0.0017720023626698169, 'mean_word_length': 3.853868194842407, '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': '6115318', 'n_tokens_mistral': 648, 'n_tokens_neox': 632, 'n_words': 135}