<commit_before>package main

import (
	"flag"
	"fmt"
	"github.com/mrjones/oauth"
	"log"
	"os"
)

type user struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	ScreenName string `json:"screen_name"`
}
type status struct {
	ID   int64  `json:"id"`
	Text string `json:"text"`
	User user   `json:"user"`
}

var tweet *string = flag.String(
	"tweet",
	"here",
	"please write your tweet here! ",
	)

var consumerKey *string = flag.String(
	"consumerkey",
	"<KEY>",
	"Consumer Key from Twitter. See: https://dev.twitter.com/apps/new")

var consumerSecret *string = flag.String(
	"consumersecret",
	"<KEY>",
	"Consumer Secret from Twitter. See: https://dev.twitter.com/apps/new")

var accessToken *oauth.AccessToken

func main() {
	
	flag.Parse()
	fmt.Println("loading consumerkey......")
	loading()
	post_tweet()

}

var c = oauth.NewConsumer(
	*consumerKey,
	*consumerSecret,
	oauth.ServiceProvider{
		RequestTokenUrl:   "https://api.twitter.com/oauth/request_token",
		AuthorizeTokenUrl: "https://api.twitter.com/oauth/authorize",
		AccessTokenUrl:    "https://api.twitter.com/oauth/access_token",
	})

func loading() {

	if len(*consumerKey) == 0 || len(*consumerSecret) == 0 {
		fmt.Println("You must set the --consumerkey and --consumersecret flags.")
		fmt.Println("---")
		os.Exit(1)
	}

	requestToken, url, err := c.GetRequestTokenAndUrl("oob")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("(1) Go to: " + url)
	fmt.Println("(2) Grant access, you should get back a verification code.")
	fmt.Println("(3) Enter that verification code here: ")
	verificationCode := ""
	fmt.Scanln(&verificationCode)
	fmt.Println("loading successed.")
	accessToken, err = c.AuthorizeToken(requestToken, verificationCode)
	if err != nil {
		log.Fatal(err)
	}

}


func post_tweet() {

	response, err := c.Post("https://api.twitter.com/1.1/statuses/update.json",
		map[string]string{"status": *tweet}, accessToken)
	if err != nil {
		log.Fatal(err)
	}
	defer response.Body.Close()

	fmt.Println("tweeted!!")

}<commit_msg>add func post_name<commit_after>package main

import (
	"flag"
	"fmt"
	"github.com/mrjones/oauth"
	"log"
	"os"
)

type user struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	ScreenName string `json:"screen_name"`
}
type status struct {
	ID   int64  `json:"id"`
	Text string `json:"text"`
	User user   `json:"user"`
}

var name *string = flag.String(
	"name",
	"here",
	"please write your name here! ",
	)


var tweet *string = flag.String(
	"tweet",
	"here",
	"please write your tweet here! ",
	)

var consumerKey *string = flag.String(
	"consumerkey",
	"<KEY>",
	"Consumer Key from Twitter. See: https://dev.twitter.com/apps/new")

var consumerSecret *string = flag.String(
	"consumersecret",
	"cGOq2NGmEqdwzVPPkQfMJuh6HEVFuVz5qFqBQJAteVuKC4ZQS9",
	"Consumer Secret from Twitter. See: https://dev.twitter.com/apps/new")

var accessToken *oauth.AccessToken

func main() {
	
	flag.Parse()
	fmt.Println("loading consumerkey......")
	loading()
	if *tweet != "here"{
		post_tweet()
	}
	
	if *name != "here"{
		post_name()
	}
}

var c = oauth.NewConsumer(
	*consumerKey,
	*consumerSecret,
	oauth.ServiceProvider{
		RequestTokenUrl:   "https://api.twitter.com/oauth/request_token",
		AuthorizeTokenUrl: "https://api.twitter.com/oauth/authorize",
		AccessTokenUrl:    "https://api.twitter.com/oauth/access_token",
	})

func loading() {

	if len(*consumerKey) == 0 || len(*consumerSecret) == 0 {
		fmt.Println("You must set the --consumerkey and --consumersecret flags.")
		fmt.Println("---")
		os.Exit(1)
	}

	requestToken, url, err := c.GetRequestTokenAndUrl("oob")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("(1) Go to: " + url)
	fmt.Println("(2) Grant access, you should get back a verification code.")
	fmt.Println("(3) Enter that verification code here: ")
	verificationCode := ""
	fmt.Scanln(&verificationCode)
	fmt.Println("loading successed.")
	accessToken, err = c.AuthorizeToken(requestToken, verificationCode)
	if err != nil {
		log.Fatal(err)
	}

}


func post_tweet() {

	response, err := c.Post("https://api.twitter.com/1.1/statuses/update.json",
		map[string]string{"status": *tweet}, accessToken)
	if err != nil {
		log.Fatal(err)
	}
	defer response.Body.Close()

	fmt.Println("tweeted!!")

}



func post_name() {

	response, err := c.Post("https://api.twitter.com/1.1/account/update_profile.json",
		map[string]string{"name": *name}, accessToken)
	if err != nil {
		log.Fatal(err)
	}
	defer response.Body.Close()

	fmt.Println("name posted!!")
	
}
{'fraction_non_alphanumeric': 0.16847465131724595, 'fraction_numerical': 0.006862962143015275, 'mean_word_length': 4.059350503919373, 'pattern_counts': {'":': 3, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 13, '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': '2412351', 'n_tokens_mistral': 1755, 'n_tokens_neox': 1667, 'n_words': 358}