<commit_before>package telegram

import (
	"encoding/json"
	"net/url"
	"strconv"
)

// BaseChat describes chat settings. It's an abstract type.
//
// You must set ID or ChannelUsername.
type BaseChat struct {
	// Unique identifier for the target chat
	ID int64
	// Username of the target channel (in the format @channelusername)
	ChannelUsername string
}

// Values returns RequiredError if neither ID or ChannelUsername are empty.
// Prefers ChannelUsername if both ID and ChannelUsername are not empty.
func (c BaseChat) Values() (url.Values, error) {
	v := url.Values{}
	if c.ChannelUsername != "" {
		v.Add("chat_id", c.ChannelUsername)
		return v, nil
	}
	if c.ID != 0 {
		v.Add("chat_id", strconv.FormatInt(c.ID, 10))
		return v, nil
	}
	return nil, NewRequiredError("ID", "ChannelUsername")
}

// GetChatCfg contains information about a getChat request.
type GetChatCfg struct {
	BaseChat
}

// Name returns method name
func (cfg GetChatCfg) Name() string {
	return getChatMethod
}

// Values returns a url.Values representation of GetChatCfg.
// Returns RequiredError if Chat is not set.<commit_msg>Add helper to set ChatID<commit_after>package telegram

import (
	"encoding/json"
	"net/url"
	"strconv"
)

// BaseChat describes chat settings. It's an abstract type.
//
// You must set ID or ChannelUsername.
type BaseChat struct {
	// Unique identifier for the target chat
	ID int64
	// Username of the target channel (in the format @channelusername)
	ChannelUsername string
}

// Values returns RequiredError if neither ID or ChannelUsername are empty.
// Prefers ChannelUsername if both ID and ChannelUsername are not empty.
func (c BaseChat) Values() (url.Values, error) {
	v := url.Values{}
	if c.ChannelUsername != "" {
		v.Add("chat_id", c.ChannelUsername)
		return v, nil
	}
	if c.ID != 0 {
		v.Add("chat_id", strconv.FormatInt(c.ID, 10))
		return v, nil
	}
	return nil, NewRequiredError("ID", "ChannelUsername")
}

// SetChatID sets new chat id
func (c *BaseChat) SetChatID(id int64) {
	c.ID = id
}

// GetChatCfg contains information about a getChat request.
type GetChatCfg struct {
	BaseChat
}

// Name returns method name
func (cfg GetChatCfg) Name() string {
	return getChatMethod
}

// Values returns a url.Values representation of GetChatCfg.
// Returns RequiredError if Chat is not set.
{'fraction_non_alphanumeric': 0.1025974025974026, 'fraction_numerical': 0.005194805194805195, 'mean_word_length': 3.8550420168067228, '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': '6974365', 'n_tokens_mistral': 742, 'n_tokens_neox': 712, 'n_words': 267}