<commit_before>package extension

import (
	"bytes"
	"net/url"

	"github.com/kayex/sirius"
)

type Google struct{}

func (*Google) Run(m sirius.Message, cfg sirius.ExtensionConfig) (sirius.MessageAction, error) {
	cmd, match := m.Command("g")

	if !match {
		return sirius.NoAction(), nil
	}

	q := cmd.Arg(0)

	if q == "" {
		return sirius.NoAction(), nil
	}

	var urlb bytes.Buffer

	urlb.WriteString("https://www.google.com/search?q=")
	urlb.WriteString(url.QueryEscape(q))
<commit_msg>Fix bug where spaces would break google query string<commit_after>package extension

import (
	"bytes"
	"net/url"

	"github.com/kayex/sirius"
)

type Google struct{}

func (*Google) Run(m sirius.Message, cfg sirius.ExtensionConfig) (sirius.MessageAction, error) {
	cmd, match := m.Command("g")

	if !match || len(cmd.Args) == 0 {
		return sirius.NoAction(), nil
	}

	var qbuf bytes.Buffer

	for i, a := range cmd.Args {
		if i != 0 {
			qbuf.WriteRune(' ')
		}
		qbuf.WriteString(a)
	}

	var urlb bytes.Buffer

	urlb.WriteString("https://www.google.com/search?q=")
	urlb.WriteString(url.QueryEscape(qbuf.String()))

{'fraction_non_alphanumeric': 0.15760869565217392, 'fraction_numerical': 0.002717391304347826, 'mean_word_length': 4.068807339449541, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5131204', 'n_tokens_mistral': 442, 'n_tokens_neox': 417, 'n_words': 90}