repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
letsencrypt/boulder
metrics/scope.go
GaugeDelta
func (s *promScope) GaugeDelta(stat string, value int64) { s.autoGauge(s.statName(stat)).Add(float64(value)) }
go
func (s *promScope) GaugeDelta(stat string, value int64) { s.autoGauge(s.statName(stat)).Add(float64(value)) }
[ "func", "(", "s", "*", "promScope", ")", "GaugeDelta", "(", "stat", "string", ",", "value", "int64", ")", "{", "s", ".", "autoGauge", "(", "s", ".", "statName", "(", "stat", ")", ")", ".", "Add", "(", "float64", "(", "value", ")", ")", "\n", "}" ]
// GaugeDelta sends the change in a gauge stat and adds the Scope's prefix to the name
[ "GaugeDelta", "sends", "the", "change", "in", "a", "gauge", "stat", "and", "adds", "the", "Scope", "s", "prefix", "to", "the", "name" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/metrics/scope.go#L72-L74
train
letsencrypt/boulder
metrics/scope.go
Timing
func (s *promScope) Timing(stat string, delta int64) { s.autoSummary(s.statName(stat) + "_seconds").Observe(float64(delta)) }
go
func (s *promScope) Timing(stat string, delta int64) { s.autoSummary(s.statName(stat) + "_seconds").Observe(float64(delta)) }
[ "func", "(", "s", "*", "promScope", ")", "Timing", "(", "stat", "string", ",", "delta", "int64", ")", "{", "s", ".", "autoSummary", "(", "s", ".", "statName", "(", "stat", ")", "+", "\"_seconds\"", ")", ".", "Observe", "(", "float64", "(", "delta", ")", ")", "\n", "}" ]
// Timing sends a latency stat and adds the Scope's prefix to the name
[ "Timing", "sends", "a", "latency", "stat", "and", "adds", "the", "Scope", "s", "prefix", "to", "the", "name" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/metrics/scope.go#L77-L79
train
letsencrypt/boulder
metrics/scope.go
TimingDuration
func (s *promScope) TimingDuration(stat string, delta time.Duration) { s.autoSummary(s.statName(stat) + "_seconds").Observe(delta.Seconds()) }
go
func (s *promScope) TimingDuration(stat string, delta time.Duration) { s.autoSummary(s.statName(stat) + "_seconds").Observe(delta.Seconds()) }
[ "func", "(", "s", "*", "promScope", ")", "TimingDuration", "(", "stat", "string", ",", "delta", "time", ".", "Duration", ")", "{", "s", ".", "autoSummary", "(", "s", ".", "statName", "(", "stat", ")", "+", "\"_seconds\"", ")", ".", "Observe", "(", "delta", ".", "Seconds", "(", ")", ")", "\n", "}" ]
// TimingDuration sends a latency stat as a time.Duration and adds the Scope's // prefix to the name
[ "TimingDuration", "sends", "a", "latency", "stat", "as", "a", "time", ".", "Duration", "and", "adds", "the", "Scope", "s", "prefix", "to", "the", "name" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/metrics/scope.go#L83-L85
train
letsencrypt/boulder
metrics/scope.go
SetInt
func (s *promScope) SetInt(stat string, value int64) { s.autoGauge(s.statName(stat)).Set(float64(value)) }
go
func (s *promScope) SetInt(stat string, value int64) { s.autoGauge(s.statName(stat)).Set(float64(value)) }
[ "func", "(", "s", "*", "promScope", ")", "SetInt", "(", "stat", "string", ",", "value", "int64", ")", "{", "s", ".", "autoGauge", "(", "s", ".", "statName", "(", "stat", ")", ")", ".", "Set", "(", "float64", "(", "value", ")", ")", "\n", "}" ]
// SetInt sets a stat's integer value and adds the Scope's prefix to the name
[ "SetInt", "sets", "a", "stat", "s", "integer", "value", "and", "adds", "the", "Scope", "s", "prefix", "to", "the", "name" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/metrics/scope.go#L88-L90
train
letsencrypt/boulder
metrics/scope.go
statName
func (s *promScope) statName(stat string) string { if len(s.prefix) > 0 { return strings.Join(s.prefix, "_") + "_" + stat } return stat }
go
func (s *promScope) statName(stat string) string { if len(s.prefix) > 0 { return strings.Join(s.prefix, "_") + "_" + stat } return stat }
[ "func", "(", "s", "*", "promScope", ")", "statName", "(", "stat", "string", ")", "string", "{", "if", "len", "(", "s", ".", "prefix", ")", ">", "0", "{", "return", "strings", ".", "Join", "(", "s", ".", "prefix", ",", "\"_\"", ")", "+", "\"_\"", "+", "stat", "\n", "}", "\n", "return", "stat", "\n", "}" ]
// statName construct a name for a stat based on the prefix of this scope, plus // the provided string.
[ "statName", "construct", "a", "name", "for", "a", "stat", "based", "on", "the", "prefix", "of", "this", "scope", "plus", "the", "provided", "string", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/metrics/scope.go#L94-L99
train
letsencrypt/boulder
akamai/cache-client.go
NewCachePurgeClient
func NewCachePurgeClient( endpoint, clientToken, clientSecret, accessToken string, v3Network string, retries int, retryBackoff time.Duration, log blog.Logger, stats metrics.Scope, ) (*CachePurgeClient, error) { stats = stats.NewScope("CCU") if strings.HasSuffix(endpoint, "/") { endpoint = endpoint[:len(endpoint)-1] } apiURL, err := url.Parse(endpoint) if err != nil { return nil, err } // The network string must be either "production" or "staging". if v3Network != "production" && v3Network != "staging" { return nil, fmt.Errorf( "Invalid CCU v3 network: %q. Must be \"staging\" or \"production\"", v3Network) } return &CachePurgeClient{ client: new(http.Client), apiEndpoint: endpoint, apiHost: apiURL.Host, apiScheme: strings.ToLower(apiURL.Scheme), clientToken: clientToken, clientSecret: clientSecret, accessToken: accessToken, v3Network: v3Network, retries: retries, retryBackoff: retryBackoff, log: log, stats: stats, clk: clock.Default(), }, nil }
go
func NewCachePurgeClient( endpoint, clientToken, clientSecret, accessToken string, v3Network string, retries int, retryBackoff time.Duration, log blog.Logger, stats metrics.Scope, ) (*CachePurgeClient, error) { stats = stats.NewScope("CCU") if strings.HasSuffix(endpoint, "/") { endpoint = endpoint[:len(endpoint)-1] } apiURL, err := url.Parse(endpoint) if err != nil { return nil, err } // The network string must be either "production" or "staging". if v3Network != "production" && v3Network != "staging" { return nil, fmt.Errorf( "Invalid CCU v3 network: %q. Must be \"staging\" or \"production\"", v3Network) } return &CachePurgeClient{ client: new(http.Client), apiEndpoint: endpoint, apiHost: apiURL.Host, apiScheme: strings.ToLower(apiURL.Scheme), clientToken: clientToken, clientSecret: clientSecret, accessToken: accessToken, v3Network: v3Network, retries: retries, retryBackoff: retryBackoff, log: log, stats: stats, clk: clock.Default(), }, nil }
[ "func", "NewCachePurgeClient", "(", "endpoint", ",", "clientToken", ",", "clientSecret", ",", "accessToken", "string", ",", "v3Network", "string", ",", "retries", "int", ",", "retryBackoff", "time", ".", "Duration", ",", "log", "blog", ".", "Logger", ",", "stats", "metrics", ".", "Scope", ",", ")", "(", "*", "CachePurgeClient", ",", "error", ")", "{", "stats", "=", "stats", ".", "NewScope", "(", "\"CCU\"", ")", "\n", "if", "strings", ".", "HasSuffix", "(", "endpoint", ",", "\"/\"", ")", "{", "endpoint", "=", "endpoint", "[", ":", "len", "(", "endpoint", ")", "-", "1", "]", "\n", "}", "\n", "apiURL", ",", "err", ":=", "url", ".", "Parse", "(", "endpoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "v3Network", "!=", "\"production\"", "&&", "v3Network", "!=", "\"staging\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"Invalid CCU v3 network: %q. Must be \\\"staging\\\" or \\\"production\\\"\"", ",", "\\\"", ")", "\n", "}", "\n", "\\\"", "\n", "}" ]
// NewCachePurgeClient constructs a new CachePurgeClient
[ "NewCachePurgeClient", "constructs", "a", "new", "CachePurgeClient" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/akamai/cache-client.go#L73-L112
train
letsencrypt/boulder
akamai/cache-client.go
signingKey
func signingKey(clientSecret string, timestamp string) []byte { h := hmac.New(sha256.New, []byte(clientSecret)) h.Write([]byte(timestamp)) key := make([]byte, base64.StdEncoding.EncodedLen(32)) base64.StdEncoding.Encode(key, h.Sum(nil)) return key }
go
func signingKey(clientSecret string, timestamp string) []byte { h := hmac.New(sha256.New, []byte(clientSecret)) h.Write([]byte(timestamp)) key := make([]byte, base64.StdEncoding.EncodedLen(32)) base64.StdEncoding.Encode(key, h.Sum(nil)) return key }
[ "func", "signingKey", "(", "clientSecret", "string", ",", "timestamp", "string", ")", "[", "]", "byte", "{", "h", ":=", "hmac", ".", "New", "(", "sha256", ".", "New", ",", "[", "]", "byte", "(", "clientSecret", ")", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "timestamp", ")", ")", "\n", "key", ":=", "make", "(", "[", "]", "byte", ",", "base64", ".", "StdEncoding", ".", "EncodedLen", "(", "32", ")", ")", "\n", "base64", ".", "StdEncoding", ".", "Encode", "(", "key", ",", "h", ".", "Sum", "(", "nil", ")", ")", "\n", "return", "key", "\n", "}" ]
// signingKey makes a signing key by HMAC'ing the timestamp // using a client secret as the key.
[ "signingKey", "makes", "a", "signing", "key", "by", "HMAC", "ing", "the", "timestamp", "using", "a", "client", "secret", "as", "the", "key", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/akamai/cache-client.go#L154-L160
train
letsencrypt/boulder
akamai/cache-client.go
purge
func (cpc *CachePurgeClient) purge(urls []string) error { purgeReq := v3PurgeRequest{ Objects: urls, } endpoint := fmt.Sprintf("%s%s%s", cpc.apiEndpoint, v3PurgePath, cpc.v3Network) reqJSON, err := json.Marshal(purgeReq) if err != nil { return errFatal(err.Error()) } req, err := http.NewRequest( "POST", endpoint, bytes.NewBuffer(reqJSON), ) if err != nil { return errFatal(err.Error()) } // Create authorization header for request authHeader, err := cpc.constructAuthHeader( reqJSON, v3PurgePath+cpc.v3Network, core.RandomString(16), ) if err != nil { return errFatal(err.Error()) } req.Header.Set("Authorization", authHeader) req.Header.Set("Content-Type", "application/json") cpc.log.Debugf("POSTing to %s with Authorization %s: %s", endpoint, authHeader, reqJSON) rS := cpc.clk.Now() resp, err := cpc.client.Do(req) cpc.stats.TimingDuration("PurgeRequestLatency", time.Since(rS)) if err != nil { return err } if resp.Body == nil { return fmt.Errorf("No response body") } body, err := ioutil.ReadAll(resp.Body) if err != nil { _ = resp.Body.Close() return err } err = resp.Body.Close() if err != nil { return err } // Check purge was successful var purgeInfo purgeResponse err = json.Unmarshal(body, &purgeInfo) if err != nil { return fmt.Errorf("%s. Body was: %s", err, body) } if purgeInfo.HTTPStatus != http.StatusCreated || resp.StatusCode != http.StatusCreated { if purgeInfo.HTTPStatus == http.StatusForbidden { return errFatal(fmt.Sprintf("Unauthorized to purge URLs %q", urls)) } return fmt.Errorf("Unexpected HTTP status code '%d': %s", resp.StatusCode, string(body)) } cpc.log.Infof("Sent successful purge request purgeID: %s, purge expected in: %ds, for URLs: %s", purgeInfo.PurgeID, purgeInfo.EstimatedSeconds, urls) return nil }
go
func (cpc *CachePurgeClient) purge(urls []string) error { purgeReq := v3PurgeRequest{ Objects: urls, } endpoint := fmt.Sprintf("%s%s%s", cpc.apiEndpoint, v3PurgePath, cpc.v3Network) reqJSON, err := json.Marshal(purgeReq) if err != nil { return errFatal(err.Error()) } req, err := http.NewRequest( "POST", endpoint, bytes.NewBuffer(reqJSON), ) if err != nil { return errFatal(err.Error()) } // Create authorization header for request authHeader, err := cpc.constructAuthHeader( reqJSON, v3PurgePath+cpc.v3Network, core.RandomString(16), ) if err != nil { return errFatal(err.Error()) } req.Header.Set("Authorization", authHeader) req.Header.Set("Content-Type", "application/json") cpc.log.Debugf("POSTing to %s with Authorization %s: %s", endpoint, authHeader, reqJSON) rS := cpc.clk.Now() resp, err := cpc.client.Do(req) cpc.stats.TimingDuration("PurgeRequestLatency", time.Since(rS)) if err != nil { return err } if resp.Body == nil { return fmt.Errorf("No response body") } body, err := ioutil.ReadAll(resp.Body) if err != nil { _ = resp.Body.Close() return err } err = resp.Body.Close() if err != nil { return err } // Check purge was successful var purgeInfo purgeResponse err = json.Unmarshal(body, &purgeInfo) if err != nil { return fmt.Errorf("%s. Body was: %s", err, body) } if purgeInfo.HTTPStatus != http.StatusCreated || resp.StatusCode != http.StatusCreated { if purgeInfo.HTTPStatus == http.StatusForbidden { return errFatal(fmt.Sprintf("Unauthorized to purge URLs %q", urls)) } return fmt.Errorf("Unexpected HTTP status code '%d': %s", resp.StatusCode, string(body)) } cpc.log.Infof("Sent successful purge request purgeID: %s, purge expected in: %ds, for URLs: %s", purgeInfo.PurgeID, purgeInfo.EstimatedSeconds, urls) return nil }
[ "func", "(", "cpc", "*", "CachePurgeClient", ")", "purge", "(", "urls", "[", "]", "string", ")", "error", "{", "purgeReq", ":=", "v3PurgeRequest", "{", "Objects", ":", "urls", ",", "}", "\n", "endpoint", ":=", "fmt", ".", "Sprintf", "(", "\"%s%s%s\"", ",", "cpc", ".", "apiEndpoint", ",", "v3PurgePath", ",", "cpc", ".", "v3Network", ")", "\n", "reqJSON", ",", "err", ":=", "json", ".", "Marshal", "(", "purgeReq", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errFatal", "(", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"POST\"", ",", "endpoint", ",", "bytes", ".", "NewBuffer", "(", "reqJSON", ")", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errFatal", "(", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "authHeader", ",", "err", ":=", "cpc", ".", "constructAuthHeader", "(", "reqJSON", ",", "v3PurgePath", "+", "cpc", ".", "v3Network", ",", "core", ".", "RandomString", "(", "16", ")", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errFatal", "(", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "req", ".", "Header", ".", "Set", "(", "\"Authorization\"", ",", "authHeader", ")", "\n", "req", ".", "Header", ".", "Set", "(", "\"Content-Type\"", ",", "\"application/json\"", ")", "\n", "cpc", ".", "log", ".", "Debugf", "(", "\"POSTing to %s with Authorization %s: %s\"", ",", "endpoint", ",", "authHeader", ",", "reqJSON", ")", "\n", "rS", ":=", "cpc", ".", "clk", ".", "Now", "(", ")", "\n", "resp", ",", "err", ":=", "cpc", ".", "client", ".", "Do", "(", "req", ")", "\n", "cpc", ".", "stats", ".", "TimingDuration", "(", "\"PurgeRequestLatency\"", ",", "time", ".", "Since", "(", "rS", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "resp", ".", "Body", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"No response body\"", ")", "\n", "}", "\n", "body", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "resp", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "_", "=", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "return", "err", "\n", "}", "\n", "err", "=", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "purgeInfo", "purgeResponse", "\n", "err", "=", "json", ".", "Unmarshal", "(", "body", ",", "&", "purgeInfo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"%s. Body was: %s\"", ",", "err", ",", "body", ")", "\n", "}", "\n", "if", "purgeInfo", ".", "HTTPStatus", "!=", "http", ".", "StatusCreated", "||", "resp", ".", "StatusCode", "!=", "http", ".", "StatusCreated", "{", "if", "purgeInfo", ".", "HTTPStatus", "==", "http", ".", "StatusForbidden", "{", "return", "errFatal", "(", "fmt", ".", "Sprintf", "(", "\"Unauthorized to purge URLs %q\"", ",", "urls", ")", ")", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"Unexpected HTTP status code '%d': %s\"", ",", "resp", ".", "StatusCode", ",", "string", "(", "body", ")", ")", "\n", "}", "\n", "cpc", ".", "log", ".", "Infof", "(", "\"Sent successful purge request purgeID: %s, purge expected in: %ds, for URLs: %s\"", ",", "purgeInfo", ".", "PurgeID", ",", "purgeInfo", ".", "EstimatedSeconds", ",", "urls", ")", "\n", "return", "nil", "\n", "}" ]
// purge actually sends the individual requests to the Akamai endpoint and checks // if they are successful
[ "purge", "actually", "sends", "the", "individual", "requests", "to", "the", "Akamai", "endpoint", "and", "checks", "if", "they", "are", "successful" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/akamai/cache-client.go#L164-L234
train
letsencrypt/boulder
akamai/cache-client.go
Purge
func (cpc *CachePurgeClient) Purge(urls []string) error { for i := 0; i < len(urls); { sliceEnd := i + akamaiBatchSize if sliceEnd > len(urls) { sliceEnd = len(urls) } err := cpc.purgeBatch(urls[i:sliceEnd]) if err != nil { return err } i += akamaiBatchSize } return nil }
go
func (cpc *CachePurgeClient) Purge(urls []string) error { for i := 0; i < len(urls); { sliceEnd := i + akamaiBatchSize if sliceEnd > len(urls) { sliceEnd = len(urls) } err := cpc.purgeBatch(urls[i:sliceEnd]) if err != nil { return err } i += akamaiBatchSize } return nil }
[ "func", "(", "cpc", "*", "CachePurgeClient", ")", "Purge", "(", "urls", "[", "]", "string", ")", "error", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "urls", ")", ";", "{", "sliceEnd", ":=", "i", "+", "akamaiBatchSize", "\n", "if", "sliceEnd", ">", "len", "(", "urls", ")", "{", "sliceEnd", "=", "len", "(", "urls", ")", "\n", "}", "\n", "err", ":=", "cpc", ".", "purgeBatch", "(", "urls", "[", "i", ":", "sliceEnd", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "i", "+=", "akamaiBatchSize", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Purge attempts to send a purge request to the Akamai CCU API cpc.retries number // of times before giving up and returning ErrAllRetriesFailed
[ "Purge", "attempts", "to", "send", "a", "purge", "request", "to", "the", "Akamai", "CCU", "API", "cpc", ".", "retries", "number", "of", "times", "before", "giving", "up", "and", "returning", "ErrAllRetriesFailed" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/akamai/cache-client.go#L268-L281
train
letsencrypt/boulder
akamai/cache-client.go
CheckSignature
func CheckSignature(secret string, url string, r *http.Request, body []byte) error { bodyHash := sha256.Sum256(body) bodyHashB64 := base64.StdEncoding.EncodeToString(bodyHash[:]) authorization := r.Header.Get("Authorization") authValues := make(map[string]string) for _, v := range strings.Split(authorization, ";") { splitValue := strings.Split(v, "=") authValues[splitValue[0]] = splitValue[1] } headerTimestamp := authValues["timestamp"] splitHeader := strings.Split(authorization, "signature=") shortenedHeader, signature := splitHeader[0], splitHeader[1] hostPort := strings.Split(url, "://")[1] h := hmac.New(sha256.New, signingKey(secret, headerTimestamp)) input := []byte(fmt.Sprintf("POST\thttp\t%s\t%s\t\t%s\t%s", hostPort, r.URL.Path, bodyHashB64, shortenedHeader, )) h.Write(input) expectedSignature := base64.StdEncoding.EncodeToString(h.Sum(nil)) if signature != expectedSignature { return fmt.Errorf("Wrong signature %q in %q. Expected %q\n", signature, authorization, expectedSignature) } return nil }
go
func CheckSignature(secret string, url string, r *http.Request, body []byte) error { bodyHash := sha256.Sum256(body) bodyHashB64 := base64.StdEncoding.EncodeToString(bodyHash[:]) authorization := r.Header.Get("Authorization") authValues := make(map[string]string) for _, v := range strings.Split(authorization, ";") { splitValue := strings.Split(v, "=") authValues[splitValue[0]] = splitValue[1] } headerTimestamp := authValues["timestamp"] splitHeader := strings.Split(authorization, "signature=") shortenedHeader, signature := splitHeader[0], splitHeader[1] hostPort := strings.Split(url, "://")[1] h := hmac.New(sha256.New, signingKey(secret, headerTimestamp)) input := []byte(fmt.Sprintf("POST\thttp\t%s\t%s\t\t%s\t%s", hostPort, r.URL.Path, bodyHashB64, shortenedHeader, )) h.Write(input) expectedSignature := base64.StdEncoding.EncodeToString(h.Sum(nil)) if signature != expectedSignature { return fmt.Errorf("Wrong signature %q in %q. Expected %q\n", signature, authorization, expectedSignature) } return nil }
[ "func", "CheckSignature", "(", "secret", "string", ",", "url", "string", ",", "r", "*", "http", ".", "Request", ",", "body", "[", "]", "byte", ")", "error", "{", "bodyHash", ":=", "sha256", ".", "Sum256", "(", "body", ")", "\n", "bodyHashB64", ":=", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "bodyHash", "[", ":", "]", ")", "\n", "authorization", ":=", "r", ".", "Header", ".", "Get", "(", "\"Authorization\"", ")", "\n", "authValues", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "_", ",", "v", ":=", "range", "strings", ".", "Split", "(", "authorization", ",", "\";\"", ")", "{", "splitValue", ":=", "strings", ".", "Split", "(", "v", ",", "\"=\"", ")", "\n", "authValues", "[", "splitValue", "[", "0", "]", "]", "=", "splitValue", "[", "1", "]", "\n", "}", "\n", "headerTimestamp", ":=", "authValues", "[", "\"timestamp\"", "]", "\n", "splitHeader", ":=", "strings", ".", "Split", "(", "authorization", ",", "\"signature=\"", ")", "\n", "shortenedHeader", ",", "signature", ":=", "splitHeader", "[", "0", "]", ",", "splitHeader", "[", "1", "]", "\n", "hostPort", ":=", "strings", ".", "Split", "(", "url", ",", "\"://\"", ")", "[", "1", "]", "\n", "h", ":=", "hmac", ".", "New", "(", "sha256", ".", "New", ",", "signingKey", "(", "secret", ",", "headerTimestamp", ")", ")", "\n", "input", ":=", "[", "]", "byte", "(", "fmt", ".", "Sprintf", "(", "\"POST\\thttp\\t%s\\t%s\\t\\t%s\\t%s\"", ",", "\\t", ",", "\\t", ",", "\\t", ",", "\\t", ",", ")", ")", "\n", "\\t", "\n", "\\t", "\n", "hostPort", "\n", "r", ".", "URL", ".", "Path", "\n", "}" ]
// CheckSignature is used for tests, it exported so that it can be used in akamai-test-srv
[ "CheckSignature", "is", "used", "for", "tests", "it", "exported", "so", "that", "it", "can", "be", "used", "in", "akamai", "-", "test", "-", "srv" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/akamai/cache-client.go#L284-L312
train
letsencrypt/boulder
cmd/id-exporter/main.go
findIDs
func (c idExporter) findIDs() ([]id, error) { var idsList []id _, err := c.dbMap.Select( &idsList, `SELECT id FROM registrations WHERE contact != 'null' AND id IN ( SELECT registrationID FROM certificates WHERE expires >= :expireCutoff );`, map[string]interface{}{ "expireCutoff": c.clk.Now().Add(-c.grace), }) if err != nil { c.log.AuditErrf("Error finding IDs: %s", err) return nil, err } return idsList, nil }
go
func (c idExporter) findIDs() ([]id, error) { var idsList []id _, err := c.dbMap.Select( &idsList, `SELECT id FROM registrations WHERE contact != 'null' AND id IN ( SELECT registrationID FROM certificates WHERE expires >= :expireCutoff );`, map[string]interface{}{ "expireCutoff": c.clk.Now().Add(-c.grace), }) if err != nil { c.log.AuditErrf("Error finding IDs: %s", err) return nil, err } return idsList, nil }
[ "func", "(", "c", "idExporter", ")", "findIDs", "(", ")", "(", "[", "]", "id", ",", "error", ")", "{", "var", "idsList", "[", "]", "id", "\n", "_", ",", "err", ":=", "c", ".", "dbMap", ".", "Select", "(", "&", "idsList", ",", "`SELECT id\t\tFROM registrations\t\tWHERE contact != 'null' AND\t\t\tid IN (\t\t\t\tSELECT registrationID\t\t\t\tFROM certificates\t\t\t\tWHERE expires >= :expireCutoff\t\t\t);`", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"expireCutoff\"", ":", "c", ".", "clk", ".", "Now", "(", ")", ".", "Add", "(", "-", "c", ".", "grace", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "c", ".", "log", ".", "AuditErrf", "(", "\"Error finding IDs: %s\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "idsList", ",", "nil", "\n", "}" ]
// Find all registration IDs with unexpired certificates.
[ "Find", "all", "registration", "IDs", "with", "unexpired", "certificates", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/cmd/id-exporter/main.go#L34-L55
train
letsencrypt/boulder
cmd/id-exporter/main.go
writeIDs
func writeIDs(idsList []id, outfile string) error { data, err := json.Marshal(idsList) if err != nil { return err } data = append(data, '\n') if outfile != "" { return ioutil.WriteFile(outfile, data, 0644) } fmt.Printf("%s", data) return nil }
go
func writeIDs(idsList []id, outfile string) error { data, err := json.Marshal(idsList) if err != nil { return err } data = append(data, '\n') if outfile != "" { return ioutil.WriteFile(outfile, data, 0644) } fmt.Printf("%s", data) return nil }
[ "func", "writeIDs", "(", "idsList", "[", "]", "id", ",", "outfile", "string", ")", "error", "{", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "idsList", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "data", "=", "append", "(", "data", ",", "'\\n'", ")", "\n", "if", "outfile", "!=", "\"\"", "{", "return", "ioutil", ".", "WriteFile", "(", "outfile", ",", "data", ",", "0644", ")", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"%s\"", ",", "data", ")", "\n", "return", "nil", "\n", "}" ]
// The `writeIDs` function produces a file containing JSON serialized // contact objects
[ "The", "writeIDs", "function", "produces", "a", "file", "containing", "JSON", "serialized", "contact", "objects" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/cmd/id-exporter/main.go#L89-L102
train
letsencrypt/boulder
grpc/creds/creds.go
ClientHandshake
func (tc *clientTransportCredentials) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { var err error host := tc.hostOverride if host == "" { // IMPORTANT: Don't wrap the errors returned from this method. gRPC expects to be // able to check err.Temporary to spot temporary errors and reconnect when they happen. host, _, err = net.SplitHostPort(addr) if err != nil { return nil, nil, err } } conn := tls.Client(rawConn, &tls.Config{ ServerName: host, RootCAs: tc.roots, Certificates: tc.clients, MinVersion: tls.VersionTLS12, // Override default of tls.VersionTLS10 MaxVersion: tls.VersionTLS12, // Same as default in golang <= 1.6 }) errChan := make(chan error, 1) go func() { errChan <- conn.Handshake() }() select { case <-ctx.Done(): return nil, nil, ctx.Err() case err := <-errChan: if err != nil { _ = rawConn.Close() return nil, nil, err } return conn, nil, nil } }
go
func (tc *clientTransportCredentials) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { var err error host := tc.hostOverride if host == "" { // IMPORTANT: Don't wrap the errors returned from this method. gRPC expects to be // able to check err.Temporary to spot temporary errors and reconnect when they happen. host, _, err = net.SplitHostPort(addr) if err != nil { return nil, nil, err } } conn := tls.Client(rawConn, &tls.Config{ ServerName: host, RootCAs: tc.roots, Certificates: tc.clients, MinVersion: tls.VersionTLS12, // Override default of tls.VersionTLS10 MaxVersion: tls.VersionTLS12, // Same as default in golang <= 1.6 }) errChan := make(chan error, 1) go func() { errChan <- conn.Handshake() }() select { case <-ctx.Done(): return nil, nil, ctx.Err() case err := <-errChan: if err != nil { _ = rawConn.Close() return nil, nil, err } return conn, nil, nil } }
[ "func", "(", "tc", "*", "clientTransportCredentials", ")", "ClientHandshake", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ",", "rawConn", "net", ".", "Conn", ")", "(", "net", ".", "Conn", ",", "credentials", ".", "AuthInfo", ",", "error", ")", "{", "var", "err", "error", "\n", "host", ":=", "tc", ".", "hostOverride", "\n", "if", "host", "==", "\"\"", "{", "host", ",", "_", ",", "err", "=", "net", ".", "SplitHostPort", "(", "addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "conn", ":=", "tls", ".", "Client", "(", "rawConn", ",", "&", "tls", ".", "Config", "{", "ServerName", ":", "host", ",", "RootCAs", ":", "tc", ".", "roots", ",", "Certificates", ":", "tc", ".", "clients", ",", "MinVersion", ":", "tls", ".", "VersionTLS12", ",", "MaxVersion", ":", "tls", ".", "VersionTLS12", ",", "}", ")", "\n", "errChan", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n", "go", "func", "(", ")", "{", "errChan", "<-", "conn", ".", "Handshake", "(", ")", "\n", "}", "(", ")", "\n", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "nil", ",", "nil", ",", "ctx", ".", "Err", "(", ")", "\n", "case", "err", ":=", "<-", "errChan", ":", "if", "err", "!=", "nil", "{", "_", "=", "rawConn", ".", "Close", "(", ")", "\n", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "conn", ",", "nil", ",", "nil", "\n", "}", "\n", "}" ]
// ClientHandshake does the authentication handshake specified by the corresponding // authentication protocol on rawConn for clients. It returns the authenticated // connection and the corresponding auth information about the connection. // Implementations must use the provided context to implement timely cancellation.
[ "ClientHandshake", "does", "the", "authentication", "handshake", "specified", "by", "the", "corresponding", "authentication", "protocol", "on", "rawConn", "for", "clients", ".", "It", "returns", "the", "authenticated", "connection", "and", "the", "corresponding", "auth", "information", "about", "the", "connection", ".", "Implementations", "must", "use", "the", "provided", "context", "to", "implement", "timely", "cancellation", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/grpc/creds/creds.go#L57-L89
train
letsencrypt/boulder
grpc/creds/creds.go
ServerHandshake
func (tc *clientTransportCredentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { return nil, nil, ServerHandshakeNopErr }
go
func (tc *clientTransportCredentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { return nil, nil, ServerHandshakeNopErr }
[ "func", "(", "tc", "*", "clientTransportCredentials", ")", "ServerHandshake", "(", "rawConn", "net", ".", "Conn", ")", "(", "net", ".", "Conn", ",", "credentials", ".", "AuthInfo", ",", "error", ")", "{", "return", "nil", ",", "nil", ",", "ServerHandshakeNopErr", "\n", "}" ]
// ServerHandshake is not implemented for a `clientTransportCredentials`, use // a `serverTransportCredentials` if you require `ServerHandshake`.
[ "ServerHandshake", "is", "not", "implemented", "for", "a", "clientTransportCredentials", "use", "a", "serverTransportCredentials", "if", "you", "require", "ServerHandshake", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/grpc/creds/creds.go#L93-L95
train
letsencrypt/boulder
grpc/creds/creds.go
Clone
func (tc *clientTransportCredentials) Clone() credentials.TransportCredentials { return NewClientCredentials(tc.roots, tc.clients, tc.hostOverride) }
go
func (tc *clientTransportCredentials) Clone() credentials.TransportCredentials { return NewClientCredentials(tc.roots, tc.clients, tc.hostOverride) }
[ "func", "(", "tc", "*", "clientTransportCredentials", ")", "Clone", "(", ")", "credentials", ".", "TransportCredentials", "{", "return", "NewClientCredentials", "(", "tc", ".", "roots", ",", "tc", ".", "clients", ",", "tc", ".", "hostOverride", ")", "\n", "}" ]
// Clone returns a copy of the clientTransportCredentials
[ "Clone", "returns", "a", "copy", "of", "the", "clientTransportCredentials" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/grpc/creds/creds.go#L116-L118
train
letsencrypt/boulder
grpc/creds/creds.go
ServerHandshake
func (tc *serverTransportCredentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { // Perform the server <- client TLS handshake. This will validate the peer's // client certificate. conn := tls.Server(rawConn, tc.serverConfig) if err := conn.Handshake(); err != nil { return nil, nil, err } // In addition to the validation from `conn.Handshake()` we apply further // constraints on what constitutes a valid peer if err := tc.validateClient(conn.ConnectionState()); err != nil { return nil, nil, err } return conn, credentials.TLSInfo{State: conn.ConnectionState()}, nil }
go
func (tc *serverTransportCredentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { // Perform the server <- client TLS handshake. This will validate the peer's // client certificate. conn := tls.Server(rawConn, tc.serverConfig) if err := conn.Handshake(); err != nil { return nil, nil, err } // In addition to the validation from `conn.Handshake()` we apply further // constraints on what constitutes a valid peer if err := tc.validateClient(conn.ConnectionState()); err != nil { return nil, nil, err } return conn, credentials.TLSInfo{State: conn.ConnectionState()}, nil }
[ "func", "(", "tc", "*", "serverTransportCredentials", ")", "ServerHandshake", "(", "rawConn", "net", ".", "Conn", ")", "(", "net", ".", "Conn", ",", "credentials", ".", "AuthInfo", ",", "error", ")", "{", "conn", ":=", "tls", ".", "Server", "(", "rawConn", ",", "tc", ".", "serverConfig", ")", "\n", "if", "err", ":=", "conn", ".", "Handshake", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "if", "err", ":=", "tc", ".", "validateClient", "(", "conn", ".", "ConnectionState", "(", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "conn", ",", "credentials", ".", "TLSInfo", "{", "State", ":", "conn", ".", "ConnectionState", "(", ")", "}", ",", "nil", "\n", "}" ]
// ServerHandshake does the authentication handshake for servers. It returns // the authenticated connection and the corresponding auth information about // the connection.
[ "ServerHandshake", "does", "the", "authentication", "handshake", "for", "servers", ".", "It", "returns", "the", "authenticated", "connection", "and", "the", "corresponding", "auth", "information", "about", "the", "connection", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/grpc/creds/creds.go#L205-L220
train
letsencrypt/boulder
grpc/creds/creds.go
ClientHandshake
func (tc *serverTransportCredentials) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { return nil, nil, ClientHandshakeNopErr }
go
func (tc *serverTransportCredentials) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { return nil, nil, ClientHandshakeNopErr }
[ "func", "(", "tc", "*", "serverTransportCredentials", ")", "ClientHandshake", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ",", "rawConn", "net", ".", "Conn", ")", "(", "net", ".", "Conn", ",", "credentials", ".", "AuthInfo", ",", "error", ")", "{", "return", "nil", ",", "nil", ",", "ClientHandshakeNopErr", "\n", "}" ]
// ClientHandshake is not implemented for a `serverTransportCredentials`, use // a `clientTransportCredentials` if you require `ClientHandshake`.
[ "ClientHandshake", "is", "not", "implemented", "for", "a", "serverTransportCredentials", "use", "a", "clientTransportCredentials", "if", "you", "require", "ClientHandshake", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/grpc/creds/creds.go#L224-L226
train
letsencrypt/boulder
grpc/creds/creds.go
GetRequestMetadata
func (tc *serverTransportCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return nil, nil }
go
func (tc *serverTransportCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return nil, nil }
[ "func", "(", "tc", "*", "serverTransportCredentials", ")", "GetRequestMetadata", "(", "ctx", "context", ".", "Context", ",", "uri", "...", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "return", "nil", ",", "nil", "\n", "}" ]
// GetRequestMetadata returns nil, nil since TLS credentials do not have metadata.
[ "GetRequestMetadata", "returns", "nil", "nil", "since", "TLS", "credentials", "do", "not", "have", "metadata", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/grpc/creds/creds.go#L237-L239
train
letsencrypt/boulder
grpc/creds/creds.go
Clone
func (tc *serverTransportCredentials) Clone() credentials.TransportCredentials { clone, _ := NewServerCredentials(tc.serverConfig, tc.acceptedSANs) return clone }
go
func (tc *serverTransportCredentials) Clone() credentials.TransportCredentials { clone, _ := NewServerCredentials(tc.serverConfig, tc.acceptedSANs) return clone }
[ "func", "(", "tc", "*", "serverTransportCredentials", ")", "Clone", "(", ")", "credentials", ".", "TransportCredentials", "{", "clone", ",", "_", ":=", "NewServerCredentials", "(", "tc", ".", "serverConfig", ",", "tc", ".", "acceptedSANs", ")", "\n", "return", "clone", "\n", "}" ]
// Clone returns a copy of the serverTransportCredentials
[ "Clone", "returns", "a", "copy", "of", "the", "serverTransportCredentials" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/grpc/creds/creds.go#L247-L250
train
letsencrypt/boulder
core/objects.go
ValidChallenge
func ValidChallenge(name string) bool { switch name { case ChallengeTypeHTTP01, ChallengeTypeDNS01, ChallengeTypeTLSALPN01: return true default: return false } }
go
func ValidChallenge(name string) bool { switch name { case ChallengeTypeHTTP01, ChallengeTypeDNS01, ChallengeTypeTLSALPN01: return true default: return false } }
[ "func", "ValidChallenge", "(", "name", "string", ")", "bool", "{", "switch", "name", "{", "case", "ChallengeTypeHTTP01", ",", "ChallengeTypeDNS01", ",", "ChallengeTypeTLSALPN01", ":", "return", "true", "\n", "default", ":", "return", "false", "\n", "}", "\n", "}" ]
// ValidChallenge tests whether the provided string names a known challenge
[ "ValidChallenge", "tests", "whether", "the", "provided", "string", "names", "a", "known", "challenge" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L75-L84
train
letsencrypt/boulder
core/objects.go
UnmarshalJSON
func (cr *CertificateRequest) UnmarshalJSON(data []byte) error { var raw RawCertificateRequest if err := json.Unmarshal(data, &raw); err != nil { return err } csr, err := x509.ParseCertificateRequest(raw.CSR) if err != nil { return err } cr.CSR = csr cr.Bytes = raw.CSR return nil }
go
func (cr *CertificateRequest) UnmarshalJSON(data []byte) error { var raw RawCertificateRequest if err := json.Unmarshal(data, &raw); err != nil { return err } csr, err := x509.ParseCertificateRequest(raw.CSR) if err != nil { return err } cr.CSR = csr cr.Bytes = raw.CSR return nil }
[ "func", "(", "cr", "*", "CertificateRequest", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "raw", "RawCertificateRequest", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "raw", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "csr", ",", "err", ":=", "x509", ".", "ParseCertificateRequest", "(", "raw", ".", "CSR", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "cr", ".", "CSR", "=", "csr", "\n", "cr", ".", "Bytes", "=", "raw", ".", "CSR", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON provides an implementation for decoding CertificateRequest objects.
[ "UnmarshalJSON", "provides", "an", "implementation", "for", "decoding", "CertificateRequest", "objects", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L113-L127
train
letsencrypt/boulder
core/objects.go
MarshalJSON
func (cr CertificateRequest) MarshalJSON() ([]byte, error) { return json.Marshal(RawCertificateRequest{ CSR: cr.CSR.Raw, }) }
go
func (cr CertificateRequest) MarshalJSON() ([]byte, error) { return json.Marshal(RawCertificateRequest{ CSR: cr.CSR.Raw, }) }
[ "func", "(", "cr", "CertificateRequest", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "json", ".", "Marshal", "(", "RawCertificateRequest", "{", "CSR", ":", "cr", ".", "CSR", ".", "Raw", ",", "}", ")", "\n", "}" ]
// MarshalJSON provides an implementation for encoding CertificateRequest objects.
[ "MarshalJSON", "provides", "an", "implementation", "for", "encoding", "CertificateRequest", "objects", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L130-L134
train
letsencrypt/boulder
core/objects.go
ExpectedKeyAuthorization
func (ch Challenge) ExpectedKeyAuthorization(key *jose.JSONWebKey) (string, error) { if key == nil { return "", fmt.Errorf("Cannot authorize a nil key") } thumbprint, err := key.Thumbprint(crypto.SHA256) if err != nil { return "", err } return ch.Token + "." + base64.RawURLEncoding.EncodeToString(thumbprint), nil }
go
func (ch Challenge) ExpectedKeyAuthorization(key *jose.JSONWebKey) (string, error) { if key == nil { return "", fmt.Errorf("Cannot authorize a nil key") } thumbprint, err := key.Thumbprint(crypto.SHA256) if err != nil { return "", err } return ch.Token + "." + base64.RawURLEncoding.EncodeToString(thumbprint), nil }
[ "func", "(", "ch", "Challenge", ")", "ExpectedKeyAuthorization", "(", "key", "*", "jose", ".", "JSONWebKey", ")", "(", "string", ",", "error", ")", "{", "if", "key", "==", "nil", "{", "return", "\"\"", ",", "fmt", ".", "Errorf", "(", "\"Cannot authorize a nil key\"", ")", "\n", "}", "\n", "thumbprint", ",", "err", ":=", "key", ".", "Thumbprint", "(", "crypto", ".", "SHA256", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "err", "\n", "}", "\n", "return", "ch", ".", "Token", "+", "\".\"", "+", "base64", ".", "RawURLEncoding", ".", "EncodeToString", "(", "thumbprint", ")", ",", "nil", "\n", "}" ]
// ExpectedKeyAuthorization computes the expected KeyAuthorization value for // the challenge.
[ "ExpectedKeyAuthorization", "computes", "the", "expected", "KeyAuthorization", "value", "for", "the", "challenge", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L251-L262
train
letsencrypt/boulder
core/objects.go
RecordsSane
func (ch Challenge) RecordsSane() bool { if ch.ValidationRecord == nil || len(ch.ValidationRecord) == 0 { return false } switch ch.Type { case ChallengeTypeHTTP01: for _, rec := range ch.ValidationRecord { if rec.URL == "" || rec.Hostname == "" || rec.Port == "" || rec.AddressUsed == nil || len(rec.AddressesResolved) == 0 { return false } } case ChallengeTypeTLSALPN01: if len(ch.ValidationRecord) > 1 { return false } if ch.ValidationRecord[0].URL != "" { return false } if ch.ValidationRecord[0].Hostname == "" || ch.ValidationRecord[0].Port == "" || ch.ValidationRecord[0].AddressUsed == nil || len(ch.ValidationRecord[0].AddressesResolved) == 0 { return false } case ChallengeTypeDNS01: if len(ch.ValidationRecord) > 1 { return false } if ch.ValidationRecord[0].Hostname == "" { return false } return true default: // Unsupported challenge type return false } return true }
go
func (ch Challenge) RecordsSane() bool { if ch.ValidationRecord == nil || len(ch.ValidationRecord) == 0 { return false } switch ch.Type { case ChallengeTypeHTTP01: for _, rec := range ch.ValidationRecord { if rec.URL == "" || rec.Hostname == "" || rec.Port == "" || rec.AddressUsed == nil || len(rec.AddressesResolved) == 0 { return false } } case ChallengeTypeTLSALPN01: if len(ch.ValidationRecord) > 1 { return false } if ch.ValidationRecord[0].URL != "" { return false } if ch.ValidationRecord[0].Hostname == "" || ch.ValidationRecord[0].Port == "" || ch.ValidationRecord[0].AddressUsed == nil || len(ch.ValidationRecord[0].AddressesResolved) == 0 { return false } case ChallengeTypeDNS01: if len(ch.ValidationRecord) > 1 { return false } if ch.ValidationRecord[0].Hostname == "" { return false } return true default: // Unsupported challenge type return false } return true }
[ "func", "(", "ch", "Challenge", ")", "RecordsSane", "(", ")", "bool", "{", "if", "ch", ".", "ValidationRecord", "==", "nil", "||", "len", "(", "ch", ".", "ValidationRecord", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "switch", "ch", ".", "Type", "{", "case", "ChallengeTypeHTTP01", ":", "for", "_", ",", "rec", ":=", "range", "ch", ".", "ValidationRecord", "{", "if", "rec", ".", "URL", "==", "\"\"", "||", "rec", ".", "Hostname", "==", "\"\"", "||", "rec", ".", "Port", "==", "\"\"", "||", "rec", ".", "AddressUsed", "==", "nil", "||", "len", "(", "rec", ".", "AddressesResolved", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "}", "\n", "case", "ChallengeTypeTLSALPN01", ":", "if", "len", "(", "ch", ".", "ValidationRecord", ")", ">", "1", "{", "return", "false", "\n", "}", "\n", "if", "ch", ".", "ValidationRecord", "[", "0", "]", ".", "URL", "!=", "\"\"", "{", "return", "false", "\n", "}", "\n", "if", "ch", ".", "ValidationRecord", "[", "0", "]", ".", "Hostname", "==", "\"\"", "||", "ch", ".", "ValidationRecord", "[", "0", "]", ".", "Port", "==", "\"\"", "||", "ch", ".", "ValidationRecord", "[", "0", "]", ".", "AddressUsed", "==", "nil", "||", "len", "(", "ch", ".", "ValidationRecord", "[", "0", "]", ".", "AddressesResolved", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "case", "ChallengeTypeDNS01", ":", "if", "len", "(", "ch", ".", "ValidationRecord", ")", ">", "1", "{", "return", "false", "\n", "}", "\n", "if", "ch", ".", "ValidationRecord", "[", "0", "]", ".", "Hostname", "==", "\"\"", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "default", ":", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// RecordsSane checks the sanity of a ValidationRecord object before sending it // back to the RA to be stored.
[ "RecordsSane", "checks", "the", "sanity", "of", "a", "ValidationRecord", "object", "before", "sending", "it", "back", "to", "the", "RA", "to", "be", "stored", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L266-L303
train
letsencrypt/boulder
core/objects.go
CheckConsistencyForClientOffer
func (ch Challenge) CheckConsistencyForClientOffer() error { if err := ch.checkConsistency(); err != nil { return err } // Before completion, the key authorization field should be empty if ch.ProvidedKeyAuthorization != "" { return fmt.Errorf("A response to this challenge was already submitted.") } return nil }
go
func (ch Challenge) CheckConsistencyForClientOffer() error { if err := ch.checkConsistency(); err != nil { return err } // Before completion, the key authorization field should be empty if ch.ProvidedKeyAuthorization != "" { return fmt.Errorf("A response to this challenge was already submitted.") } return nil }
[ "func", "(", "ch", "Challenge", ")", "CheckConsistencyForClientOffer", "(", ")", "error", "{", "if", "err", ":=", "ch", ".", "checkConsistency", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "ch", ".", "ProvidedKeyAuthorization", "!=", "\"\"", "{", "return", "fmt", ".", "Errorf", "(", "\"A response to this challenge was already submitted.\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// CheckConsistencyForClientOffer checks the fields of a challenge object before it is // given to the client.
[ "CheckConsistencyForClientOffer", "checks", "the", "fields", "of", "a", "challenge", "object", "before", "it", "is", "given", "to", "the", "client", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L307-L317
train
letsencrypt/boulder
core/objects.go
CheckConsistencyForValidation
func (ch Challenge) CheckConsistencyForValidation() error { if err := ch.checkConsistency(); err != nil { return err } // If the challenge is completed, then there should be a key authorization return looksLikeKeyAuthorization(ch.ProvidedKeyAuthorization) }
go
func (ch Challenge) CheckConsistencyForValidation() error { if err := ch.checkConsistency(); err != nil { return err } // If the challenge is completed, then there should be a key authorization return looksLikeKeyAuthorization(ch.ProvidedKeyAuthorization) }
[ "func", "(", "ch", "Challenge", ")", "CheckConsistencyForValidation", "(", ")", "error", "{", "if", "err", ":=", "ch", ".", "checkConsistency", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "looksLikeKeyAuthorization", "(", "ch", ".", "ProvidedKeyAuthorization", ")", "\n", "}" ]
// CheckConsistencyForValidation checks the fields of a challenge object before it is // given to the VA.
[ "CheckConsistencyForValidation", "checks", "the", "fields", "of", "a", "challenge", "object", "before", "it", "is", "given", "to", "the", "VA", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L321-L328
train
letsencrypt/boulder
core/objects.go
checkConsistency
func (ch Challenge) checkConsistency() error { if ch.Status != StatusPending { return fmt.Errorf("The challenge is not pending.") } // There always needs to be a token if !LooksLikeAToken(ch.Token) { return fmt.Errorf("The token is missing.") } return nil }
go
func (ch Challenge) checkConsistency() error { if ch.Status != StatusPending { return fmt.Errorf("The challenge is not pending.") } // There always needs to be a token if !LooksLikeAToken(ch.Token) { return fmt.Errorf("The token is missing.") } return nil }
[ "func", "(", "ch", "Challenge", ")", "checkConsistency", "(", ")", "error", "{", "if", "ch", ".", "Status", "!=", "StatusPending", "{", "return", "fmt", ".", "Errorf", "(", "\"The challenge is not pending.\"", ")", "\n", "}", "\n", "if", "!", "LooksLikeAToken", "(", "ch", ".", "Token", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"The token is missing.\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// checkConsistency checks the sanity of a challenge object before issued to the client.
[ "checkConsistency", "checks", "the", "sanity", "of", "a", "challenge", "object", "before", "issued", "to", "the", "client", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L331-L341
train
letsencrypt/boulder
core/objects.go
StringID
func (ch Challenge) StringID() string { h := fnv.New128a() h.Write([]byte(ch.Token)) h.Write([]byte(ch.Type)) return base64.URLEncoding.EncodeToString(h.Sum(nil)[0:4]) }
go
func (ch Challenge) StringID() string { h := fnv.New128a() h.Write([]byte(ch.Token)) h.Write([]byte(ch.Type)) return base64.URLEncoding.EncodeToString(h.Sum(nil)[0:4]) }
[ "func", "(", "ch", "Challenge", ")", "StringID", "(", ")", "string", "{", "h", ":=", "fnv", ".", "New128a", "(", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "ch", ".", "Token", ")", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "ch", ".", "Type", ")", ")", "\n", "return", "base64", ".", "URLEncoding", ".", "EncodeToString", "(", "h", ".", "Sum", "(", "nil", ")", "[", "0", ":", "4", "]", ")", "\n", "}" ]
// StringID is used to generate a ID for challenges associated with new style authorizations. // This is necessary as these challenges no longer have a unique non-sequential identifier // in the new storage scheme. This identifier is generated by constructing a fnv hash over the // challenge token and type and encoding the first 4 bytes of it using the base64 URL encoding.
[ "StringID", "is", "used", "to", "generate", "a", "ID", "for", "challenges", "associated", "with", "new", "style", "authorizations", ".", "This", "is", "necessary", "as", "these", "challenges", "no", "longer", "have", "a", "unique", "non", "-", "sequential", "identifier", "in", "the", "new", "storage", "scheme", ".", "This", "identifier", "is", "generated", "by", "constructing", "a", "fnv", "hash", "over", "the", "challenge", "token", "and", "type", "and", "encoding", "the", "first", "4", "bytes", "of", "it", "using", "the", "base64", "URL", "encoding", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L347-L352
train
letsencrypt/boulder
core/objects.go
FindChallenge
func (authz *Authorization) FindChallenge(challengeID int64) int { for i, c := range authz.Challenges { if c.ID == challengeID { return i } } return -1 }
go
func (authz *Authorization) FindChallenge(challengeID int64) int { for i, c := range authz.Challenges { if c.ID == challengeID { return i } } return -1 }
[ "func", "(", "authz", "*", "Authorization", ")", "FindChallenge", "(", "challengeID", "int64", ")", "int", "{", "for", "i", ",", "c", ":=", "range", "authz", ".", "Challenges", "{", "if", "c", ".", "ID", "==", "challengeID", "{", "return", "i", "\n", "}", "\n", "}", "\n", "return", "-", "1", "\n", "}" ]
// FindChallenge will look for the given challenge inside this authorization. If // found, it will return the index of that challenge within the Authorization's // Challenges array. Otherwise it will return -1.
[ "FindChallenge", "will", "look", "for", "the", "given", "challenge", "inside", "this", "authorization", ".", "If", "found", "it", "will", "return", "the", "index", "of", "that", "challenge", "within", "the", "Authorization", "s", "Challenges", "array", ".", "Otherwise", "it", "will", "return", "-", "1", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L407-L414
train
letsencrypt/boulder
core/objects.go
FindChallengeByStringID
func (authz *Authorization) FindChallengeByStringID(id string) int { for i, c := range authz.Challenges { if c.StringID() == id { return i } } return -1 }
go
func (authz *Authorization) FindChallengeByStringID(id string) int { for i, c := range authz.Challenges { if c.StringID() == id { return i } } return -1 }
[ "func", "(", "authz", "*", "Authorization", ")", "FindChallengeByStringID", "(", "id", "string", ")", "int", "{", "for", "i", ",", "c", ":=", "range", "authz", ".", "Challenges", "{", "if", "c", ".", "StringID", "(", ")", "==", "id", "{", "return", "i", "\n", "}", "\n", "}", "\n", "return", "-", "1", "\n", "}" ]
// FindChallengeByStringID will look for a challenge matching the given ID inside // this authorization. If found, it will return the index of that challenge within // the Authorization's Challenges array. Otherwise it will return -1.
[ "FindChallengeByStringID", "will", "look", "for", "a", "challenge", "matching", "the", "given", "ID", "inside", "this", "authorization", ".", "If", "found", "it", "will", "return", "the", "index", "of", "that", "challenge", "within", "the", "Authorization", "s", "Challenges", "array", ".", "Otherwise", "it", "will", "return", "-", "1", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L419-L426
train
letsencrypt/boulder
core/objects.go
base64URLEncode
func base64URLEncode(data []byte) string { var result = base64.URLEncoding.EncodeToString(data) return strings.TrimRight(result, "=") }
go
func base64URLEncode(data []byte) string { var result = base64.URLEncoding.EncodeToString(data) return strings.TrimRight(result, "=") }
[ "func", "base64URLEncode", "(", "data", "[", "]", "byte", ")", "string", "{", "var", "result", "=", "base64", ".", "URLEncoding", ".", "EncodeToString", "(", "data", ")", "\n", "return", "strings", ".", "TrimRight", "(", "result", ",", "\"=\"", ")", "\n", "}" ]
// URL-safe base64 encode that strips padding
[ "URL", "-", "safe", "base64", "encode", "that", "strips", "padding" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L448-L451
train
letsencrypt/boulder
core/objects.go
base64URLDecode
func base64URLDecode(data string) ([]byte, error) { var missing = (4 - len(data)%4) % 4 data += strings.Repeat("=", missing) return base64.URLEncoding.DecodeString(data) }
go
func base64URLDecode(data string) ([]byte, error) { var missing = (4 - len(data)%4) % 4 data += strings.Repeat("=", missing) return base64.URLEncoding.DecodeString(data) }
[ "func", "base64URLDecode", "(", "data", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "missing", "=", "(", "4", "-", "len", "(", "data", ")", "%", "4", ")", "%", "4", "\n", "data", "+=", "strings", ".", "Repeat", "(", "\"=\"", ",", "missing", ")", "\n", "return", "base64", ".", "URLEncoding", ".", "DecodeString", "(", "data", ")", "\n", "}" ]
// URL-safe base64 decoder that adds padding
[ "URL", "-", "safe", "base64", "decoder", "that", "adds", "padding" ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L454-L458
train
letsencrypt/boulder
core/objects.go
MarshalJSON
func (jb JSONBuffer) MarshalJSON() (result []byte, err error) { return json.Marshal(base64URLEncode(jb)) }
go
func (jb JSONBuffer) MarshalJSON() (result []byte, err error) { return json.Marshal(base64URLEncode(jb)) }
[ "func", "(", "jb", "JSONBuffer", ")", "MarshalJSON", "(", ")", "(", "result", "[", "]", "byte", ",", "err", "error", ")", "{", "return", "json", ".", "Marshal", "(", "base64URLEncode", "(", "jb", ")", ")", "\n", "}" ]
// MarshalJSON encodes a JSONBuffer for transmission.
[ "MarshalJSON", "encodes", "a", "JSONBuffer", "for", "transmission", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L461-L463
train
letsencrypt/boulder
core/objects.go
UnmarshalJSON
func (jb *JSONBuffer) UnmarshalJSON(data []byte) (err error) { var str string err = json.Unmarshal(data, &str) if err != nil { return err } *jb, err = base64URLDecode(str) return }
go
func (jb *JSONBuffer) UnmarshalJSON(data []byte) (err error) { var str string err = json.Unmarshal(data, &str) if err != nil { return err } *jb, err = base64URLDecode(str) return }
[ "func", "(", "jb", "*", "JSONBuffer", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "var", "str", "string", "\n", "err", "=", "json", ".", "Unmarshal", "(", "data", ",", "&", "str", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "*", "jb", ",", "err", "=", "base64URLDecode", "(", "str", ")", "\n", "return", "\n", "}" ]
// UnmarshalJSON decodes a JSONBuffer to an object.
[ "UnmarshalJSON", "decodes", "a", "JSONBuffer", "to", "an", "object", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/core/objects.go#L466-L474
train
letsencrypt/boulder
web/relative.go
RelativeEndpoint
func RelativeEndpoint(request *http.Request, endpoint string) string { var result string proto := "http" host := request.Host // If the request was received via TLS, use `https://` for the protocol if request.TLS != nil { proto = "https" } // Allow upstream proxies to specify the forwarded protocol. Allow this value // to override our own guess. if specifiedProto := request.Header.Get("X-Forwarded-Proto"); specifiedProto != "" { proto = specifiedProto } // Default to "localhost" when no request.Host is provided. Otherwise requests // with an empty `Host` produce results like `http:///acme/new-authz` if request.Host == "" { host = "localhost" } resultUrl := url.URL{Scheme: proto, Host: host, Path: endpoint} result = resultUrl.String() return result }
go
func RelativeEndpoint(request *http.Request, endpoint string) string { var result string proto := "http" host := request.Host // If the request was received via TLS, use `https://` for the protocol if request.TLS != nil { proto = "https" } // Allow upstream proxies to specify the forwarded protocol. Allow this value // to override our own guess. if specifiedProto := request.Header.Get("X-Forwarded-Proto"); specifiedProto != "" { proto = specifiedProto } // Default to "localhost" when no request.Host is provided. Otherwise requests // with an empty `Host` produce results like `http:///acme/new-authz` if request.Host == "" { host = "localhost" } resultUrl := url.URL{Scheme: proto, Host: host, Path: endpoint} result = resultUrl.String() return result }
[ "func", "RelativeEndpoint", "(", "request", "*", "http", ".", "Request", ",", "endpoint", "string", ")", "string", "{", "var", "result", "string", "\n", "proto", ":=", "\"http\"", "\n", "host", ":=", "request", ".", "Host", "\n", "if", "request", ".", "TLS", "!=", "nil", "{", "proto", "=", "\"https\"", "\n", "}", "\n", "if", "specifiedProto", ":=", "request", ".", "Header", ".", "Get", "(", "\"X-Forwarded-Proto\"", ")", ";", "specifiedProto", "!=", "\"\"", "{", "proto", "=", "specifiedProto", "\n", "}", "\n", "if", "request", ".", "Host", "==", "\"\"", "{", "host", "=", "\"localhost\"", "\n", "}", "\n", "resultUrl", ":=", "url", ".", "URL", "{", "Scheme", ":", "proto", ",", "Host", ":", "host", ",", "Path", ":", "endpoint", "}", "\n", "result", "=", "resultUrl", ".", "String", "(", ")", "\n", "return", "result", "\n", "}" ]
// RelativeEndpoint takes a path component of URL and constructs a new URL using // the host and port from the request combined the provided path.
[ "RelativeEndpoint", "takes", "a", "path", "component", "of", "URL", "and", "constructs", "a", "new", "URL", "using", "the", "host", "and", "port", "from", "the", "request", "combined", "the", "provided", "path", "." ]
a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf
https://github.com/letsencrypt/boulder/blob/a3d35f51ff716e0d4916ac2c8ce5b6df16a95baf/web/relative.go#L10-L36
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewMessage
func NewMessage(chatID int64, text string) MessageConfig { return MessageConfig{ BaseChat: BaseChat{ ChatID: chatID, ReplyToMessageID: 0, }, Text: text, DisableWebPagePreview: false, } }
go
func NewMessage(chatID int64, text string) MessageConfig { return MessageConfig{ BaseChat: BaseChat{ ChatID: chatID, ReplyToMessageID: 0, }, Text: text, DisableWebPagePreview: false, } }
[ "func", "NewMessage", "(", "chatID", "int64", ",", "text", "string", ")", "MessageConfig", "{", "return", "MessageConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", ",", "ReplyToMessageID", ":", "0", ",", "}", ",", "Text", ":", "text", ",", "DisableWebPagePreview", ":", "false", ",", "}", "\n", "}" ]
// NewMessage creates a new Message. // // chatID is where to send it, text is the message text.
[ "NewMessage", "creates", "a", "new", "Message", ".", "chatID", "is", "where", "to", "send", "it", "text", "is", "the", "message", "text", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L10-L19
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewDeleteMessage
func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig { return DeleteMessageConfig{ ChatID: chatID, MessageID: messageID, } }
go
func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig { return DeleteMessageConfig{ ChatID: chatID, MessageID: messageID, } }
[ "func", "NewDeleteMessage", "(", "chatID", "int64", ",", "messageID", "int", ")", "DeleteMessageConfig", "{", "return", "DeleteMessageConfig", "{", "ChatID", ":", "chatID", ",", "MessageID", ":", "messageID", ",", "}", "\n", "}" ]
// NewDeleteMessage creates a request to delete a message.
[ "NewDeleteMessage", "creates", "a", "request", "to", "delete", "a", "message", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L22-L27
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewMessageToChannel
func NewMessageToChannel(username string, text string) MessageConfig { return MessageConfig{ BaseChat: BaseChat{ ChannelUsername: username, }, Text: text, } }
go
func NewMessageToChannel(username string, text string) MessageConfig { return MessageConfig{ BaseChat: BaseChat{ ChannelUsername: username, }, Text: text, } }
[ "func", "NewMessageToChannel", "(", "username", "string", ",", "text", "string", ")", "MessageConfig", "{", "return", "MessageConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChannelUsername", ":", "username", ",", "}", ",", "Text", ":", "text", ",", "}", "\n", "}" ]
// NewMessageToChannel creates a new Message that is sent to a channel // by username. // // username is the username of the channel, text is the message text.
[ "NewMessageToChannel", "creates", "a", "new", "Message", "that", "is", "sent", "to", "a", "channel", "by", "username", ".", "username", "is", "the", "username", "of", "the", "channel", "text", "is", "the", "message", "text", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L33-L40
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewForward
func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig { return ForwardConfig{ BaseChat: BaseChat{ChatID: chatID}, FromChatID: fromChatID, MessageID: messageID, } }
go
func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig { return ForwardConfig{ BaseChat: BaseChat{ChatID: chatID}, FromChatID: fromChatID, MessageID: messageID, } }
[ "func", "NewForward", "(", "chatID", "int64", ",", "fromChatID", "int64", ",", "messageID", "int", ")", "ForwardConfig", "{", "return", "ForwardConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FromChatID", ":", "fromChatID", ",", "MessageID", ":", "messageID", ",", "}", "\n", "}" ]
// NewForward creates a new forward. // // chatID is where to send it, fromChatID is the source chat, // and messageID is the ID of the original message.
[ "NewForward", "creates", "a", "new", "forward", ".", "chatID", "is", "where", "to", "send", "it", "fromChatID", "is", "the", "source", "chat", "and", "messageID", "is", "the", "ID", "of", "the", "original", "message", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L46-L52
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewPhotoUpload
func NewPhotoUpload(chatID int64, file interface{}) PhotoConfig { return PhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
go
func NewPhotoUpload(chatID int64, file interface{}) PhotoConfig { return PhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
[ "func", "NewPhotoUpload", "(", "chatID", "int64", ",", "file", "interface", "{", "}", ")", "PhotoConfig", "{", "return", "PhotoConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "}", "\n", "}" ]
// NewPhotoUpload creates a new photo uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes. // // Note that you must send animated GIFs as a document.
[ "NewPhotoUpload", "creates", "a", "new", "photo", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", ".", "Note", "that", "you", "must", "send", "animated", "GIFs", "as", "a", "document", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L60-L68
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewPhotoShare
func NewPhotoShare(chatID int64, fileID string) PhotoConfig { return PhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
go
func NewPhotoShare(chatID int64, fileID string) PhotoConfig { return PhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
[ "func", "NewPhotoShare", "(", "chatID", "int64", ",", "fileID", "string", ")", "PhotoConfig", "{", "return", "PhotoConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "}", "\n", "}" ]
// NewPhotoShare shares an existing photo. // You may use this to reshare an existing photo without reuploading it. // // chatID is where to send it, fileID is the ID of the file // already uploaded.
[ "NewPhotoShare", "shares", "an", "existing", "photo", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "photo", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "file", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L75-L83
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewAudioUpload
func NewAudioUpload(chatID int64, file interface{}) AudioConfig { return AudioConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
go
func NewAudioUpload(chatID int64, file interface{}) AudioConfig { return AudioConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
[ "func", "NewAudioUpload", "(", "chatID", "int64", ",", "file", "interface", "{", "}", ")", "AudioConfig", "{", "return", "AudioConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "}", "\n", "}" ]
// NewAudioUpload creates a new audio uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes.
[ "NewAudioUpload", "creates", "a", "new", "audio", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L89-L97
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewAudioShare
func NewAudioShare(chatID int64, fileID string) AudioConfig { return AudioConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
go
func NewAudioShare(chatID int64, fileID string) AudioConfig { return AudioConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
[ "func", "NewAudioShare", "(", "chatID", "int64", ",", "fileID", "string", ")", "AudioConfig", "{", "return", "AudioConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "}", "\n", "}" ]
// NewAudioShare shares an existing audio file. // You may use this to reshare an existing audio file without // reuploading it. // // chatID is where to send it, fileID is the ID of the audio // already uploaded.
[ "NewAudioShare", "shares", "an", "existing", "audio", "file", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "audio", "file", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "audio", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L105-L113
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewDocumentUpload
func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig { return DocumentConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
go
func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig { return DocumentConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
[ "func", "NewDocumentUpload", "(", "chatID", "int64", ",", "file", "interface", "{", "}", ")", "DocumentConfig", "{", "return", "DocumentConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "}", "\n", "}" ]
// NewDocumentUpload creates a new document uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes.
[ "NewDocumentUpload", "creates", "a", "new", "document", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L119-L127
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewDocumentShare
func NewDocumentShare(chatID int64, fileID string) DocumentConfig { return DocumentConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
go
func NewDocumentShare(chatID int64, fileID string) DocumentConfig { return DocumentConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
[ "func", "NewDocumentShare", "(", "chatID", "int64", ",", "fileID", "string", ")", "DocumentConfig", "{", "return", "DocumentConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "}", "\n", "}" ]
// NewDocumentShare shares an existing document. // You may use this to reshare an existing document without // reuploading it. // // chatID is where to send it, fileID is the ID of the document // already uploaded.
[ "NewDocumentShare", "shares", "an", "existing", "document", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "document", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "document", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L135-L143
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewStickerUpload
func NewStickerUpload(chatID int64, file interface{}) StickerConfig { return StickerConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
go
func NewStickerUpload(chatID int64, file interface{}) StickerConfig { return StickerConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
[ "func", "NewStickerUpload", "(", "chatID", "int64", ",", "file", "interface", "{", "}", ")", "StickerConfig", "{", "return", "StickerConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "}", "\n", "}" ]
// NewStickerUpload creates a new sticker uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes.
[ "NewStickerUpload", "creates", "a", "new", "sticker", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L149-L157
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewStickerShare
func NewStickerShare(chatID int64, fileID string) StickerConfig { return StickerConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
go
func NewStickerShare(chatID int64, fileID string) StickerConfig { return StickerConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
[ "func", "NewStickerShare", "(", "chatID", "int64", ",", "fileID", "string", ")", "StickerConfig", "{", "return", "StickerConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "}", "\n", "}" ]
// NewStickerShare shares an existing sticker. // You may use this to reshare an existing sticker without // reuploading it. // // chatID is where to send it, fileID is the ID of the sticker // already uploaded.
[ "NewStickerShare", "shares", "an", "existing", "sticker", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "sticker", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "sticker", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L165-L173
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewVideoUpload
func NewVideoUpload(chatID int64, file interface{}) VideoConfig { return VideoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
go
func NewVideoUpload(chatID int64, file interface{}) VideoConfig { return VideoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
[ "func", "NewVideoUpload", "(", "chatID", "int64", ",", "file", "interface", "{", "}", ")", "VideoConfig", "{", "return", "VideoConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "}", "\n", "}" ]
// NewVideoUpload creates a new video uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes.
[ "NewVideoUpload", "creates", "a", "new", "video", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L179-L187
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewVideoShare
func NewVideoShare(chatID int64, fileID string) VideoConfig { return VideoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
go
func NewVideoShare(chatID int64, fileID string) VideoConfig { return VideoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
[ "func", "NewVideoShare", "(", "chatID", "int64", ",", "fileID", "string", ")", "VideoConfig", "{", "return", "VideoConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "}", "\n", "}" ]
// NewVideoShare shares an existing video. // You may use this to reshare an existing video without reuploading it. // // chatID is where to send it, fileID is the ID of the video // already uploaded.
[ "NewVideoShare", "shares", "an", "existing", "video", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "video", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "video", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L194-L202
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewAnimationUpload
func NewAnimationUpload(chatID int64, file interface{}) AnimationConfig { return AnimationConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
go
func NewAnimationUpload(chatID int64, file interface{}) AnimationConfig { return AnimationConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
[ "func", "NewAnimationUpload", "(", "chatID", "int64", ",", "file", "interface", "{", "}", ")", "AnimationConfig", "{", "return", "AnimationConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "}", "\n", "}" ]
// NewAnimationUpload creates a new animation uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes.
[ "NewAnimationUpload", "creates", "a", "new", "animation", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L208-L216
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewAnimationShare
func NewAnimationShare(chatID int64, fileID string) AnimationConfig { return AnimationConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
go
func NewAnimationShare(chatID int64, fileID string) AnimationConfig { return AnimationConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
[ "func", "NewAnimationShare", "(", "chatID", "int64", ",", "fileID", "string", ")", "AnimationConfig", "{", "return", "AnimationConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "}", "\n", "}" ]
// NewAnimationShare shares an existing animation. // You may use this to reshare an existing animation without reuploading it. // // chatID is where to send it, fileID is the ID of the animation // already uploaded.
[ "NewAnimationShare", "shares", "an", "existing", "animation", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "animation", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "animation", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L223-L231
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewVideoNoteUpload
func NewVideoNoteUpload(chatID int64, length int, file interface{}) VideoNoteConfig { return VideoNoteConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, Length: length, } }
go
func NewVideoNoteUpload(chatID int64, length int, file interface{}) VideoNoteConfig { return VideoNoteConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, Length: length, } }
[ "func", "NewVideoNoteUpload", "(", "chatID", "int64", ",", "length", "int", ",", "file", "interface", "{", "}", ")", "VideoNoteConfig", "{", "return", "VideoNoteConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "Length", ":", "length", ",", "}", "\n", "}" ]
// NewVideoNoteUpload creates a new video note uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes.
[ "NewVideoNoteUpload", "creates", "a", "new", "video", "note", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L237-L246
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewVideoNoteShare
func NewVideoNoteShare(chatID int64, length int, fileID string) VideoNoteConfig { return VideoNoteConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, Length: length, } }
go
func NewVideoNoteShare(chatID int64, length int, fileID string) VideoNoteConfig { return VideoNoteConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, Length: length, } }
[ "func", "NewVideoNoteShare", "(", "chatID", "int64", ",", "length", "int", ",", "fileID", "string", ")", "VideoNoteConfig", "{", "return", "VideoNoteConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "Length", ":", "length", ",", "}", "\n", "}" ]
// NewVideoNoteShare shares an existing video. // You may use this to reshare an existing video without reuploading it. // // chatID is where to send it, fileID is the ID of the video // already uploaded.
[ "NewVideoNoteShare", "shares", "an", "existing", "video", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "video", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "video", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L253-L262
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewVoiceUpload
func NewVoiceUpload(chatID int64, file interface{}) VoiceConfig { return VoiceConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
go
func NewVoiceUpload(chatID int64, file interface{}) VoiceConfig { return VoiceConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
[ "func", "NewVoiceUpload", "(", "chatID", "int64", ",", "file", "interface", "{", "}", ")", "VoiceConfig", "{", "return", "VoiceConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "}", "\n", "}" ]
// NewVoiceUpload creates a new voice uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes.
[ "NewVoiceUpload", "creates", "a", "new", "voice", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L268-L276
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewVoiceShare
func NewVoiceShare(chatID int64, fileID string) VoiceConfig { return VoiceConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
go
func NewVoiceShare(chatID int64, fileID string) VoiceConfig { return VoiceConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
[ "func", "NewVoiceShare", "(", "chatID", "int64", ",", "fileID", "string", ")", "VoiceConfig", "{", "return", "VoiceConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "}", "\n", "}" ]
// NewVoiceShare shares an existing voice. // You may use this to reshare an existing voice without reuploading it. // // chatID is where to send it, fileID is the ID of the video // already uploaded.
[ "NewVoiceShare", "shares", "an", "existing", "voice", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "voice", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "video", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L283-L291
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewMediaGroup
func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig { return MediaGroupConfig{ BaseChat: BaseChat{ ChatID: chatID, }, InputMedia: files, } }
go
func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig { return MediaGroupConfig{ BaseChat: BaseChat{ ChatID: chatID, }, InputMedia: files, } }
[ "func", "NewMediaGroup", "(", "chatID", "int64", ",", "files", "[", "]", "interface", "{", "}", ")", "MediaGroupConfig", "{", "return", "MediaGroupConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", ",", "}", ",", "InputMedia", ":", "files", ",", "}", "\n", "}" ]
// NewMediaGroup creates a new media group. Files should be an array of // two to ten InputMediaPhoto or InputMediaVideo.
[ "NewMediaGroup", "creates", "a", "new", "media", "group", ".", "Files", "should", "be", "an", "array", "of", "two", "to", "ten", "InputMediaPhoto", "or", "InputMediaVideo", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L295-L302
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewContact
func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig { return ContactConfig{ BaseChat: BaseChat{ ChatID: chatID, }, PhoneNumber: phoneNumber, FirstName: firstName, } }
go
func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig { return ContactConfig{ BaseChat: BaseChat{ ChatID: chatID, }, PhoneNumber: phoneNumber, FirstName: firstName, } }
[ "func", "NewContact", "(", "chatID", "int64", ",", "phoneNumber", ",", "firstName", "string", ")", "ContactConfig", "{", "return", "ContactConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", ",", "}", ",", "PhoneNumber", ":", "phoneNumber", ",", "FirstName", ":", "firstName", ",", "}", "\n", "}" ]
// NewContact allows you to send a shared contact.
[ "NewContact", "allows", "you", "to", "send", "a", "shared", "contact", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L321-L329
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewLocation
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig { return LocationConfig{ BaseChat: BaseChat{ ChatID: chatID, }, Latitude: latitude, Longitude: longitude, } }
go
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig { return LocationConfig{ BaseChat: BaseChat{ ChatID: chatID, }, Latitude: latitude, Longitude: longitude, } }
[ "func", "NewLocation", "(", "chatID", "int64", ",", "latitude", "float64", ",", "longitude", "float64", ")", "LocationConfig", "{", "return", "LocationConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", ",", "}", ",", "Latitude", ":", "latitude", ",", "Longitude", ":", "longitude", ",", "}", "\n", "}" ]
// NewLocation shares your location. // // chatID is where to send it, latitude and longitude are coordinates.
[ "NewLocation", "shares", "your", "location", ".", "chatID", "is", "where", "to", "send", "it", "latitude", "and", "longitude", "are", "coordinates", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L334-L342
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewVenue
func NewVenue(chatID int64, title, address string, latitude, longitude float64) VenueConfig { return VenueConfig{ BaseChat: BaseChat{ ChatID: chatID, }, Title: title, Address: address, Latitude: latitude, Longitude: longitude, } }
go
func NewVenue(chatID int64, title, address string, latitude, longitude float64) VenueConfig { return VenueConfig{ BaseChat: BaseChat{ ChatID: chatID, }, Title: title, Address: address, Latitude: latitude, Longitude: longitude, } }
[ "func", "NewVenue", "(", "chatID", "int64", ",", "title", ",", "address", "string", ",", "latitude", ",", "longitude", "float64", ")", "VenueConfig", "{", "return", "VenueConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", ",", "}", ",", "Title", ":", "title", ",", "Address", ":", "address", ",", "Latitude", ":", "latitude", ",", "Longitude", ":", "longitude", ",", "}", "\n", "}" ]
// NewVenue allows you to send a venue and its location.
[ "NewVenue", "allows", "you", "to", "send", "a", "venue", "and", "its", "location", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L345-L355
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewChatAction
func NewChatAction(chatID int64, action string) ChatActionConfig { return ChatActionConfig{ BaseChat: BaseChat{ChatID: chatID}, Action: action, } }
go
func NewChatAction(chatID int64, action string) ChatActionConfig { return ChatActionConfig{ BaseChat: BaseChat{ChatID: chatID}, Action: action, } }
[ "func", "NewChatAction", "(", "chatID", "int64", ",", "action", "string", ")", "ChatActionConfig", "{", "return", "ChatActionConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "Action", ":", "action", ",", "}", "\n", "}" ]
// NewChatAction sets a chat action. // Actions last for 5 seconds, or until your next action. // // chatID is where to send it, action should be set via Chat constants.
[ "NewChatAction", "sets", "a", "chat", "action", ".", "Actions", "last", "for", "5", "seconds", "or", "until", "your", "next", "action", ".", "chatID", "is", "where", "to", "send", "it", "action", "should", "be", "set", "via", "Chat", "constants", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L361-L366
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewWebhook
func NewWebhook(link string) WebhookConfig { u, _ := url.Parse(link) return WebhookConfig{ URL: u, } }
go
func NewWebhook(link string) WebhookConfig { u, _ := url.Parse(link) return WebhookConfig{ URL: u, } }
[ "func", "NewWebhook", "(", "link", "string", ")", "WebhookConfig", "{", "u", ",", "_", ":=", "url", ".", "Parse", "(", "link", ")", "\n", "return", "WebhookConfig", "{", "URL", ":", "u", ",", "}", "\n", "}" ]
// NewWebhook creates a new webhook. // // link is the url parsable link you wish to get the updates.
[ "NewWebhook", "creates", "a", "new", "webhook", ".", "link", "is", "the", "url", "parsable", "link", "you", "wish", "to", "get", "the", "updates", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L394-L400
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewWebhookWithCert
func NewWebhookWithCert(link string, file interface{}) WebhookConfig { u, _ := url.Parse(link) return WebhookConfig{ URL: u, Certificate: file, } }
go
func NewWebhookWithCert(link string, file interface{}) WebhookConfig { u, _ := url.Parse(link) return WebhookConfig{ URL: u, Certificate: file, } }
[ "func", "NewWebhookWithCert", "(", "link", "string", ",", "file", "interface", "{", "}", ")", "WebhookConfig", "{", "u", ",", "_", ":=", "url", ".", "Parse", "(", "link", ")", "\n", "return", "WebhookConfig", "{", "URL", ":", "u", ",", "Certificate", ":", "file", ",", "}", "\n", "}" ]
// NewWebhookWithCert creates a new webhook with a certificate. // // link is the url you wish to get webhooks, // file contains a string to a file, FileReader, or FileBytes.
[ "NewWebhookWithCert", "creates", "a", "new", "webhook", "with", "a", "certificate", ".", "link", "is", "the", "url", "you", "wish", "to", "get", "webhooks", "file", "contains", "a", "string", "to", "a", "file", "FileReader", "or", "FileBytes", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L406-L413
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultArticle
func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle { return InlineQueryResultArticle{ Type: "article", ID: id, Title: title, InputMessageContent: InputTextMessageContent{ Text: messageText, }, } }
go
func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle { return InlineQueryResultArticle{ Type: "article", ID: id, Title: title, InputMessageContent: InputTextMessageContent{ Text: messageText, }, } }
[ "func", "NewInlineQueryResultArticle", "(", "id", ",", "title", ",", "messageText", "string", ")", "InlineQueryResultArticle", "{", "return", "InlineQueryResultArticle", "{", "Type", ":", "\"article\"", ",", "ID", ":", "id", ",", "Title", ":", "title", ",", "InputMessageContent", ":", "InputTextMessageContent", "{", "Text", ":", "messageText", ",", "}", ",", "}", "\n", "}" ]
// NewInlineQueryResultArticle creates a new inline query article.
[ "NewInlineQueryResultArticle", "creates", "a", "new", "inline", "query", "article", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L416-L425
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultArticleMarkdown
func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQueryResultArticle { return InlineQueryResultArticle{ Type: "article", ID: id, Title: title, InputMessageContent: InputTextMessageContent{ Text: messageText, ParseMode: "Markdown", }, } }
go
func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQueryResultArticle { return InlineQueryResultArticle{ Type: "article", ID: id, Title: title, InputMessageContent: InputTextMessageContent{ Text: messageText, ParseMode: "Markdown", }, } }
[ "func", "NewInlineQueryResultArticleMarkdown", "(", "id", ",", "title", ",", "messageText", "string", ")", "InlineQueryResultArticle", "{", "return", "InlineQueryResultArticle", "{", "Type", ":", "\"article\"", ",", "ID", ":", "id", ",", "Title", ":", "title", ",", "InputMessageContent", ":", "InputTextMessageContent", "{", "Text", ":", "messageText", ",", "ParseMode", ":", "\"Markdown\"", ",", "}", ",", "}", "\n", "}" ]
// NewInlineQueryResultArticleMarkdown creates a new inline query article with Markdown parsing.
[ "NewInlineQueryResultArticleMarkdown", "creates", "a", "new", "inline", "query", "article", "with", "Markdown", "parsing", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L428-L438
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultGIF
func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF { return InlineQueryResultGIF{ Type: "gif", ID: id, URL: url, } }
go
func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF { return InlineQueryResultGIF{ Type: "gif", ID: id, URL: url, } }
[ "func", "NewInlineQueryResultGIF", "(", "id", ",", "url", "string", ")", "InlineQueryResultGIF", "{", "return", "InlineQueryResultGIF", "{", "Type", ":", "\"gif\"", ",", "ID", ":", "id", ",", "URL", ":", "url", ",", "}", "\n", "}" ]
// NewInlineQueryResultGIF creates a new inline query GIF.
[ "NewInlineQueryResultGIF", "creates", "a", "new", "inline", "query", "GIF", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L454-L460
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultCachedGIF
func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF { return InlineQueryResultCachedGIF{ Type: "gif", ID: id, GifID: gifID, } }
go
func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF { return InlineQueryResultCachedGIF{ Type: "gif", ID: id, GifID: gifID, } }
[ "func", "NewInlineQueryResultCachedGIF", "(", "id", ",", "gifID", "string", ")", "InlineQueryResultCachedGIF", "{", "return", "InlineQueryResultCachedGIF", "{", "Type", ":", "\"gif\"", ",", "ID", ":", "id", ",", "GifID", ":", "gifID", ",", "}", "\n", "}" ]
// NewInlineQueryResultCachedGIF create a new inline query with cached photo.
[ "NewInlineQueryResultCachedGIF", "create", "a", "new", "inline", "query", "with", "cached", "photo", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L463-L469
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultMPEG4GIF
func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF { return InlineQueryResultMPEG4GIF{ Type: "mpeg4_gif", ID: id, URL: url, } }
go
func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF { return InlineQueryResultMPEG4GIF{ Type: "mpeg4_gif", ID: id, URL: url, } }
[ "func", "NewInlineQueryResultMPEG4GIF", "(", "id", ",", "url", "string", ")", "InlineQueryResultMPEG4GIF", "{", "return", "InlineQueryResultMPEG4GIF", "{", "Type", ":", "\"mpeg4_gif\"", ",", "ID", ":", "id", ",", "URL", ":", "url", ",", "}", "\n", "}" ]
// NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
[ "NewInlineQueryResultMPEG4GIF", "creates", "a", "new", "inline", "query", "MPEG4", "GIF", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L472-L478
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultPhoto
func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto { return InlineQueryResultPhoto{ Type: "photo", ID: id, URL: url, } }
go
func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto { return InlineQueryResultPhoto{ Type: "photo", ID: id, URL: url, } }
[ "func", "NewInlineQueryResultPhoto", "(", "id", ",", "url", "string", ")", "InlineQueryResultPhoto", "{", "return", "InlineQueryResultPhoto", "{", "Type", ":", "\"photo\"", ",", "ID", ":", "id", ",", "URL", ":", "url", ",", "}", "\n", "}" ]
// NewInlineQueryResultPhoto creates a new inline query photo.
[ "NewInlineQueryResultPhoto", "creates", "a", "new", "inline", "query", "photo", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L490-L496
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultPhotoWithThumb
func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto { return InlineQueryResultPhoto{ Type: "photo", ID: id, URL: url, ThumbURL: thumb, } }
go
func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto { return InlineQueryResultPhoto{ Type: "photo", ID: id, URL: url, ThumbURL: thumb, } }
[ "func", "NewInlineQueryResultPhotoWithThumb", "(", "id", ",", "url", ",", "thumb", "string", ")", "InlineQueryResultPhoto", "{", "return", "InlineQueryResultPhoto", "{", "Type", ":", "\"photo\"", ",", "ID", ":", "id", ",", "URL", ":", "url", ",", "ThumbURL", ":", "thumb", ",", "}", "\n", "}" ]
// NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
[ "NewInlineQueryResultPhotoWithThumb", "creates", "a", "new", "inline", "query", "photo", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L499-L506
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultVideo
func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo { return InlineQueryResultVideo{ Type: "video", ID: id, URL: url, } }
go
func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo { return InlineQueryResultVideo{ Type: "video", ID: id, URL: url, } }
[ "func", "NewInlineQueryResultVideo", "(", "id", ",", "url", "string", ")", "InlineQueryResultVideo", "{", "return", "InlineQueryResultVideo", "{", "Type", ":", "\"video\"", ",", "ID", ":", "id", ",", "URL", ":", "url", ",", "}", "\n", "}" ]
// NewInlineQueryResultVideo creates a new inline query video.
[ "NewInlineQueryResultVideo", "creates", "a", "new", "inline", "query", "video", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L518-L524
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultCachedVideo
func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo { return InlineQueryResultCachedVideo{ Type: "video", ID: id, VideoID: videoID, Title: title, } }
go
func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo { return InlineQueryResultCachedVideo{ Type: "video", ID: id, VideoID: videoID, Title: title, } }
[ "func", "NewInlineQueryResultCachedVideo", "(", "id", ",", "videoID", ",", "title", "string", ")", "InlineQueryResultCachedVideo", "{", "return", "InlineQueryResultCachedVideo", "{", "Type", ":", "\"video\"", ",", "ID", ":", "id", ",", "VideoID", ":", "videoID", ",", "Title", ":", "title", ",", "}", "\n", "}" ]
// NewInlineQueryResultCachedVideo create a new inline query with cached video.
[ "NewInlineQueryResultCachedVideo", "create", "a", "new", "inline", "query", "with", "cached", "video", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L527-L534
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultAudio
func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio { return InlineQueryResultAudio{ Type: "audio", ID: id, URL: url, Title: title, } }
go
func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio { return InlineQueryResultAudio{ Type: "audio", ID: id, URL: url, Title: title, } }
[ "func", "NewInlineQueryResultAudio", "(", "id", ",", "url", ",", "title", "string", ")", "InlineQueryResultAudio", "{", "return", "InlineQueryResultAudio", "{", "Type", ":", "\"audio\"", ",", "ID", ":", "id", ",", "URL", ":", "url", ",", "Title", ":", "title", ",", "}", "\n", "}" ]
// NewInlineQueryResultAudio creates a new inline query audio.
[ "NewInlineQueryResultAudio", "creates", "a", "new", "inline", "query", "audio", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L537-L544
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultCachedAudio
func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio { return InlineQueryResultCachedAudio{ Type: "audio", ID: id, AudioID: audioID, } }
go
func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio { return InlineQueryResultCachedAudio{ Type: "audio", ID: id, AudioID: audioID, } }
[ "func", "NewInlineQueryResultCachedAudio", "(", "id", ",", "audioID", "string", ")", "InlineQueryResultCachedAudio", "{", "return", "InlineQueryResultCachedAudio", "{", "Type", ":", "\"audio\"", ",", "ID", ":", "id", ",", "AudioID", ":", "audioID", ",", "}", "\n", "}" ]
// NewInlineQueryResultCachedAudio create a new inline query with cached photo.
[ "NewInlineQueryResultCachedAudio", "create", "a", "new", "inline", "query", "with", "cached", "photo", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L547-L553
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultVoice
func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice { return InlineQueryResultVoice{ Type: "voice", ID: id, URL: url, Title: title, } }
go
func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice { return InlineQueryResultVoice{ Type: "voice", ID: id, URL: url, Title: title, } }
[ "func", "NewInlineQueryResultVoice", "(", "id", ",", "url", ",", "title", "string", ")", "InlineQueryResultVoice", "{", "return", "InlineQueryResultVoice", "{", "Type", ":", "\"voice\"", ",", "ID", ":", "id", ",", "URL", ":", "url", ",", "Title", ":", "title", ",", "}", "\n", "}" ]
// NewInlineQueryResultVoice creates a new inline query voice.
[ "NewInlineQueryResultVoice", "creates", "a", "new", "inline", "query", "voice", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L556-L563
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultCachedVoice
func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice { return InlineQueryResultCachedVoice{ Type: "voice", ID: id, VoiceID: voiceID, Title: title, } }
go
func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice { return InlineQueryResultCachedVoice{ Type: "voice", ID: id, VoiceID: voiceID, Title: title, } }
[ "func", "NewInlineQueryResultCachedVoice", "(", "id", ",", "voiceID", ",", "title", "string", ")", "InlineQueryResultCachedVoice", "{", "return", "InlineQueryResultCachedVoice", "{", "Type", ":", "\"voice\"", ",", "ID", ":", "id", ",", "VoiceID", ":", "voiceID", ",", "Title", ":", "title", ",", "}", "\n", "}" ]
// NewInlineQueryResultCachedVoice create a new inline query with cached photo.
[ "NewInlineQueryResultCachedVoice", "create", "a", "new", "inline", "query", "with", "cached", "photo", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L566-L573
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultDocument
func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument { return InlineQueryResultDocument{ Type: "document", ID: id, URL: url, Title: title, MimeType: mimeType, } }
go
func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument { return InlineQueryResultDocument{ Type: "document", ID: id, URL: url, Title: title, MimeType: mimeType, } }
[ "func", "NewInlineQueryResultDocument", "(", "id", ",", "url", ",", "title", ",", "mimeType", "string", ")", "InlineQueryResultDocument", "{", "return", "InlineQueryResultDocument", "{", "Type", ":", "\"document\"", ",", "ID", ":", "id", ",", "URL", ":", "url", ",", "Title", ":", "title", ",", "MimeType", ":", "mimeType", ",", "}", "\n", "}" ]
// NewInlineQueryResultDocument creates a new inline query document.
[ "NewInlineQueryResultDocument", "creates", "a", "new", "inline", "query", "document", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L576-L584
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultCachedDocument
func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument { return InlineQueryResultCachedDocument{ Type: "document", ID: id, DocumentID: documentID, Title: title, } }
go
func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument { return InlineQueryResultCachedDocument{ Type: "document", ID: id, DocumentID: documentID, Title: title, } }
[ "func", "NewInlineQueryResultCachedDocument", "(", "id", ",", "documentID", ",", "title", "string", ")", "InlineQueryResultCachedDocument", "{", "return", "InlineQueryResultCachedDocument", "{", "Type", ":", "\"document\"", ",", "ID", ":", "id", ",", "DocumentID", ":", "documentID", ",", "Title", ":", "title", ",", "}", "\n", "}" ]
// NewInlineQueryResultCachedDocument create a new inline query with cached photo.
[ "NewInlineQueryResultCachedDocument", "create", "a", "new", "inline", "query", "with", "cached", "photo", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L587-L594
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineQueryResultLocation
func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation { return InlineQueryResultLocation{ Type: "location", ID: id, Title: title, Latitude: latitude, Longitude: longitude, } }
go
func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation { return InlineQueryResultLocation{ Type: "location", ID: id, Title: title, Latitude: latitude, Longitude: longitude, } }
[ "func", "NewInlineQueryResultLocation", "(", "id", ",", "title", "string", ",", "latitude", ",", "longitude", "float64", ")", "InlineQueryResultLocation", "{", "return", "InlineQueryResultLocation", "{", "Type", ":", "\"location\"", ",", "ID", ":", "id", ",", "Title", ":", "title", ",", "Latitude", ":", "latitude", ",", "Longitude", ":", "longitude", ",", "}", "\n", "}" ]
// NewInlineQueryResultLocation creates a new inline query location.
[ "NewInlineQueryResultLocation", "creates", "a", "new", "inline", "query", "location", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L597-L605
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewEditMessageText
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig { return EditMessageTextConfig{ BaseEdit: BaseEdit{ ChatID: chatID, MessageID: messageID, }, Text: text, } }
go
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig { return EditMessageTextConfig{ BaseEdit: BaseEdit{ ChatID: chatID, MessageID: messageID, }, Text: text, } }
[ "func", "NewEditMessageText", "(", "chatID", "int64", ",", "messageID", "int", ",", "text", "string", ")", "EditMessageTextConfig", "{", "return", "EditMessageTextConfig", "{", "BaseEdit", ":", "BaseEdit", "{", "ChatID", ":", "chatID", ",", "MessageID", ":", "messageID", ",", "}", ",", "Text", ":", "text", ",", "}", "\n", "}" ]
// NewEditMessageText allows you to edit the text of a message.
[ "NewEditMessageText", "allows", "you", "to", "edit", "the", "text", "of", "a", "message", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L608-L616
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewEditMessageCaption
func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig { return EditMessageCaptionConfig{ BaseEdit: BaseEdit{ ChatID: chatID, MessageID: messageID, }, Caption: caption, } }
go
func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig { return EditMessageCaptionConfig{ BaseEdit: BaseEdit{ ChatID: chatID, MessageID: messageID, }, Caption: caption, } }
[ "func", "NewEditMessageCaption", "(", "chatID", "int64", ",", "messageID", "int", ",", "caption", "string", ")", "EditMessageCaptionConfig", "{", "return", "EditMessageCaptionConfig", "{", "BaseEdit", ":", "BaseEdit", "{", "ChatID", ":", "chatID", ",", "MessageID", ":", "messageID", ",", "}", ",", "Caption", ":", "caption", ",", "}", "\n", "}" ]
// NewEditMessageCaption allows you to edit the caption of a message.
[ "NewEditMessageCaption", "allows", "you", "to", "edit", "the", "caption", "of", "a", "message", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L619-L627
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewEditMessageReplyMarkup
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig { return EditMessageReplyMarkupConfig{ BaseEdit: BaseEdit{ ChatID: chatID, MessageID: messageID, ReplyMarkup: &replyMarkup, }, } }
go
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig { return EditMessageReplyMarkupConfig{ BaseEdit: BaseEdit{ ChatID: chatID, MessageID: messageID, ReplyMarkup: &replyMarkup, }, } }
[ "func", "NewEditMessageReplyMarkup", "(", "chatID", "int64", ",", "messageID", "int", ",", "replyMarkup", "InlineKeyboardMarkup", ")", "EditMessageReplyMarkupConfig", "{", "return", "EditMessageReplyMarkupConfig", "{", "BaseEdit", ":", "BaseEdit", "{", "ChatID", ":", "chatID", ",", "MessageID", ":", "messageID", ",", "ReplyMarkup", ":", "&", "replyMarkup", ",", "}", ",", "}", "\n", "}" ]
// NewEditMessageReplyMarkup allows you to edit the inline // keyboard markup.
[ "NewEditMessageReplyMarkup", "allows", "you", "to", "edit", "the", "inline", "keyboard", "markup", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L631-L639
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewHideKeyboard
func NewHideKeyboard(selective bool) ReplyKeyboardHide { log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard") return ReplyKeyboardHide{ HideKeyboard: true, Selective: selective, } }
go
func NewHideKeyboard(selective bool) ReplyKeyboardHide { log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard") return ReplyKeyboardHide{ HideKeyboard: true, Selective: selective, } }
[ "func", "NewHideKeyboard", "(", "selective", "bool", ")", "ReplyKeyboardHide", "{", "log", ".", "Println", "(", "\"NewHideKeyboard is deprecated, please use NewRemoveKeyboard\"", ")", "\n", "return", "ReplyKeyboardHide", "{", "HideKeyboard", ":", "true", ",", "Selective", ":", "selective", ",", "}", "\n", "}" ]
// NewHideKeyboard hides the keyboard, with the option for being selective // or hiding for everyone.
[ "NewHideKeyboard", "hides", "the", "keyboard", "with", "the", "option", "for", "being", "selective", "or", "hiding", "for", "everyone", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L643-L650
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewKeyboardButtonRow
func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton { var row []KeyboardButton row = append(row, buttons...) return row }
go
func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton { var row []KeyboardButton row = append(row, buttons...) return row }
[ "func", "NewKeyboardButtonRow", "(", "buttons", "...", "KeyboardButton", ")", "[", "]", "KeyboardButton", "{", "var", "row", "[", "]", "KeyboardButton", "\n", "row", "=", "append", "(", "row", ",", "buttons", "...", ")", "\n", "return", "row", "\n", "}" ]
// NewKeyboardButtonRow creates a row of keyboard buttons.
[ "NewKeyboardButtonRow", "creates", "a", "row", "of", "keyboard", "buttons", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L687-L693
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewReplyKeyboard
func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup { var keyboard [][]KeyboardButton keyboard = append(keyboard, rows...) return ReplyKeyboardMarkup{ ResizeKeyboard: true, Keyboard: keyboard, } }
go
func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup { var keyboard [][]KeyboardButton keyboard = append(keyboard, rows...) return ReplyKeyboardMarkup{ ResizeKeyboard: true, Keyboard: keyboard, } }
[ "func", "NewReplyKeyboard", "(", "rows", "...", "[", "]", "KeyboardButton", ")", "ReplyKeyboardMarkup", "{", "var", "keyboard", "[", "]", "[", "]", "KeyboardButton", "\n", "keyboard", "=", "append", "(", "keyboard", ",", "rows", "...", ")", "\n", "return", "ReplyKeyboardMarkup", "{", "ResizeKeyboard", ":", "true", ",", "Keyboard", ":", "keyboard", ",", "}", "\n", "}" ]
// NewReplyKeyboard creates a new regular keyboard with sane defaults.
[ "NewReplyKeyboard", "creates", "a", "new", "regular", "keyboard", "with", "sane", "defaults", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L696-L705
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineKeyboardButtonData
func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton { return InlineKeyboardButton{ Text: text, CallbackData: &data, } }
go
func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton { return InlineKeyboardButton{ Text: text, CallbackData: &data, } }
[ "func", "NewInlineKeyboardButtonData", "(", "text", ",", "data", "string", ")", "InlineKeyboardButton", "{", "return", "InlineKeyboardButton", "{", "Text", ":", "text", ",", "CallbackData", ":", "&", "data", ",", "}", "\n", "}" ]
// NewInlineKeyboardButtonData creates an inline keyboard button with text // and data for a callback.
[ "NewInlineKeyboardButtonData", "creates", "an", "inline", "keyboard", "button", "with", "text", "and", "data", "for", "a", "callback", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L709-L714
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineKeyboardButtonURL
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton { return InlineKeyboardButton{ Text: text, URL: &url, } }
go
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton { return InlineKeyboardButton{ Text: text, URL: &url, } }
[ "func", "NewInlineKeyboardButtonURL", "(", "text", ",", "url", "string", ")", "InlineKeyboardButton", "{", "return", "InlineKeyboardButton", "{", "Text", ":", "text", ",", "URL", ":", "&", "url", ",", "}", "\n", "}" ]
// NewInlineKeyboardButtonURL creates an inline keyboard button with text // which goes to a URL.
[ "NewInlineKeyboardButtonURL", "creates", "an", "inline", "keyboard", "button", "with", "text", "which", "goes", "to", "a", "URL", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L718-L723
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineKeyboardButtonSwitch
func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton { return InlineKeyboardButton{ Text: text, SwitchInlineQuery: &sw, } }
go
func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton { return InlineKeyboardButton{ Text: text, SwitchInlineQuery: &sw, } }
[ "func", "NewInlineKeyboardButtonSwitch", "(", "text", ",", "sw", "string", ")", "InlineKeyboardButton", "{", "return", "InlineKeyboardButton", "{", "Text", ":", "text", ",", "SwitchInlineQuery", ":", "&", "sw", ",", "}", "\n", "}" ]
// NewInlineKeyboardButtonSwitch creates an inline keyboard button with // text which allows the user to switch to a chat or return to a chat.
[ "NewInlineKeyboardButtonSwitch", "creates", "an", "inline", "keyboard", "button", "with", "text", "which", "allows", "the", "user", "to", "switch", "to", "a", "chat", "or", "return", "to", "a", "chat", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L727-L732
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineKeyboardRow
func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton { var row []InlineKeyboardButton row = append(row, buttons...) return row }
go
func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton { var row []InlineKeyboardButton row = append(row, buttons...) return row }
[ "func", "NewInlineKeyboardRow", "(", "buttons", "...", "InlineKeyboardButton", ")", "[", "]", "InlineKeyboardButton", "{", "var", "row", "[", "]", "InlineKeyboardButton", "\n", "row", "=", "append", "(", "row", ",", "buttons", "...", ")", "\n", "return", "row", "\n", "}" ]
// NewInlineKeyboardRow creates an inline keyboard row with buttons.
[ "NewInlineKeyboardRow", "creates", "an", "inline", "keyboard", "row", "with", "buttons", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L735-L741
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInlineKeyboardMarkup
func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup { var keyboard [][]InlineKeyboardButton keyboard = append(keyboard, rows...) return InlineKeyboardMarkup{ InlineKeyboard: keyboard, } }
go
func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup { var keyboard [][]InlineKeyboardButton keyboard = append(keyboard, rows...) return InlineKeyboardMarkup{ InlineKeyboard: keyboard, } }
[ "func", "NewInlineKeyboardMarkup", "(", "rows", "...", "[", "]", "InlineKeyboardButton", ")", "InlineKeyboardMarkup", "{", "var", "keyboard", "[", "]", "[", "]", "InlineKeyboardButton", "\n", "keyboard", "=", "append", "(", "keyboard", ",", "rows", "...", ")", "\n", "return", "InlineKeyboardMarkup", "{", "InlineKeyboard", ":", "keyboard", ",", "}", "\n", "}" ]
// NewInlineKeyboardMarkup creates a new inline keyboard.
[ "NewInlineKeyboardMarkup", "creates", "a", "new", "inline", "keyboard", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L744-L752
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewCallback
func NewCallback(id, text string) CallbackConfig { return CallbackConfig{ CallbackQueryID: id, Text: text, ShowAlert: false, } }
go
func NewCallback(id, text string) CallbackConfig { return CallbackConfig{ CallbackQueryID: id, Text: text, ShowAlert: false, } }
[ "func", "NewCallback", "(", "id", ",", "text", "string", ")", "CallbackConfig", "{", "return", "CallbackConfig", "{", "CallbackQueryID", ":", "id", ",", "Text", ":", "text", ",", "ShowAlert", ":", "false", ",", "}", "\n", "}" ]
// NewCallback creates a new callback message.
[ "NewCallback", "creates", "a", "new", "callback", "message", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L755-L761
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewCallbackWithAlert
func NewCallbackWithAlert(id, text string) CallbackConfig { return CallbackConfig{ CallbackQueryID: id, Text: text, ShowAlert: true, } }
go
func NewCallbackWithAlert(id, text string) CallbackConfig { return CallbackConfig{ CallbackQueryID: id, Text: text, ShowAlert: true, } }
[ "func", "NewCallbackWithAlert", "(", "id", ",", "text", "string", ")", "CallbackConfig", "{", "return", "CallbackConfig", "{", "CallbackQueryID", ":", "id", ",", "Text", ":", "text", ",", "ShowAlert", ":", "true", ",", "}", "\n", "}" ]
// NewCallbackWithAlert creates a new callback message that alerts // the user.
[ "NewCallbackWithAlert", "creates", "a", "new", "callback", "message", "that", "alerts", "the", "user", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L765-L771
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewInvoice
func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig { return InvoiceConfig{ BaseChat: BaseChat{ChatID: chatID}, Title: title, Description: description, Payload: payload, ProviderToken: providerToken, StartParameter: startParameter, Currency: currency, Prices: prices} }
go
func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig { return InvoiceConfig{ BaseChat: BaseChat{ChatID: chatID}, Title: title, Description: description, Payload: payload, ProviderToken: providerToken, StartParameter: startParameter, Currency: currency, Prices: prices} }
[ "func", "NewInvoice", "(", "chatID", "int64", ",", "title", ",", "description", ",", "payload", ",", "providerToken", ",", "startParameter", ",", "currency", "string", ",", "prices", "*", "[", "]", "LabeledPrice", ")", "InvoiceConfig", "{", "return", "InvoiceConfig", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "Title", ":", "title", ",", "Description", ":", "description", ",", "Payload", ":", "payload", ",", "ProviderToken", ":", "providerToken", ",", "StartParameter", ":", "startParameter", ",", "Currency", ":", "currency", ",", "Prices", ":", "prices", "}", "\n", "}" ]
// NewInvoice creates a new Invoice request to the user.
[ "NewInvoice", "creates", "a", "new", "Invoice", "request", "to", "the", "user", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L774-L784
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewSetChatPhotoUpload
func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig { return SetChatPhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
go
func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig { return SetChatPhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, File: file, UseExisting: false, }, } }
[ "func", "NewSetChatPhotoUpload", "(", "chatID", "int64", ",", "file", "interface", "{", "}", ")", "SetChatPhotoConfig", "{", "return", "SetChatPhotoConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "File", ":", "file", ",", "UseExisting", ":", "false", ",", "}", ",", "}", "\n", "}" ]
// NewSetChatPhotoUpload creates a new chat photo uploader. // // chatID is where to send it, file is a string path to the file, // FileReader, or FileBytes. // // Note that you must send animated GIFs as a document.
[ "NewSetChatPhotoUpload", "creates", "a", "new", "chat", "photo", "uploader", ".", "chatID", "is", "where", "to", "send", "it", "file", "is", "a", "string", "path", "to", "the", "file", "FileReader", "or", "FileBytes", ".", "Note", "that", "you", "must", "send", "animated", "GIFs", "as", "a", "document", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L792-L800
train
go-telegram-bot-api/telegram-bot-api
helpers.go
NewSetChatPhotoShare
func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig { return SetChatPhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
go
func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig { return SetChatPhotoConfig{ BaseFile: BaseFile{ BaseChat: BaseChat{ChatID: chatID}, FileID: fileID, UseExisting: true, }, } }
[ "func", "NewSetChatPhotoShare", "(", "chatID", "int64", ",", "fileID", "string", ")", "SetChatPhotoConfig", "{", "return", "SetChatPhotoConfig", "{", "BaseFile", ":", "BaseFile", "{", "BaseChat", ":", "BaseChat", "{", "ChatID", ":", "chatID", "}", ",", "FileID", ":", "fileID", ",", "UseExisting", ":", "true", ",", "}", ",", "}", "\n", "}" ]
// NewSetChatPhotoShare shares an existing photo. // You may use this to reshare an existing photo without reuploading it. // // chatID is where to send it, fileID is the ID of the file // already uploaded.
[ "NewSetChatPhotoShare", "shares", "an", "existing", "photo", ".", "You", "may", "use", "this", "to", "reshare", "an", "existing", "photo", "without", "reuploading", "it", ".", "chatID", "is", "where", "to", "send", "it", "fileID", "is", "the", "ID", "of", "the", "file", "already", "uploaded", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/helpers.go#L807-L815
train
go-telegram-bot-api/telegram-bot-api
types.go
Time
func (m *Message) Time() time.Time { return time.Unix(int64(m.Date), 0) }
go
func (m *Message) Time() time.Time { return time.Unix(int64(m.Date), 0) }
[ "func", "(", "m", "*", "Message", ")", "Time", "(", ")", "time", ".", "Time", "{", "return", "time", ".", "Unix", "(", "int64", "(", "m", ".", "Date", ")", ",", "0", ")", "\n", "}" ]
// Time converts the message timestamp into a Time.
[ "Time", "converts", "the", "message", "timestamp", "into", "a", "Time", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/types.go#L177-L179
train
go-telegram-bot-api/telegram-bot-api
types.go
IsCommand
func (m *Message) IsCommand() bool { if m.Entities == nil || len(*m.Entities) == 0 { return false } entity := (*m.Entities)[0] return entity.Offset == 0 && entity.IsCommand() }
go
func (m *Message) IsCommand() bool { if m.Entities == nil || len(*m.Entities) == 0 { return false } entity := (*m.Entities)[0] return entity.Offset == 0 && entity.IsCommand() }
[ "func", "(", "m", "*", "Message", ")", "IsCommand", "(", ")", "bool", "{", "if", "m", ".", "Entities", "==", "nil", "||", "len", "(", "*", "m", ".", "Entities", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "entity", ":=", "(", "*", "m", ".", "Entities", ")", "[", "0", "]", "\n", "return", "entity", ".", "Offset", "==", "0", "&&", "entity", ".", "IsCommand", "(", ")", "\n", "}" ]
// IsCommand returns true if message starts with a "bot_command" entity.
[ "IsCommand", "returns", "true", "if", "message", "starts", "with", "a", "bot_command", "entity", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/types.go#L182-L189
train
go-telegram-bot-api/telegram-bot-api
types.go
ParseURL
func (e MessageEntity) ParseURL() (*url.URL, error) { if e.URL == "" { return nil, errors.New(ErrBadURL) } return url.Parse(e.URL) }
go
func (e MessageEntity) ParseURL() (*url.URL, error) { if e.URL == "" { return nil, errors.New(ErrBadURL) } return url.Parse(e.URL) }
[ "func", "(", "e", "MessageEntity", ")", "ParseURL", "(", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "if", "e", ".", "URL", "==", "\"\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "ErrBadURL", ")", "\n", "}", "\n", "return", "url", ".", "Parse", "(", "e", ".", "URL", ")", "\n", "}" ]
// ParseURL attempts to parse a URL contained within a MessageEntity.
[ "ParseURL", "attempts", "to", "parse", "a", "URL", "contained", "within", "a", "MessageEntity", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/types.go#L254-L260
train
go-telegram-bot-api/telegram-bot-api
types.go
Link
func (f *File) Link(token string) string { return fmt.Sprintf(FileEndpoint, token, f.FilePath) }
go
func (f *File) Link(token string) string { return fmt.Sprintf(FileEndpoint, token, f.FilePath) }
[ "func", "(", "f", "*", "File", ")", "Link", "(", "token", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "FileEndpoint", ",", "token", ",", "f", ".", "FilePath", ")", "\n", "}" ]
// Link returns a full path to the download URL for a File. // // It requires the Bot Token to create the link.
[ "Link", "returns", "a", "full", "path", "to", "the", "download", "URL", "for", "a", "File", ".", "It", "requires", "the", "Bot", "Token", "to", "create", "the", "link", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/types.go#L430-L432
train
go-telegram-bot-api/telegram-bot-api
bot.go
NewBotAPIWithClient
func NewBotAPIWithClient(token string, client *http.Client) (*BotAPI, error) { bot := &BotAPI{ Token: token, Client: client, Buffer: 100, shutdownChannel: make(chan interface{}), } self, err := bot.GetMe() if err != nil { return nil, err } bot.Self = self return bot, nil }
go
func NewBotAPIWithClient(token string, client *http.Client) (*BotAPI, error) { bot := &BotAPI{ Token: token, Client: client, Buffer: 100, shutdownChannel: make(chan interface{}), } self, err := bot.GetMe() if err != nil { return nil, err } bot.Self = self return bot, nil }
[ "func", "NewBotAPIWithClient", "(", "token", "string", ",", "client", "*", "http", ".", "Client", ")", "(", "*", "BotAPI", ",", "error", ")", "{", "bot", ":=", "&", "BotAPI", "{", "Token", ":", "token", ",", "Client", ":", "client", ",", "Buffer", ":", "100", ",", "shutdownChannel", ":", "make", "(", "chan", "interface", "{", "}", ")", ",", "}", "\n", "self", ",", "err", ":=", "bot", ".", "GetMe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "bot", ".", "Self", "=", "self", "\n", "return", "bot", ",", "nil", "\n", "}" ]
// NewBotAPIWithClient creates a new BotAPI instance // and allows you to pass a http.Client. // // It requires a token, provided by @BotFather on Telegram.
[ "NewBotAPIWithClient", "creates", "a", "new", "BotAPI", "instance", "and", "allows", "you", "to", "pass", "a", "http", ".", "Client", ".", "It", "requires", "a", "token", "provided", "by" ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L44-L60
train
go-telegram-bot-api/telegram-bot-api
bot.go
MakeRequest
func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, error) { method := fmt.Sprintf(APIEndpoint, bot.Token, endpoint) resp, err := bot.Client.PostForm(method, params) if err != nil { return APIResponse{}, err } defer resp.Body.Close() var apiResp APIResponse bytes, err := bot.decodeAPIResponse(resp.Body, &apiResp) if err != nil { return apiResp, err } if bot.Debug { log.Printf("%s resp: %s", endpoint, bytes) } if !apiResp.Ok { parameters := ResponseParameters{} if apiResp.Parameters != nil { parameters = *apiResp.Parameters } return apiResp, Error{Code: apiResp.ErrorCode, Message: apiResp.Description, ResponseParameters: parameters} } return apiResp, nil }
go
func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, error) { method := fmt.Sprintf(APIEndpoint, bot.Token, endpoint) resp, err := bot.Client.PostForm(method, params) if err != nil { return APIResponse{}, err } defer resp.Body.Close() var apiResp APIResponse bytes, err := bot.decodeAPIResponse(resp.Body, &apiResp) if err != nil { return apiResp, err } if bot.Debug { log.Printf("%s resp: %s", endpoint, bytes) } if !apiResp.Ok { parameters := ResponseParameters{} if apiResp.Parameters != nil { parameters = *apiResp.Parameters } return apiResp, Error{Code: apiResp.ErrorCode, Message: apiResp.Description, ResponseParameters: parameters} } return apiResp, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "MakeRequest", "(", "endpoint", "string", ",", "params", "url", ".", "Values", ")", "(", "APIResponse", ",", "error", ")", "{", "method", ":=", "fmt", ".", "Sprintf", "(", "APIEndpoint", ",", "bot", ".", "Token", ",", "endpoint", ")", "\n", "resp", ",", "err", ":=", "bot", ".", "Client", ".", "PostForm", "(", "method", ",", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "var", "apiResp", "APIResponse", "\n", "bytes", ",", "err", ":=", "bot", ".", "decodeAPIResponse", "(", "resp", ".", "Body", ",", "&", "apiResp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "apiResp", ",", "err", "\n", "}", "\n", "if", "bot", ".", "Debug", "{", "log", ".", "Printf", "(", "\"%s resp: %s\"", ",", "endpoint", ",", "bytes", ")", "\n", "}", "\n", "if", "!", "apiResp", ".", "Ok", "{", "parameters", ":=", "ResponseParameters", "{", "}", "\n", "if", "apiResp", ".", "Parameters", "!=", "nil", "{", "parameters", "=", "*", "apiResp", ".", "Parameters", "\n", "}", "\n", "return", "apiResp", ",", "Error", "{", "Code", ":", "apiResp", ".", "ErrorCode", ",", "Message", ":", "apiResp", ".", "Description", ",", "ResponseParameters", ":", "parameters", "}", "\n", "}", "\n", "return", "apiResp", ",", "nil", "\n", "}" ]
// MakeRequest makes a request to a specific endpoint with our token.
[ "MakeRequest", "makes", "a", "request", "to", "a", "specific", "endpoint", "with", "our", "token", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L63-L91
train