<commit_before>package twitter

import (
	"encoding/json"
	"fmt"
	"github.com/0x263b/Porygon2"
	"github.com/kurrik/oauth1a"
	"github.com/kurrik/twittergo"
	"net/http"
	"net/url"
)

func LoadCredentials() (client *twittergo.Client, err error) {
	config := &oauth1a.ClientConfig{
		ConsumerKey:    bot.Config.Api.TwitterConsumerKey,
		ConsumerSecret: bot.Config.Api.TwitterConsumerSecret,
	}
	client = twittergo.NewClient(config, nil)
	return
}

func twitter(command *bot.Cmd, matches []string) (msg string, err error) {
	var (
		err     error
		client  *twittergo.Client
		query   url.Values
		req     *http.Request
		resp    *twittergo.APIResponse
		results *twittergo.Timeline
		output  string
	)

	if client, err = LoadCredentials(); err != nil {
		return "Twitter | Could not get tweet", nil
	}

	query = url.Values{}
	query.Set("count", "1")
	query.Set("screen_name", screenName)

	endpoint := fmt.Sprintf("/1.1/statuses/user_timeline.json?%v", query.Encode())

	if req, err = http.NewRequest("GET", endpoint, nil); err != nil {
		return "Twitter | Could not get tweet", nil
	}
	if resp, err = client.SendRequest(req); err != nil {
		return "Twitter | Could not get tweet", nil
	}
	results = &twittergo.Timeline{}<commit_msg>Twitter command definitely<commit_after>package twitter

import (
	"encoding/json"
	"fmt"
	"github.com/0x263b/Porygon2"
	"github.com/kurrik/oauth1a"
	"github.com/kurrik/twittergo"
	"net/http"
	"net/url"
)

func LoadCredentials() (client *twittergo.Client, err error) {
	config := &oauth1a.ClientConfig{
		ConsumerKey:    bot.Config.API.TwitterConsumerKey,
		ConsumerSecret: bot.Config.API.TwitterConsumerSecret,
	}
	client = twittergo.NewClient(config, nil)
	return
}

func twitter(command *bot.Cmd, matches []string) (msg string, err error) {
	var (
		client  *twittergo.Client
		query   url.Values
		req     *http.Request
		resp    *twittergo.APIResponse
		results *twittergo.Timeline
		output  string
	)

	if client, err = LoadCredentials(); err != nil {
		return "Twitter | Could not get tweet", nil
	}

	query = url.Values{}
	query.Set("count", "1")
	query.Set("exclude_replies", "true")
	query.Set("screen_name", matches[1])

	endpoint := fmt.Sprintf("/1.1/statuses/user_timeline.json?%v", query.Encode())

	if req, err = http.NewRequest("GET", endpoint, nil); err != nil {
		return "Twitter | Could not get tweet", nil
	}
	if resp, err = client.SendRequest(req); err != nil {
		return "Twitter | Could not get tweet", nil
	}
	results = &twittergo.Timeline{}
{'fraction_non_alphanumeric': 0.13959085439229843, 'fraction_numerical': 0.00842358604091456, 'mean_word_length': 4.163561076604555, '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': '4793946', 'n_tokens_mistral': 926, 'n_tokens_neox': 867, 'n_words': 205}