repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
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", "(", "\"", "\"", ")", "\n", "}", "\n\n", "thumbprint", ",", "err", ":=", "key", ".", "Thumbprint", "(", "crypto", ".", "SHA256", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\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\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", ":", "// Unsupported challenge type", "return", "false", "\n", "}", "\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\n", "// Before completion, the key authorization field should be empty", "if", "ch", ".", "ProvidedKeyAuthorization", "!=", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\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\n", "// If the challenge is completed, then there should be a key authorization", "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", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// There always needs to be a token", "if", "!", "LooksLikeAToken", "(", "ch", ".", "Token", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\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", ":=", "\"", "\"", "\n", "host", ":=", "request", ".", "Host", "\n\n", "// If the request was received via TLS, use `https://` for the protocol", "if", "request", ".", "TLS", "!=", "nil", "{", "proto", "=", "\"", "\"", "\n", "}", "\n\n", "// Allow upstream proxies to specify the forwarded protocol. Allow this value", "// to override our own guess.", "if", "specifiedProto", ":=", "request", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ";", "specifiedProto", "!=", "\"", "\"", "{", "proto", "=", "specifiedProto", "\n", "}", "\n\n", "// 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", "=", "\"", "\"", "\n", "}", "\n\n", "resultUrl", ":=", "url", ".", "URL", "{", "Scheme", ":", "proto", ",", "Host", ":", "host", ",", "Path", ":", "endpoint", "}", "\n", "result", "=", "resultUrl", ".", "String", "(", ")", "\n\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\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\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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "ID", ":", "id", ",", "Title", ":", "title", ",", "InputMessageContent", ":", "InputTextMessageContent", "{", "Text", ":", "messageText", ",", "ParseMode", ":", "\"", "\"", ",", "}", ",", "}", "\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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", ":", "\"", "\"", ",", "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", "(", "\"", "\"", ")", "\n\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\n", "row", "=", "append", "(", "row", ",", "buttons", "...", ")", "\n\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\n", "keyboard", "=", "append", "(", "keyboard", ",", "rows", "...", ")", "\n\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\n", "row", "=", "append", "(", "row", ",", "buttons", "...", ")", "\n\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\n", "keyboard", "=", "append", "(", "keyboard", ",", "rows", "...", ")", "\n\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\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\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\n", "self", ",", "err", ":=", "bot", ".", "GetMe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "bot", ".", "Self", "=", "self", "\n\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\n", "resp", ",", "err", ":=", "bot", ".", "Client", ".", "PostForm", "(", "method", ",", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n\n", "var", "apiResp", "APIResponse", "\n", "bytes", ",", "err", ":=", "bot", ".", "decodeAPIResponse", "(", "resp", ".", "Body", ",", "&", "apiResp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "apiResp", ",", "err", "\n", "}", "\n\n", "if", "bot", ".", "Debug", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "endpoint", ",", "bytes", ")", "\n", "}", "\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\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
go-telegram-bot-api/telegram-bot-api
bot.go
decodeAPIResponse
func (bot *BotAPI) decodeAPIResponse(responseBody io.Reader, resp *APIResponse) (_ []byte, err error) { if !bot.Debug { dec := json.NewDecoder(responseBody) err = dec.Decode(resp) return } // if debug, read reponse body data, err := ioutil.ReadAll(responseBody) if err != nil { return } err = json.Unmarshal(data, resp) if err != nil { return } return data, nil }
go
func (bot *BotAPI) decodeAPIResponse(responseBody io.Reader, resp *APIResponse) (_ []byte, err error) { if !bot.Debug { dec := json.NewDecoder(responseBody) err = dec.Decode(resp) return } // if debug, read reponse body data, err := ioutil.ReadAll(responseBody) if err != nil { return } err = json.Unmarshal(data, resp) if err != nil { return } return data, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "decodeAPIResponse", "(", "responseBody", "io", ".", "Reader", ",", "resp", "*", "APIResponse", ")", "(", "_", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "!", "bot", ".", "Debug", "{", "dec", ":=", "json", ".", "NewDecoder", "(", "responseBody", ")", "\n", "err", "=", "dec", ".", "Decode", "(", "resp", ")", "\n", "return", "\n", "}", "\n\n", "// if debug, read reponse body", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "responseBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "err", "=", "json", ".", "Unmarshal", "(", "data", ",", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "return", "data", ",", "nil", "\n", "}" ]
// decodeAPIResponse decode response and return slice of bytes if debug enabled. // If debug disabled, just decode http.Response.Body stream to APIResponse struct // for efficient memory usage
[ "decodeAPIResponse", "decode", "response", "and", "return", "slice", "of", "bytes", "if", "debug", "enabled", ".", "If", "debug", "disabled", "just", "decode", "http", ".", "Response", ".", "Body", "stream", "to", "APIResponse", "struct", "for", "efficient", "memory", "usage" ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L96-L115
train
go-telegram-bot-api/telegram-bot-api
bot.go
makeMessageRequest
func (bot *BotAPI) makeMessageRequest(endpoint string, params url.Values) (Message, error) { resp, err := bot.MakeRequest(endpoint, params) if err != nil { return Message{}, err } var message Message json.Unmarshal(resp.Result, &message) bot.debugLog(endpoint, params, message) return message, nil }
go
func (bot *BotAPI) makeMessageRequest(endpoint string, params url.Values) (Message, error) { resp, err := bot.MakeRequest(endpoint, params) if err != nil { return Message{}, err } var message Message json.Unmarshal(resp.Result, &message) bot.debugLog(endpoint, params, message) return message, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "makeMessageRequest", "(", "endpoint", "string", ",", "params", "url", ".", "Values", ")", "(", "Message", ",", "error", ")", "{", "resp", ",", "err", ":=", "bot", ".", "MakeRequest", "(", "endpoint", ",", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Message", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "message", "Message", "\n", "json", ".", "Unmarshal", "(", "resp", ".", "Result", ",", "&", "message", ")", "\n\n", "bot", ".", "debugLog", "(", "endpoint", ",", "params", ",", "message", ")", "\n\n", "return", "message", ",", "nil", "\n", "}" ]
// makeMessageRequest makes a request to a method that returns a Message.
[ "makeMessageRequest", "makes", "a", "request", "to", "a", "method", "that", "returns", "a", "Message", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L118-L130
train
go-telegram-bot-api/telegram-bot-api
bot.go
UploadFile
func (bot *BotAPI) UploadFile(endpoint string, params map[string]string, fieldname string, file interface{}) (APIResponse, error) { ms := multipartstreamer.New() switch f := file.(type) { case string: ms.WriteFields(params) fileHandle, err := os.Open(f) if err != nil { return APIResponse{}, err } defer fileHandle.Close() fi, err := os.Stat(f) if err != nil { return APIResponse{}, err } ms.WriteReader(fieldname, fileHandle.Name(), fi.Size(), fileHandle) case FileBytes: ms.WriteFields(params) buf := bytes.NewBuffer(f.Bytes) ms.WriteReader(fieldname, f.Name, int64(len(f.Bytes)), buf) case FileReader: ms.WriteFields(params) if f.Size != -1 { ms.WriteReader(fieldname, f.Name, f.Size, f.Reader) break } data, err := ioutil.ReadAll(f.Reader) if err != nil { return APIResponse{}, err } buf := bytes.NewBuffer(data) ms.WriteReader(fieldname, f.Name, int64(len(data)), buf) case url.URL: params[fieldname] = f.String() ms.WriteFields(params) default: return APIResponse{}, errors.New(ErrBadFileType) } method := fmt.Sprintf(APIEndpoint, bot.Token, endpoint) req, err := http.NewRequest("POST", method, nil) if err != nil { return APIResponse{}, err } ms.SetupRequest(req) res, err := bot.Client.Do(req) if err != nil { return APIResponse{}, err } defer res.Body.Close() bytes, err := ioutil.ReadAll(res.Body) if err != nil { return APIResponse{}, err } if bot.Debug { log.Println(string(bytes)) } var apiResp APIResponse err = json.Unmarshal(bytes, &apiResp) if err != nil { return APIResponse{}, err } if !apiResp.Ok { return APIResponse{}, errors.New(apiResp.Description) } return apiResp, nil }
go
func (bot *BotAPI) UploadFile(endpoint string, params map[string]string, fieldname string, file interface{}) (APIResponse, error) { ms := multipartstreamer.New() switch f := file.(type) { case string: ms.WriteFields(params) fileHandle, err := os.Open(f) if err != nil { return APIResponse{}, err } defer fileHandle.Close() fi, err := os.Stat(f) if err != nil { return APIResponse{}, err } ms.WriteReader(fieldname, fileHandle.Name(), fi.Size(), fileHandle) case FileBytes: ms.WriteFields(params) buf := bytes.NewBuffer(f.Bytes) ms.WriteReader(fieldname, f.Name, int64(len(f.Bytes)), buf) case FileReader: ms.WriteFields(params) if f.Size != -1 { ms.WriteReader(fieldname, f.Name, f.Size, f.Reader) break } data, err := ioutil.ReadAll(f.Reader) if err != nil { return APIResponse{}, err } buf := bytes.NewBuffer(data) ms.WriteReader(fieldname, f.Name, int64(len(data)), buf) case url.URL: params[fieldname] = f.String() ms.WriteFields(params) default: return APIResponse{}, errors.New(ErrBadFileType) } method := fmt.Sprintf(APIEndpoint, bot.Token, endpoint) req, err := http.NewRequest("POST", method, nil) if err != nil { return APIResponse{}, err } ms.SetupRequest(req) res, err := bot.Client.Do(req) if err != nil { return APIResponse{}, err } defer res.Body.Close() bytes, err := ioutil.ReadAll(res.Body) if err != nil { return APIResponse{}, err } if bot.Debug { log.Println(string(bytes)) } var apiResp APIResponse err = json.Unmarshal(bytes, &apiResp) if err != nil { return APIResponse{}, err } if !apiResp.Ok { return APIResponse{}, errors.New(apiResp.Description) } return apiResp, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "UploadFile", "(", "endpoint", "string", ",", "params", "map", "[", "string", "]", "string", ",", "fieldname", "string", ",", "file", "interface", "{", "}", ")", "(", "APIResponse", ",", "error", ")", "{", "ms", ":=", "multipartstreamer", ".", "New", "(", ")", "\n\n", "switch", "f", ":=", "file", ".", "(", "type", ")", "{", "case", "string", ":", "ms", ".", "WriteFields", "(", "params", ")", "\n\n", "fileHandle", ",", "err", ":=", "os", ".", "Open", "(", "f", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n", "defer", "fileHandle", ".", "Close", "(", ")", "\n\n", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "f", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n\n", "ms", ".", "WriteReader", "(", "fieldname", ",", "fileHandle", ".", "Name", "(", ")", ",", "fi", ".", "Size", "(", ")", ",", "fileHandle", ")", "\n", "case", "FileBytes", ":", "ms", ".", "WriteFields", "(", "params", ")", "\n\n", "buf", ":=", "bytes", ".", "NewBuffer", "(", "f", ".", "Bytes", ")", "\n", "ms", ".", "WriteReader", "(", "fieldname", ",", "f", ".", "Name", ",", "int64", "(", "len", "(", "f", ".", "Bytes", ")", ")", ",", "buf", ")", "\n", "case", "FileReader", ":", "ms", ".", "WriteFields", "(", "params", ")", "\n\n", "if", "f", ".", "Size", "!=", "-", "1", "{", "ms", ".", "WriteReader", "(", "fieldname", ",", "f", ".", "Name", ",", "f", ".", "Size", ",", "f", ".", "Reader", ")", "\n\n", "break", "\n", "}", "\n\n", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "f", ".", "Reader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n\n", "buf", ":=", "bytes", ".", "NewBuffer", "(", "data", ")", "\n\n", "ms", ".", "WriteReader", "(", "fieldname", ",", "f", ".", "Name", ",", "int64", "(", "len", "(", "data", ")", ")", ",", "buf", ")", "\n", "case", "url", ".", "URL", ":", "params", "[", "fieldname", "]", "=", "f", ".", "String", "(", ")", "\n\n", "ms", ".", "WriteFields", "(", "params", ")", "\n", "default", ":", "return", "APIResponse", "{", "}", ",", "errors", ".", "New", "(", "ErrBadFileType", ")", "\n", "}", "\n\n", "method", ":=", "fmt", ".", "Sprintf", "(", "APIEndpoint", ",", "bot", ".", "Token", ",", "endpoint", ")", "\n\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "method", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n\n", "ms", ".", "SetupRequest", "(", "req", ")", "\n\n", "res", ",", "err", ":=", "bot", ".", "Client", ".", "Do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n", "defer", "res", ".", "Body", ".", "Close", "(", ")", "\n\n", "bytes", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "res", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "bot", ".", "Debug", "{", "log", ".", "Println", "(", "string", "(", "bytes", ")", ")", "\n", "}", "\n\n", "var", "apiResp", "APIResponse", "\n\n", "err", "=", "json", ".", "Unmarshal", "(", "bytes", ",", "&", "apiResp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "!", "apiResp", ".", "Ok", "{", "return", "APIResponse", "{", "}", ",", "errors", ".", "New", "(", "apiResp", ".", "Description", ")", "\n", "}", "\n\n", "return", "apiResp", ",", "nil", "\n", "}" ]
// UploadFile makes a request to the API with a file. // // Requires the parameter to hold the file not be in the params. // File should be a string to a file path, a FileBytes struct, // a FileReader struct, or a url.URL. // // Note that if your FileReader has a size set to -1, it will read // the file into memory to calculate a size.
[ "UploadFile", "makes", "a", "request", "to", "the", "API", "with", "a", "file", ".", "Requires", "the", "parameter", "to", "hold", "the", "file", "not", "be", "in", "the", "params", ".", "File", "should", "be", "a", "string", "to", "a", "file", "path", "a", "FileBytes", "struct", "a", "FileReader", "struct", "or", "a", "url", ".", "URL", ".", "Note", "that", "if", "your", "FileReader", "has", "a", "size", "set", "to", "-", "1", "it", "will", "read", "the", "file", "into", "memory", "to", "calculate", "a", "size", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L140-L225
train
go-telegram-bot-api/telegram-bot-api
bot.go
GetFileDirectURL
func (bot *BotAPI) GetFileDirectURL(fileID string) (string, error) { file, err := bot.GetFile(FileConfig{fileID}) if err != nil { return "", err } return file.Link(bot.Token), nil }
go
func (bot *BotAPI) GetFileDirectURL(fileID string) (string, error) { file, err := bot.GetFile(FileConfig{fileID}) if err != nil { return "", err } return file.Link(bot.Token), nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "GetFileDirectURL", "(", "fileID", "string", ")", "(", "string", ",", "error", ")", "{", "file", ",", "err", ":=", "bot", ".", "GetFile", "(", "FileConfig", "{", "fileID", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "file", ".", "Link", "(", "bot", ".", "Token", ")", ",", "nil", "\n", "}" ]
// GetFileDirectURL returns direct URL to file // // It requires the FileID.
[ "GetFileDirectURL", "returns", "direct", "URL", "to", "file", "It", "requires", "the", "FileID", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L230-L238
train
go-telegram-bot-api/telegram-bot-api
bot.go
GetMe
func (bot *BotAPI) GetMe() (User, error) { resp, err := bot.MakeRequest("getMe", nil) if err != nil { return User{}, err } var user User json.Unmarshal(resp.Result, &user) bot.debugLog("getMe", nil, user) return user, nil }
go
func (bot *BotAPI) GetMe() (User, error) { resp, err := bot.MakeRequest("getMe", nil) if err != nil { return User{}, err } var user User json.Unmarshal(resp.Result, &user) bot.debugLog("getMe", nil, user) return user, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "GetMe", "(", ")", "(", "User", ",", "error", ")", "{", "resp", ",", "err", ":=", "bot", ".", "MakeRequest", "(", "\"", "\"", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "user", "User", "\n", "json", ".", "Unmarshal", "(", "resp", ".", "Result", ",", "&", "user", ")", "\n\n", "bot", ".", "debugLog", "(", "\"", "\"", ",", "nil", ",", "user", ")", "\n\n", "return", "user", ",", "nil", "\n", "}" ]
// GetMe fetches the currently authenticated bot. // // This method is called upon creation to validate the token, // and so you may get this data from BotAPI.Self without the need for // another request.
[ "GetMe", "fetches", "the", "currently", "authenticated", "bot", ".", "This", "method", "is", "called", "upon", "creation", "to", "validate", "the", "token", "and", "so", "you", "may", "get", "this", "data", "from", "BotAPI", ".", "Self", "without", "the", "need", "for", "another", "request", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L245-L257
train
go-telegram-bot-api/telegram-bot-api
bot.go
IsMessageToMe
func (bot *BotAPI) IsMessageToMe(message Message) bool { return strings.Contains(message.Text, "@"+bot.Self.UserName) }
go
func (bot *BotAPI) IsMessageToMe(message Message) bool { return strings.Contains(message.Text, "@"+bot.Self.UserName) }
[ "func", "(", "bot", "*", "BotAPI", ")", "IsMessageToMe", "(", "message", "Message", ")", "bool", "{", "return", "strings", ".", "Contains", "(", "message", ".", "Text", ",", "\"", "\"", "+", "bot", ".", "Self", ".", "UserName", ")", "\n", "}" ]
// IsMessageToMe returns true if message directed to this bot. // // It requires the Message.
[ "IsMessageToMe", "returns", "true", "if", "message", "directed", "to", "this", "bot", ".", "It", "requires", "the", "Message", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L262-L264
train
go-telegram-bot-api/telegram-bot-api
bot.go
Send
func (bot *BotAPI) Send(c Chattable) (Message, error) { switch c.(type) { case Fileable: return bot.sendFile(c.(Fileable)) default: return bot.sendChattable(c) } }
go
func (bot *BotAPI) Send(c Chattable) (Message, error) { switch c.(type) { case Fileable: return bot.sendFile(c.(Fileable)) default: return bot.sendChattable(c) } }
[ "func", "(", "bot", "*", "BotAPI", ")", "Send", "(", "c", "Chattable", ")", "(", "Message", ",", "error", ")", "{", "switch", "c", ".", "(", "type", ")", "{", "case", "Fileable", ":", "return", "bot", ".", "sendFile", "(", "c", ".", "(", "Fileable", ")", ")", "\n", "default", ":", "return", "bot", ".", "sendChattable", "(", "c", ")", "\n", "}", "\n", "}" ]
// Send will send a Chattable item to Telegram. // // It requires the Chattable to send.
[ "Send", "will", "send", "a", "Chattable", "item", "to", "Telegram", ".", "It", "requires", "the", "Chattable", "to", "send", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L269-L276
train
go-telegram-bot-api/telegram-bot-api
bot.go
debugLog
func (bot *BotAPI) debugLog(context string, v url.Values, message interface{}) { if bot.Debug { log.Printf("%s req : %+v\n", context, v) log.Printf("%s resp: %+v\n", context, message) } }
go
func (bot *BotAPI) debugLog(context string, v url.Values, message interface{}) { if bot.Debug { log.Printf("%s req : %+v\n", context, v) log.Printf("%s resp: %+v\n", context, message) } }
[ "func", "(", "bot", "*", "BotAPI", ")", "debugLog", "(", "context", "string", ",", "v", "url", ".", "Values", ",", "message", "interface", "{", "}", ")", "{", "if", "bot", ".", "Debug", "{", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "context", ",", "v", ")", "\n", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "context", ",", "message", ")", "\n", "}", "\n", "}" ]
// debugLog checks if the bot is currently running in debug mode, and if // so will display information about the request and response in the // debug log.
[ "debugLog", "checks", "if", "the", "bot", "is", "currently", "running", "in", "debug", "mode", "and", "if", "so", "will", "display", "information", "about", "the", "request", "and", "response", "in", "the", "debug", "log", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L281-L286
train
go-telegram-bot-api/telegram-bot-api
bot.go
sendExisting
func (bot *BotAPI) sendExisting(method string, config Fileable) (Message, error) { v, err := config.values() if err != nil { return Message{}, err } message, err := bot.makeMessageRequest(method, v) if err != nil { return Message{}, err } return message, nil }
go
func (bot *BotAPI) sendExisting(method string, config Fileable) (Message, error) { v, err := config.values() if err != nil { return Message{}, err } message, err := bot.makeMessageRequest(method, v) if err != nil { return Message{}, err } return message, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "sendExisting", "(", "method", "string", ",", "config", "Fileable", ")", "(", "Message", ",", "error", ")", "{", "v", ",", "err", ":=", "config", ".", "values", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "Message", "{", "}", ",", "err", "\n", "}", "\n\n", "message", ",", "err", ":=", "bot", ".", "makeMessageRequest", "(", "method", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Message", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "message", ",", "nil", "\n", "}" ]
// sendExisting will send a Message with an existing file to Telegram.
[ "sendExisting", "will", "send", "a", "Message", "with", "an", "existing", "file", "to", "Telegram", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L289-L302
train
go-telegram-bot-api/telegram-bot-api
bot.go
uploadAndSend
func (bot *BotAPI) uploadAndSend(method string, config Fileable) (Message, error) { params, err := config.params() if err != nil { return Message{}, err } file := config.getFile() resp, err := bot.UploadFile(method, params, config.name(), file) if err != nil { return Message{}, err } var message Message json.Unmarshal(resp.Result, &message) bot.debugLog(method, nil, message) return message, nil }
go
func (bot *BotAPI) uploadAndSend(method string, config Fileable) (Message, error) { params, err := config.params() if err != nil { return Message{}, err } file := config.getFile() resp, err := bot.UploadFile(method, params, config.name(), file) if err != nil { return Message{}, err } var message Message json.Unmarshal(resp.Result, &message) bot.debugLog(method, nil, message) return message, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "uploadAndSend", "(", "method", "string", ",", "config", "Fileable", ")", "(", "Message", ",", "error", ")", "{", "params", ",", "err", ":=", "config", ".", "params", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Message", "{", "}", ",", "err", "\n", "}", "\n\n", "file", ":=", "config", ".", "getFile", "(", ")", "\n\n", "resp", ",", "err", ":=", "bot", ".", "UploadFile", "(", "method", ",", "params", ",", "config", ".", "name", "(", ")", ",", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Message", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "message", "Message", "\n", "json", ".", "Unmarshal", "(", "resp", ".", "Result", ",", "&", "message", ")", "\n\n", "bot", ".", "debugLog", "(", "method", ",", "nil", ",", "message", ")", "\n\n", "return", "message", ",", "nil", "\n", "}" ]
// uploadAndSend will send a Message with a new file to Telegram.
[ "uploadAndSend", "will", "send", "a", "Message", "with", "a", "new", "file", "to", "Telegram", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L305-L324
train
go-telegram-bot-api/telegram-bot-api
bot.go
sendFile
func (bot *BotAPI) sendFile(config Fileable) (Message, error) { if config.useExistingFile() { return bot.sendExisting(config.method(), config) } return bot.uploadAndSend(config.method(), config) }
go
func (bot *BotAPI) sendFile(config Fileable) (Message, error) { if config.useExistingFile() { return bot.sendExisting(config.method(), config) } return bot.uploadAndSend(config.method(), config) }
[ "func", "(", "bot", "*", "BotAPI", ")", "sendFile", "(", "config", "Fileable", ")", "(", "Message", ",", "error", ")", "{", "if", "config", ".", "useExistingFile", "(", ")", "{", "return", "bot", ".", "sendExisting", "(", "config", ".", "method", "(", ")", ",", "config", ")", "\n", "}", "\n\n", "return", "bot", ".", "uploadAndSend", "(", "config", ".", "method", "(", ")", ",", "config", ")", "\n", "}" ]
// sendFile determines if the file is using an existing file or uploading // a new file, then sends it as needed.
[ "sendFile", "determines", "if", "the", "file", "is", "using", "an", "existing", "file", "or", "uploading", "a", "new", "file", "then", "sends", "it", "as", "needed", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L328-L334
train
go-telegram-bot-api/telegram-bot-api
bot.go
sendChattable
func (bot *BotAPI) sendChattable(config Chattable) (Message, error) { v, err := config.values() if err != nil { return Message{}, err } message, err := bot.makeMessageRequest(config.method(), v) if err != nil { return Message{}, err } return message, nil }
go
func (bot *BotAPI) sendChattable(config Chattable) (Message, error) { v, err := config.values() if err != nil { return Message{}, err } message, err := bot.makeMessageRequest(config.method(), v) if err != nil { return Message{}, err } return message, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "sendChattable", "(", "config", "Chattable", ")", "(", "Message", ",", "error", ")", "{", "v", ",", "err", ":=", "config", ".", "values", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Message", "{", "}", ",", "err", "\n", "}", "\n\n", "message", ",", "err", ":=", "bot", ".", "makeMessageRequest", "(", "config", ".", "method", "(", ")", ",", "v", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "Message", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "message", ",", "nil", "\n", "}" ]
// sendChattable sends a Chattable.
[ "sendChattable", "sends", "a", "Chattable", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L337-L350
train
go-telegram-bot-api/telegram-bot-api
bot.go
GetUserProfilePhotos
func (bot *BotAPI) GetUserProfilePhotos(config UserProfilePhotosConfig) (UserProfilePhotos, error) { v := url.Values{} v.Add("user_id", strconv.Itoa(config.UserID)) if config.Offset != 0 { v.Add("offset", strconv.Itoa(config.Offset)) } if config.Limit != 0 { v.Add("limit", strconv.Itoa(config.Limit)) } resp, err := bot.MakeRequest("getUserProfilePhotos", v) if err != nil { return UserProfilePhotos{}, err } var profilePhotos UserProfilePhotos json.Unmarshal(resp.Result, &profilePhotos) bot.debugLog("GetUserProfilePhoto", v, profilePhotos) return profilePhotos, nil }
go
func (bot *BotAPI) GetUserProfilePhotos(config UserProfilePhotosConfig) (UserProfilePhotos, error) { v := url.Values{} v.Add("user_id", strconv.Itoa(config.UserID)) if config.Offset != 0 { v.Add("offset", strconv.Itoa(config.Offset)) } if config.Limit != 0 { v.Add("limit", strconv.Itoa(config.Limit)) } resp, err := bot.MakeRequest("getUserProfilePhotos", v) if err != nil { return UserProfilePhotos{}, err } var profilePhotos UserProfilePhotos json.Unmarshal(resp.Result, &profilePhotos) bot.debugLog("GetUserProfilePhoto", v, profilePhotos) return profilePhotos, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "GetUserProfilePhotos", "(", "config", "UserProfilePhotosConfig", ")", "(", "UserProfilePhotos", ",", "error", ")", "{", "v", ":=", "url", ".", "Values", "{", "}", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "UserID", ")", ")", "\n", "if", "config", ".", "Offset", "!=", "0", "{", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "Offset", ")", ")", "\n", "}", "\n", "if", "config", ".", "Limit", "!=", "0", "{", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "Limit", ")", ")", "\n", "}", "\n\n", "resp", ",", "err", ":=", "bot", ".", "MakeRequest", "(", "\"", "\"", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "UserProfilePhotos", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "profilePhotos", "UserProfilePhotos", "\n", "json", ".", "Unmarshal", "(", "resp", ".", "Result", ",", "&", "profilePhotos", ")", "\n\n", "bot", ".", "debugLog", "(", "\"", "\"", ",", "v", ",", "profilePhotos", ")", "\n\n", "return", "profilePhotos", ",", "nil", "\n", "}" ]
// GetUserProfilePhotos gets a user's profile photos. // // It requires UserID. // Offset and Limit are optional.
[ "GetUserProfilePhotos", "gets", "a", "user", "s", "profile", "photos", ".", "It", "requires", "UserID", ".", "Offset", "and", "Limit", "are", "optional", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L356-L377
train
go-telegram-bot-api/telegram-bot-api
bot.go
GetFile
func (bot *BotAPI) GetFile(config FileConfig) (File, error) { v := url.Values{} v.Add("file_id", config.FileID) resp, err := bot.MakeRequest("getFile", v) if err != nil { return File{}, err } var file File json.Unmarshal(resp.Result, &file) bot.debugLog("GetFile", v, file) return file, nil }
go
func (bot *BotAPI) GetFile(config FileConfig) (File, error) { v := url.Values{} v.Add("file_id", config.FileID) resp, err := bot.MakeRequest("getFile", v) if err != nil { return File{}, err } var file File json.Unmarshal(resp.Result, &file) bot.debugLog("GetFile", v, file) return file, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "GetFile", "(", "config", "FileConfig", ")", "(", "File", ",", "error", ")", "{", "v", ":=", "url", ".", "Values", "{", "}", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "FileID", ")", "\n\n", "resp", ",", "err", ":=", "bot", ".", "MakeRequest", "(", "\"", "\"", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "File", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "file", "File", "\n", "json", ".", "Unmarshal", "(", "resp", ".", "Result", ",", "&", "file", ")", "\n\n", "bot", ".", "debugLog", "(", "\"", "\"", ",", "v", ",", "file", ")", "\n\n", "return", "file", ",", "nil", "\n", "}" ]
// GetFile returns a File which can download a file from Telegram. // // Requires FileID.
[ "GetFile", "returns", "a", "File", "which", "can", "download", "a", "file", "from", "Telegram", ".", "Requires", "FileID", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L382-L397
train
go-telegram-bot-api/telegram-bot-api
bot.go
GetUpdates
func (bot *BotAPI) GetUpdates(config UpdateConfig) ([]Update, error) { v := url.Values{} if config.Offset != 0 { v.Add("offset", strconv.Itoa(config.Offset)) } if config.Limit > 0 { v.Add("limit", strconv.Itoa(config.Limit)) } if config.Timeout > 0 { v.Add("timeout", strconv.Itoa(config.Timeout)) } resp, err := bot.MakeRequest("getUpdates", v) if err != nil { return []Update{}, err } var updates []Update json.Unmarshal(resp.Result, &updates) bot.debugLog("getUpdates", v, updates) return updates, nil }
go
func (bot *BotAPI) GetUpdates(config UpdateConfig) ([]Update, error) { v := url.Values{} if config.Offset != 0 { v.Add("offset", strconv.Itoa(config.Offset)) } if config.Limit > 0 { v.Add("limit", strconv.Itoa(config.Limit)) } if config.Timeout > 0 { v.Add("timeout", strconv.Itoa(config.Timeout)) } resp, err := bot.MakeRequest("getUpdates", v) if err != nil { return []Update{}, err } var updates []Update json.Unmarshal(resp.Result, &updates) bot.debugLog("getUpdates", v, updates) return updates, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "GetUpdates", "(", "config", "UpdateConfig", ")", "(", "[", "]", "Update", ",", "error", ")", "{", "v", ":=", "url", ".", "Values", "{", "}", "\n", "if", "config", ".", "Offset", "!=", "0", "{", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "Offset", ")", ")", "\n", "}", "\n", "if", "config", ".", "Limit", ">", "0", "{", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "Limit", ")", ")", "\n", "}", "\n", "if", "config", ".", "Timeout", ">", "0", "{", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "Timeout", ")", ")", "\n", "}", "\n\n", "resp", ",", "err", ":=", "bot", ".", "MakeRequest", "(", "\"", "\"", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "Update", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "updates", "[", "]", "Update", "\n", "json", ".", "Unmarshal", "(", "resp", ".", "Result", ",", "&", "updates", ")", "\n\n", "bot", ".", "debugLog", "(", "\"", "\"", ",", "v", ",", "updates", ")", "\n\n", "return", "updates", ",", "nil", "\n", "}" ]
// GetUpdates fetches updates. // If a WebHook is set, this will not return any data! // // Offset, Limit, and Timeout are optional. // To avoid stale items, set Offset to one higher than the previous item. // Set Timeout to a large number to reduce requests so you can get updates // instantly instead of having to wait between requests.
[ "GetUpdates", "fetches", "updates", ".", "If", "a", "WebHook", "is", "set", "this", "will", "not", "return", "any", "data!", "Offset", "Limit", "and", "Timeout", "are", "optional", ".", "To", "avoid", "stale", "items", "set", "Offset", "to", "one", "higher", "than", "the", "previous", "item", ".", "Set", "Timeout", "to", "a", "large", "number", "to", "reduce", "requests", "so", "you", "can", "get", "updates", "instantly", "instead", "of", "having", "to", "wait", "between", "requests", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L406-L429
train
go-telegram-bot-api/telegram-bot-api
bot.go
SetWebhook
func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error) { if config.Certificate == nil { v := url.Values{} v.Add("url", config.URL.String()) if config.MaxConnections != 0 { v.Add("max_connections", strconv.Itoa(config.MaxConnections)) } return bot.MakeRequest("setWebhook", v) } params := make(map[string]string) params["url"] = config.URL.String() if config.MaxConnections != 0 { params["max_connections"] = strconv.Itoa(config.MaxConnections) } resp, err := bot.UploadFile("setWebhook", params, "certificate", config.Certificate) if err != nil { return APIResponse{}, err } return resp, nil }
go
func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error) { if config.Certificate == nil { v := url.Values{} v.Add("url", config.URL.String()) if config.MaxConnections != 0 { v.Add("max_connections", strconv.Itoa(config.MaxConnections)) } return bot.MakeRequest("setWebhook", v) } params := make(map[string]string) params["url"] = config.URL.String() if config.MaxConnections != 0 { params["max_connections"] = strconv.Itoa(config.MaxConnections) } resp, err := bot.UploadFile("setWebhook", params, "certificate", config.Certificate) if err != nil { return APIResponse{}, err } return resp, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "SetWebhook", "(", "config", "WebhookConfig", ")", "(", "APIResponse", ",", "error", ")", "{", "if", "config", ".", "Certificate", "==", "nil", "{", "v", ":=", "url", ".", "Values", "{", "}", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "URL", ".", "String", "(", ")", ")", "\n", "if", "config", ".", "MaxConnections", "!=", "0", "{", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "MaxConnections", ")", ")", "\n", "}", "\n\n", "return", "bot", ".", "MakeRequest", "(", "\"", "\"", ",", "v", ")", "\n", "}", "\n\n", "params", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "params", "[", "\"", "\"", "]", "=", "config", ".", "URL", ".", "String", "(", ")", "\n", "if", "config", ".", "MaxConnections", "!=", "0", "{", "params", "[", "\"", "\"", "]", "=", "strconv", ".", "Itoa", "(", "config", ".", "MaxConnections", ")", "\n", "}", "\n\n", "resp", ",", "err", ":=", "bot", ".", "UploadFile", "(", "\"", "\"", ",", "params", ",", "\"", "\"", ",", "config", ".", "Certificate", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "resp", ",", "nil", "\n", "}" ]
// SetWebhook sets a webhook. // // If this is set, GetUpdates will not get any data! // // If you do not have a legitimate TLS certificate, you need to include // your self signed certificate with the config.
[ "SetWebhook", "sets", "a", "webhook", ".", "If", "this", "is", "set", "GetUpdates", "will", "not", "get", "any", "data!", "If", "you", "do", "not", "have", "a", "legitimate", "TLS", "certificate", "you", "need", "to", "include", "your", "self", "signed", "certificate", "with", "the", "config", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L442-L466
train
go-telegram-bot-api/telegram-bot-api
bot.go
GetWebhookInfo
func (bot *BotAPI) GetWebhookInfo() (WebhookInfo, error) { resp, err := bot.MakeRequest("getWebhookInfo", url.Values{}) if err != nil { return WebhookInfo{}, err } var info WebhookInfo err = json.Unmarshal(resp.Result, &info) return info, err }
go
func (bot *BotAPI) GetWebhookInfo() (WebhookInfo, error) { resp, err := bot.MakeRequest("getWebhookInfo", url.Values{}) if err != nil { return WebhookInfo{}, err } var info WebhookInfo err = json.Unmarshal(resp.Result, &info) return info, err }
[ "func", "(", "bot", "*", "BotAPI", ")", "GetWebhookInfo", "(", ")", "(", "WebhookInfo", ",", "error", ")", "{", "resp", ",", "err", ":=", "bot", ".", "MakeRequest", "(", "\"", "\"", ",", "url", ".", "Values", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "WebhookInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "info", "WebhookInfo", "\n", "err", "=", "json", ".", "Unmarshal", "(", "resp", ".", "Result", ",", "&", "info", ")", "\n\n", "return", "info", ",", "err", "\n", "}" ]
// GetWebhookInfo allows you to fetch information about a webhook and if // one currently is set, along with pending update count and error messages.
[ "GetWebhookInfo", "allows", "you", "to", "fetch", "information", "about", "a", "webhook", "and", "if", "one", "currently", "is", "set", "along", "with", "pending", "update", "count", "and", "error", "messages", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L470-L480
train
go-telegram-bot-api/telegram-bot-api
bot.go
GetUpdatesChan
func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (UpdatesChannel, error) { ch := make(chan Update, bot.Buffer) go func() { for { select { case <-bot.shutdownChannel: return default: } updates, err := bot.GetUpdates(config) if err != nil { log.Println(err) log.Println("Failed to get updates, retrying in 3 seconds...") time.Sleep(time.Second * 3) continue } for _, update := range updates { if update.UpdateID >= config.Offset { config.Offset = update.UpdateID + 1 ch <- update } } } }() return ch, nil }
go
func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (UpdatesChannel, error) { ch := make(chan Update, bot.Buffer) go func() { for { select { case <-bot.shutdownChannel: return default: } updates, err := bot.GetUpdates(config) if err != nil { log.Println(err) log.Println("Failed to get updates, retrying in 3 seconds...") time.Sleep(time.Second * 3) continue } for _, update := range updates { if update.UpdateID >= config.Offset { config.Offset = update.UpdateID + 1 ch <- update } } } }() return ch, nil }
[ "func", "(", "bot", "*", "BotAPI", ")", "GetUpdatesChan", "(", "config", "UpdateConfig", ")", "(", "UpdatesChannel", ",", "error", ")", "{", "ch", ":=", "make", "(", "chan", "Update", ",", "bot", ".", "Buffer", ")", "\n\n", "go", "func", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "bot", ".", "shutdownChannel", ":", "return", "\n", "default", ":", "}", "\n", "updates", ",", "err", ":=", "bot", ".", "GetUpdates", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Println", "(", "err", ")", "\n", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "time", ".", "Sleep", "(", "time", ".", "Second", "*", "3", ")", "\n\n", "continue", "\n", "}", "\n\n", "for", "_", ",", "update", ":=", "range", "updates", "{", "if", "update", ".", "UpdateID", ">=", "config", ".", "Offset", "{", "config", ".", "Offset", "=", "update", ".", "UpdateID", "+", "1", "\n", "ch", "<-", "update", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n\n", "return", "ch", ",", "nil", "\n", "}" ]
// GetUpdatesChan starts and returns a channel for getting updates.
[ "GetUpdatesChan", "starts", "and", "returns", "a", "channel", "for", "getting", "updates", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L483-L513
train
go-telegram-bot-api/telegram-bot-api
bot.go
StopReceivingUpdates
func (bot *BotAPI) StopReceivingUpdates() { if bot.Debug { log.Println("Stopping the update receiver routine...") } close(bot.shutdownChannel) }
go
func (bot *BotAPI) StopReceivingUpdates() { if bot.Debug { log.Println("Stopping the update receiver routine...") } close(bot.shutdownChannel) }
[ "func", "(", "bot", "*", "BotAPI", ")", "StopReceivingUpdates", "(", ")", "{", "if", "bot", ".", "Debug", "{", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "\n", "close", "(", "bot", ".", "shutdownChannel", ")", "\n", "}" ]
// StopReceivingUpdates stops the go routine which receives updates
[ "StopReceivingUpdates", "stops", "the", "go", "routine", "which", "receives", "updates" ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L516-L521
train
go-telegram-bot-api/telegram-bot-api
bot.go
ListenForWebhook
func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel { ch := make(chan Update, bot.Buffer) http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) { bytes, _ := ioutil.ReadAll(r.Body) r.Body.Close() var update Update json.Unmarshal(bytes, &update) ch <- update }) return ch }
go
func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel { ch := make(chan Update, bot.Buffer) http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) { bytes, _ := ioutil.ReadAll(r.Body) r.Body.Close() var update Update json.Unmarshal(bytes, &update) ch <- update }) return ch }
[ "func", "(", "bot", "*", "BotAPI", ")", "ListenForWebhook", "(", "pattern", "string", ")", "UpdatesChannel", "{", "ch", ":=", "make", "(", "chan", "Update", ",", "bot", ".", "Buffer", ")", "\n\n", "http", ".", "HandleFunc", "(", "pattern", ",", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "bytes", ",", "_", ":=", "ioutil", ".", "ReadAll", "(", "r", ".", "Body", ")", "\n", "r", ".", "Body", ".", "Close", "(", ")", "\n\n", "var", "update", "Update", "\n", "json", ".", "Unmarshal", "(", "bytes", ",", "&", "update", ")", "\n\n", "ch", "<-", "update", "\n", "}", ")", "\n\n", "return", "ch", "\n", "}" ]
// ListenForWebhook registers a http handler for a webhook.
[ "ListenForWebhook", "registers", "a", "http", "handler", "for", "a", "webhook", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L524-L538
train
go-telegram-bot-api/telegram-bot-api
bot.go
AnswerInlineQuery
func (bot *BotAPI) AnswerInlineQuery(config InlineConfig) (APIResponse, error) { v := url.Values{} v.Add("inline_query_id", config.InlineQueryID) v.Add("cache_time", strconv.Itoa(config.CacheTime)) v.Add("is_personal", strconv.FormatBool(config.IsPersonal)) v.Add("next_offset", config.NextOffset) data, err := json.Marshal(config.Results) if err != nil { return APIResponse{}, err } v.Add("results", string(data)) v.Add("switch_pm_text", config.SwitchPMText) v.Add("switch_pm_parameter", config.SwitchPMParameter) bot.debugLog("answerInlineQuery", v, nil) return bot.MakeRequest("answerInlineQuery", v) }
go
func (bot *BotAPI) AnswerInlineQuery(config InlineConfig) (APIResponse, error) { v := url.Values{} v.Add("inline_query_id", config.InlineQueryID) v.Add("cache_time", strconv.Itoa(config.CacheTime)) v.Add("is_personal", strconv.FormatBool(config.IsPersonal)) v.Add("next_offset", config.NextOffset) data, err := json.Marshal(config.Results) if err != nil { return APIResponse{}, err } v.Add("results", string(data)) v.Add("switch_pm_text", config.SwitchPMText) v.Add("switch_pm_parameter", config.SwitchPMParameter) bot.debugLog("answerInlineQuery", v, nil) return bot.MakeRequest("answerInlineQuery", v) }
[ "func", "(", "bot", "*", "BotAPI", ")", "AnswerInlineQuery", "(", "config", "InlineConfig", ")", "(", "APIResponse", ",", "error", ")", "{", "v", ":=", "url", ".", "Values", "{", "}", "\n\n", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "InlineQueryID", ")", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "CacheTime", ")", ")", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "FormatBool", "(", "config", ".", "IsPersonal", ")", ")", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "NextOffset", ")", "\n", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "config", ".", "Results", ")", "\n", "if", "err", "!=", "nil", "{", "return", "APIResponse", "{", "}", ",", "err", "\n", "}", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "string", "(", "data", ")", ")", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "SwitchPMText", ")", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "SwitchPMParameter", ")", "\n\n", "bot", ".", "debugLog", "(", "\"", "\"", ",", "v", ",", "nil", ")", "\n\n", "return", "bot", ".", "MakeRequest", "(", "\"", "\"", ",", "v", ")", "\n", "}" ]
// AnswerInlineQuery sends a response to an inline query. // // Note that you must respond to an inline query within 30 seconds.
[ "AnswerInlineQuery", "sends", "a", "response", "to", "an", "inline", "query", ".", "Note", "that", "you", "must", "respond", "to", "an", "inline", "query", "within", "30", "seconds", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L543-L561
train
go-telegram-bot-api/telegram-bot-api
bot.go
AnswerCallbackQuery
func (bot *BotAPI) AnswerCallbackQuery(config CallbackConfig) (APIResponse, error) { v := url.Values{} v.Add("callback_query_id", config.CallbackQueryID) if config.Text != "" { v.Add("text", config.Text) } v.Add("show_alert", strconv.FormatBool(config.ShowAlert)) if config.URL != "" { v.Add("url", config.URL) } v.Add("cache_time", strconv.Itoa(config.CacheTime)) bot.debugLog("answerCallbackQuery", v, nil) return bot.MakeRequest("answerCallbackQuery", v) }
go
func (bot *BotAPI) AnswerCallbackQuery(config CallbackConfig) (APIResponse, error) { v := url.Values{} v.Add("callback_query_id", config.CallbackQueryID) if config.Text != "" { v.Add("text", config.Text) } v.Add("show_alert", strconv.FormatBool(config.ShowAlert)) if config.URL != "" { v.Add("url", config.URL) } v.Add("cache_time", strconv.Itoa(config.CacheTime)) bot.debugLog("answerCallbackQuery", v, nil) return bot.MakeRequest("answerCallbackQuery", v) }
[ "func", "(", "bot", "*", "BotAPI", ")", "AnswerCallbackQuery", "(", "config", "CallbackConfig", ")", "(", "APIResponse", ",", "error", ")", "{", "v", ":=", "url", ".", "Values", "{", "}", "\n\n", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "CallbackQueryID", ")", "\n", "if", "config", ".", "Text", "!=", "\"", "\"", "{", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "Text", ")", "\n", "}", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "FormatBool", "(", "config", ".", "ShowAlert", ")", ")", "\n", "if", "config", ".", "URL", "!=", "\"", "\"", "{", "v", ".", "Add", "(", "\"", "\"", ",", "config", ".", "URL", ")", "\n", "}", "\n", "v", ".", "Add", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "config", ".", "CacheTime", ")", ")", "\n\n", "bot", ".", "debugLog", "(", "\"", "\"", ",", "v", ",", "nil", ")", "\n\n", "return", "bot", ".", "MakeRequest", "(", "\"", "\"", ",", "v", ")", "\n", "}" ]
// AnswerCallbackQuery sends a response to an inline query callback.
[ "AnswerCallbackQuery", "sends", "a", "response", "to", "an", "inline", "query", "callback", "." ]
87e7035a900c7cb1fd896e5f33b461c96c3ac31e
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/bot.go#L564-L580
train