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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
hashicorp/hcl
json/scanner/scanner.go
err
func (s *Scanner) err(msg string) { s.ErrorCount++ pos := s.recentPosition() if s.Error != nil { s.Error(pos, msg) return } fmt.Fprintf(os.Stderr, "%s: %s\n", pos, msg) }
go
func (s *Scanner) err(msg string) { s.ErrorCount++ pos := s.recentPosition() if s.Error != nil { s.Error(pos, msg) return } fmt.Fprintf(os.Stderr, "%s: %s\n", pos, msg) }
[ "func", "(", "s", "*", "Scanner", ")", "err", "(", "msg", "string", ")", "{", "s", ".", "ErrorCount", "++", "\n", "pos", ":=", "s", ".", "recentPosition", "(", ")", "\n\n", "if", "s", ".", "Error", "!=", "nil", "{", "s", ".", "Error", "(", "pos...
// err prints the error of any scanning to s.Error function. If the function is // not defined, by default it prints them to os.Stderr
[ "err", "prints", "the", "error", "of", "any", "scanning", "to", "s", ".", "Error", "function", ".", "If", "the", "function", "is", "not", "defined", "by", "default", "it", "prints", "them", "to", "os", ".", "Stderr" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L403-L413
train
hashicorp/hcl
json/scanner/scanner.go
isDigit
func isDigit(ch rune) bool { return '0' <= ch && ch <= '9' || ch >= 0x80 && unicode.IsDigit(ch) }
go
func isDigit(ch rune) bool { return '0' <= ch && ch <= '9' || ch >= 0x80 && unicode.IsDigit(ch) }
[ "func", "isDigit", "(", "ch", "rune", ")", "bool", "{", "return", "'0'", "<=", "ch", "&&", "ch", "<=", "'9'", "||", "ch", ">=", "0x80", "&&", "unicode", ".", "IsDigit", "(", "ch", ")", "\n", "}" ]
// isHexadecimal returns true if the given rune is a decimal digit
[ "isHexadecimal", "returns", "true", "if", "the", "given", "rune", "is", "a", "decimal", "digit" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L421-L423
train
hashicorp/hcl
json/scanner/scanner.go
isHexadecimal
func isHexadecimal(ch rune) bool { return '0' <= ch && ch <= '9' || 'a' <= ch && ch <= 'f' || 'A' <= ch && ch <= 'F' }
go
func isHexadecimal(ch rune) bool { return '0' <= ch && ch <= '9' || 'a' <= ch && ch <= 'f' || 'A' <= ch && ch <= 'F' }
[ "func", "isHexadecimal", "(", "ch", "rune", ")", "bool", "{", "return", "'0'", "<=", "ch", "&&", "ch", "<=", "'9'", "||", "'a'", "<=", "ch", "&&", "ch", "<=", "'f'", "||", "'A'", "<=", "ch", "&&", "ch", "<=", "'F'", "\n", "}" ]
// isHexadecimal returns true if the given rune is an hexadecimal number
[ "isHexadecimal", "returns", "true", "if", "the", "given", "rune", "is", "an", "hexadecimal", "number" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L431-L433
train
hashicorp/hcl
hcl/token/position.go
Before
func (p Pos) Before(u Pos) bool { return u.Offset > p.Offset || u.Line > p.Line }
go
func (p Pos) Before(u Pos) bool { return u.Offset > p.Offset || u.Line > p.Line }
[ "func", "(", "p", "Pos", ")", "Before", "(", "u", "Pos", ")", "bool", "{", "return", "u", ".", "Offset", ">", "p", ".", "Offset", "||", "u", ".", "Line", ">", "p", ".", "Line", "\n", "}" ]
// Before reports whether the position p is before u.
[ "Before", "reports", "whether", "the", "position", "p", "is", "before", "u", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/token/position.go#L39-L41
train
hashicorp/hcl
hcl/token/position.go
After
func (p Pos) After(u Pos) bool { return u.Offset < p.Offset || u.Line < p.Line }
go
func (p Pos) After(u Pos) bool { return u.Offset < p.Offset || u.Line < p.Line }
[ "func", "(", "p", "Pos", ")", "After", "(", "u", "Pos", ")", "bool", "{", "return", "u", ".", "Offset", "<", "p", ".", "Offset", "||", "u", ".", "Line", "<", "p", ".", "Line", "\n", "}" ]
// After reports whether the position p is after u.
[ "After", "reports", "whether", "the", "position", "p", "is", "after", "u", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/token/position.go#L44-L46
train
hashicorp/hcl
decoder.go
Unmarshal
func Unmarshal(bs []byte, v interface{}) error { root, err := parse(bs) if err != nil { return err } return DecodeObject(v, root) }
go
func Unmarshal(bs []byte, v interface{}) error { root, err := parse(bs) if err != nil { return err } return DecodeObject(v, root) }
[ "func", "Unmarshal", "(", "bs", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "error", "{", "root", ",", "err", ":=", "parse", "(", "bs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "DecodeObj...
// Unmarshal accepts a byte slice as input and writes the // data to the value pointed to by v.
[ "Unmarshal", "accepts", "a", "byte", "slice", "as", "input", "and", "writes", "the", "data", "to", "the", "value", "pointed", "to", "by", "v", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/decoder.go#L26-L33
train
hashicorp/hcl
decoder.go
Decode
func Decode(out interface{}, in string) error { obj, err := Parse(in) if err != nil { return err } return DecodeObject(out, obj) }
go
func Decode(out interface{}, in string) error { obj, err := Parse(in) if err != nil { return err } return DecodeObject(out, obj) }
[ "func", "Decode", "(", "out", "interface", "{", "}", ",", "in", "string", ")", "error", "{", "obj", ",", "err", ":=", "Parse", "(", "in", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "DecodeObject", "(", ...
// Decode reads the given input and decodes it into the structure // given by `out`.
[ "Decode", "reads", "the", "given", "input", "and", "decodes", "it", "into", "the", "structure", "given", "by", "out", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/decoder.go#L37-L44
train
hashicorp/hcl
decoder.go
DecodeObject
func DecodeObject(out interface{}, n ast.Node) error { val := reflect.ValueOf(out) if val.Kind() != reflect.Ptr { return errors.New("result must be a pointer") } // If we have the file, we really decode the root node if f, ok := n.(*ast.File); ok { n = f.Node } var d decoder return d.decode("root", n, val...
go
func DecodeObject(out interface{}, n ast.Node) error { val := reflect.ValueOf(out) if val.Kind() != reflect.Ptr { return errors.New("result must be a pointer") } // If we have the file, we really decode the root node if f, ok := n.(*ast.File); ok { n = f.Node } var d decoder return d.decode("root", n, val...
[ "func", "DecodeObject", "(", "out", "interface", "{", "}", ",", "n", "ast", ".", "Node", ")", "error", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "out", ")", "\n", "if", "val", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "{", "retu...
// DecodeObject is a lower-level version of Decode. It decodes a // raw Object into the given output.
[ "DecodeObject", "is", "a", "lower", "-", "level", "version", "of", "Decode", ".", "It", "decodes", "a", "raw", "Object", "into", "the", "given", "output", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/decoder.go#L48-L61
train
hashicorp/hcl
decoder.go
expandObject
func expandObject(node ast.Node, result reflect.Value) ast.Node { item, ok := node.(*ast.ObjectItem) if !ok { return node } elemType := result.Type() // our target type must be a struct switch elemType.Kind() { case reflect.Ptr: switch elemType.Elem().Kind() { case reflect.Struct: //OK default: r...
go
func expandObject(node ast.Node, result reflect.Value) ast.Node { item, ok := node.(*ast.ObjectItem) if !ok { return node } elemType := result.Type() // our target type must be a struct switch elemType.Kind() { case reflect.Ptr: switch elemType.Elem().Kind() { case reflect.Struct: //OK default: r...
[ "func", "expandObject", "(", "node", "ast", ".", "Node", ",", "result", "reflect", ".", "Value", ")", "ast", ".", "Node", "{", "item", ",", "ok", ":=", "node", ".", "(", "*", "ast", ".", "ObjectItem", ")", "\n", "if", "!", "ok", "{", "return", "n...
// expandObject detects if an ambiguous JSON object was flattened to a List which // should be decoded into a struct, and expands the ast to properly deocode.
[ "expandObject", "detects", "if", "an", "ambiguous", "JSON", "object", "was", "flattened", "to", "a", "List", "which", "should", "be", "decoded", "into", "a", "struct", "and", "expands", "the", "ast", "to", "properly", "deocode", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/decoder.go#L485-L532
train
hashicorp/hcl
decoder.go
findNodeType
func findNodeType() reflect.Type { var nodeContainer struct { Node ast.Node } value := reflect.ValueOf(nodeContainer).FieldByName("Node") return value.Type() }
go
func findNodeType() reflect.Type { var nodeContainer struct { Node ast.Node } value := reflect.ValueOf(nodeContainer).FieldByName("Node") return value.Type() }
[ "func", "findNodeType", "(", ")", "reflect", ".", "Type", "{", "var", "nodeContainer", "struct", "{", "Node", "ast", ".", "Node", "\n", "}", "\n", "value", ":=", "reflect", ".", "ValueOf", "(", "nodeContainer", ")", ".", "FieldByName", "(", "\"", "\"", ...
// findNodeType returns the type of ast.Node
[ "findNodeType", "returns", "the", "type", "of", "ast", ".", "Node" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/decoder.go#L752-L758
train
hashicorp/hcl
hcl/scanner/scanner.go
scanHeredoc
func (s *Scanner) scanHeredoc() { // Scan the second '<' in example: '<<EOF' if s.next() != '<' { s.err("heredoc expected second '<', didn't see it") return } // Get the original offset so we can read just the heredoc ident offs := s.srcPos.Offset // Scan the identifier ch := s.next() // Indented heredoc...
go
func (s *Scanner) scanHeredoc() { // Scan the second '<' in example: '<<EOF' if s.next() != '<' { s.err("heredoc expected second '<', didn't see it") return } // Get the original offset so we can read just the heredoc ident offs := s.srcPos.Offset // Scan the identifier ch := s.next() // Indented heredoc...
[ "func", "(", "s", "*", "Scanner", ")", "scanHeredoc", "(", ")", "{", "// Scan the second '<' in example: '<<EOF'", "if", "s", ".", "next", "(", ")", "!=", "'<'", "{", "s", ".", "err", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "// Get the...
// scanHeredoc scans a heredoc string
[ "scanHeredoc", "scans", "a", "heredoc", "string" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/scanner/scanner.go#L393-L474
train
hashicorp/hcl
hcl/scanner/scanner.go
scanString
func (s *Scanner) scanString() { braces := 0 for { // '"' opening already consumed // read character after quote ch := s.next() if (ch == '\n' && braces == 0) || ch < 0 || ch == eof { s.err("literal not terminated") return } if ch == '"' && braces == 0 { break } // If we're going into a ${...
go
func (s *Scanner) scanString() { braces := 0 for { // '"' opening already consumed // read character after quote ch := s.next() if (ch == '\n' && braces == 0) || ch < 0 || ch == eof { s.err("literal not terminated") return } if ch == '"' && braces == 0 { break } // If we're going into a ${...
[ "func", "(", "s", "*", "Scanner", ")", "scanString", "(", ")", "{", "braces", ":=", "0", "\n", "for", "{", "// '\"' opening already consumed", "// read character after quote", "ch", ":=", "s", ".", "next", "(", ")", "\n\n", "if", "(", "ch", "==", "'\\n'", ...
// scanString scans a quoted string
[ "scanString", "scans", "a", "quoted", "string" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/scanner/scanner.go#L477-L510
train
hashicorp/hcl
hcl/parser/parser.go
scan
func (p *Parser) scan() token.Token { // If we have a token on the buffer, then return it. if p.n != 0 { p.n = 0 return p.tok } // Otherwise read the next token from the scanner and Save it to the buffer // in case we unscan later. prev := p.tok p.tok = p.sc.Scan() if p.tok.Type == token.COMMENT { var c...
go
func (p *Parser) scan() token.Token { // If we have a token on the buffer, then return it. if p.n != 0 { p.n = 0 return p.tok } // Otherwise read the next token from the scanner and Save it to the buffer // in case we unscan later. prev := p.tok p.tok = p.sc.Scan() if p.tok.Type == token.COMMENT { var c...
[ "func", "(", "p", "*", "Parser", ")", "scan", "(", ")", "token", ".", "Token", "{", "// If we have a token on the buffer, then return it.", "if", "p", ".", "n", "!=", "0", "{", "p", ".", "n", "=", "0", "\n", "return", "p", ".", "tok", "\n", "}", "\n\...
// scan returns the next token from the underlying scanner. If a token has // been unscanned then read that instead. In the process, it collects any // comment groups encountered, and remembers the last lead and line comments.
[ "scan", "returns", "the", "next", "token", "from", "the", "underlying", "scanner", ".", "If", "a", "token", "has", "been", "unscanned", "then", "read", "that", "instead", ".", "In", "the", "process", "it", "collects", "any", "comment", "groups", "encountered...
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/parser/parser.go#L444-L493
train
hashicorp/hcl
json/parser/parser.go
literalType
func (p *Parser) literalType() (*ast.LiteralType, error) { defer un(trace(p, "ParseLiteral")) return &ast.LiteralType{ Token: p.tok.HCLToken(), }, nil }
go
func (p *Parser) literalType() (*ast.LiteralType, error) { defer un(trace(p, "ParseLiteral")) return &ast.LiteralType{ Token: p.tok.HCLToken(), }, nil }
[ "func", "(", "p", "*", "Parser", ")", "literalType", "(", ")", "(", "*", "ast", ".", "LiteralType", ",", "error", ")", "{", "defer", "un", "(", "trace", "(", "p", ",", "\"", "\"", ")", ")", "\n\n", "return", "&", "ast", ".", "LiteralType", "{", ...
// literalType parses a literal type and returns a LiteralType AST
[ "literalType", "parses", "a", "literal", "type", "and", "returns", "a", "LiteralType", "AST" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/parser/parser.go#L255-L261
train
hashicorp/hcl
json/parser/parser.go
scan
func (p *Parser) scan() token.Token { // If we have a token on the buffer, then return it. if p.n != 0 { p.n = 0 return p.tok } p.tok = p.sc.Scan() return p.tok }
go
func (p *Parser) scan() token.Token { // If we have a token on the buffer, then return it. if p.n != 0 { p.n = 0 return p.tok } p.tok = p.sc.Scan() return p.tok }
[ "func", "(", "p", "*", "Parser", ")", "scan", "(", ")", "token", ".", "Token", "{", "// If we have a token on the buffer, then return it.", "if", "p", ".", "n", "!=", "0", "{", "p", ".", "n", "=", "0", "\n", "return", "p", ".", "tok", "\n", "}", "\n\...
// scan returns the next token from the underlying scanner. If a token has // been unscanned then read that instead.
[ "scan", "returns", "the", "next", "token", "from", "the", "underlying", "scanner", ".", "If", "a", "token", "has", "been", "unscanned", "then", "read", "that", "instead", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/parser/parser.go#L265-L274
train
hashicorp/hcl
hcl/fmtcmd/fmtcmd.go
processFile
func processFile(filename string, in io.Reader, out io.Writer, stdin bool, opts Options) error { if in == nil { f, err := os.Open(filename) if err != nil { return err } defer f.Close() in = f } src, err := ioutil.ReadAll(in) if err != nil { return err } res, err := printer.Format(src) if err != ...
go
func processFile(filename string, in io.Reader, out io.Writer, stdin bool, opts Options) error { if in == nil { f, err := os.Open(filename) if err != nil { return err } defer f.Close() in = f } src, err := ioutil.ReadAll(in) if err != nil { return err } res, err := printer.Format(src) if err != ...
[ "func", "processFile", "(", "filename", "string", ",", "in", "io", ".", "Reader", ",", "out", "io", ".", "Writer", ",", "stdin", "bool", ",", "opts", "Options", ")", "error", "{", "if", "in", "==", "nil", "{", "f", ",", "err", ":=", "os", ".", "O...
// If in == nil, the source is the contents of the file with the given filename.
[ "If", "in", "==", "nil", "the", "source", "is", "the", "contents", "of", "the", "file", "with", "the", "given", "filename", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/fmtcmd/fmtcmd.go#L44-L90
train
hashicorp/hcl
hcl/token/token.go
String
func (t Type) String() string { s := "" if 0 <= t && t < Type(len(tokens)) { s = tokens[t] } if s == "" { s = "token(" + strconv.Itoa(int(t)) + ")" } return s }
go
func (t Type) String() string { s := "" if 0 <= t && t < Type(len(tokens)) { s = tokens[t] } if s == "" { s = "token(" + strconv.Itoa(int(t)) + ")" } return s }
[ "func", "(", "t", "Type", ")", "String", "(", ")", "string", "{", "s", ":=", "\"", "\"", "\n", "if", "0", "<=", "t", "&&", "t", "<", "Type", "(", "len", "(", "tokens", ")", ")", "{", "s", "=", "tokens", "[", "t", "]", "\n", "}", "\n", "if...
// String returns the string corresponding to the token tok.
[ "String", "returns", "the", "string", "corresponding", "to", "the", "token", "tok", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/token/token.go#L83-L92
train
hashicorp/hcl
hcl/token/token.go
String
func (t Token) String() string { return fmt.Sprintf("%s %s %s", t.Pos.String(), t.Type.String(), t.Text) }
go
func (t Token) String() string { return fmt.Sprintf("%s %s %s", t.Pos.String(), t.Type.String(), t.Text) }
[ "func", "(", "t", "Token", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "t", ".", "Pos", ".", "String", "(", ")", ",", "t", ".", "Type", ".", "String", "(", ")", ",", "t", ".", "Text", ")", ...
// String returns the token's literal text. Note that this is only // applicable for certain token types, such as token.IDENT, // token.STRING, etc..
[ "String", "returns", "the", "token", "s", "literal", "text", ".", "Note", "that", "this", "is", "only", "applicable", "for", "certain", "token", "types", "such", "as", "token", ".", "IDENT", "token", ".", "STRING", "etc", ".." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/token/token.go#L109-L111
train
hashicorp/hcl
hcl/token/token.go
unindentHeredoc
func unindentHeredoc(heredoc string) string { // We need to find the end of the marker idx := strings.IndexByte(heredoc, '\n') if idx == -1 { panic("heredoc doesn't contain newline") } unindent := heredoc[2] == '-' // We can optimize if the heredoc isn't marked for indentation if !unindent { return string(...
go
func unindentHeredoc(heredoc string) string { // We need to find the end of the marker idx := strings.IndexByte(heredoc, '\n') if idx == -1 { panic("heredoc doesn't contain newline") } unindent := heredoc[2] == '-' // We can optimize if the heredoc isn't marked for indentation if !unindent { return string(...
[ "func", "unindentHeredoc", "(", "heredoc", "string", ")", "string", "{", "// We need to find the end of the marker", "idx", ":=", "strings", ".", "IndexByte", "(", "heredoc", ",", "'\\n'", ")", "\n", "if", "idx", "==", "-", "1", "{", "panic", "(", "\"", "\""...
// unindentHeredoc returns the string content of a HEREDOC if it is started with << // and the content of a HEREDOC with the hanging indent removed if it is started with // a <<-, and the terminating line is at least as indented as the least indented line.
[ "unindentHeredoc", "returns", "the", "string", "content", "of", "a", "HEREDOC", "if", "it", "is", "started", "with", "<<", "and", "the", "content", "of", "a", "HEREDOC", "with", "the", "hanging", "indent", "removed", "if", "it", "is", "started", "with", "a...
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/token/token.go#L174-L219
train
hashicorp/hcl
hcl/printer/nodes.go
collectComments
func (p *printer) collectComments(node ast.Node) { // first collect all comments. This is already stored in // ast.File.(comments) ast.Walk(node, func(nn ast.Node) (ast.Node, bool) { switch t := nn.(type) { case *ast.File: p.comments = t.Comments return nn, false } return nn, true }) standaloneComme...
go
func (p *printer) collectComments(node ast.Node) { // first collect all comments. This is already stored in // ast.File.(comments) ast.Walk(node, func(nn ast.Node) (ast.Node, bool) { switch t := nn.(type) { case *ast.File: p.comments = t.Comments return nn, false } return nn, true }) standaloneComme...
[ "func", "(", "p", "*", "printer", ")", "collectComments", "(", "node", "ast", ".", "Node", ")", "{", "// first collect all comments. This is already stored in", "// ast.File.(comments)", "ast", ".", "Walk", "(", "node", ",", "func", "(", "nn", "ast", ".", "Node"...
// collectComments comments all standalone comments which are not lead or line // comment
[ "collectComments", "comments", "all", "standalone", "comments", "which", "are", "not", "lead", "or", "line", "comment" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/printer/nodes.go#L42-L106
train
hashicorp/hcl
hcl/printer/nodes.go
list
func (p *printer) list(l *ast.ListType) []byte { if p.isSingleLineList(l) { return p.singleLineList(l) } var buf bytes.Buffer buf.WriteString("[") buf.WriteByte(newline) var longestLine int for _, item := range l.List { // for now we assume that the list only contains literal types if lit, ok := item.(*a...
go
func (p *printer) list(l *ast.ListType) []byte { if p.isSingleLineList(l) { return p.singleLineList(l) } var buf bytes.Buffer buf.WriteString("[") buf.WriteByte(newline) var longestLine int for _, item := range l.List { // for now we assume that the list only contains literal types if lit, ok := item.(*a...
[ "func", "(", "p", "*", "printer", ")", "list", "(", "l", "*", "ast", ".", "ListType", ")", "[", "]", "byte", "{", "if", "p", ".", "isSingleLineList", "(", "l", ")", "{", "return", "p", ".", "singleLineList", "(", "l", ")", "\n", "}", "\n\n", "v...
// list returns the printable HCL form of an list type.
[ "list", "returns", "the", "printable", "HCL", "form", "of", "an", "list", "type", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/printer/nodes.go#L519-L597
train
hashicorp/hcl
hcl/printer/nodes.go
singleLineList
func (p *printer) singleLineList(l *ast.ListType) []byte { buf := &bytes.Buffer{} buf.WriteString("[") for i, item := range l.List { if i != 0 { buf.WriteString(", ") } // Output the item itself buf.Write(p.output(item)) // The heredoc marker needs to be at the end of line. if lit, ok := item.(*ast...
go
func (p *printer) singleLineList(l *ast.ListType) []byte { buf := &bytes.Buffer{} buf.WriteString("[") for i, item := range l.List { if i != 0 { buf.WriteString(", ") } // Output the item itself buf.Write(p.output(item)) // The heredoc marker needs to be at the end of line. if lit, ok := item.(*ast...
[ "func", "(", "p", "*", "printer", ")", "singleLineList", "(", "l", "*", "ast", ".", "ListType", ")", "[", "]", "byte", "{", "buf", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n\n", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "for", ...
// singleLineList prints a simple single line list. // For a definition of "simple", see isSingleLineList above.
[ "singleLineList", "prints", "a", "simple", "single", "line", "list", ".", "For", "a", "definition", "of", "simple", "see", "isSingleLineList", "above", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/printer/nodes.go#L629-L649
train
hashicorp/hcl
hcl/printer/nodes.go
indent
func (p *printer) indent(buf []byte) []byte { var prefix []byte if p.cfg.SpacesWidth != 0 { for i := 0; i < p.cfg.SpacesWidth; i++ { prefix = append(prefix, blank) } } else { prefix = []byte{tab} } var res []byte bol := true for _, c := range buf { if bol && c != '\n' { res = append(res, prefix......
go
func (p *printer) indent(buf []byte) []byte { var prefix []byte if p.cfg.SpacesWidth != 0 { for i := 0; i < p.cfg.SpacesWidth; i++ { prefix = append(prefix, blank) } } else { prefix = []byte{tab} } var res []byte bol := true for _, c := range buf { if bol && c != '\n' { res = append(res, prefix......
[ "func", "(", "p", "*", "printer", ")", "indent", "(", "buf", "[", "]", "byte", ")", "[", "]", "byte", "{", "var", "prefix", "[", "]", "byte", "\n", "if", "p", ".", "cfg", ".", "SpacesWidth", "!=", "0", "{", "for", "i", ":=", "0", ";", "i", ...
// indent indents the lines of the given buffer for each non-empty line
[ "indent", "indents", "the", "lines", "of", "the", "given", "buffer", "for", "each", "non", "-", "empty", "line" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/printer/nodes.go#L652-L673
train
hashicorp/hcl
hcl/printer/nodes.go
unindent
func (p *printer) unindent(buf []byte) []byte { var res []byte for i := 0; i < len(buf); i++ { skip := len(buf)-i <= len(unindent) if !skip { skip = !bytes.Equal(unindent, buf[i:i+len(unindent)]) } if skip { res = append(res, buf[i]) continue } // We have a marker. we have to backtrace here and ...
go
func (p *printer) unindent(buf []byte) []byte { var res []byte for i := 0; i < len(buf); i++ { skip := len(buf)-i <= len(unindent) if !skip { skip = !bytes.Equal(unindent, buf[i:i+len(unindent)]) } if skip { res = append(res, buf[i]) continue } // We have a marker. we have to backtrace here and ...
[ "func", "(", "p", "*", "printer", ")", "unindent", "(", "buf", "[", "]", "byte", ")", "[", "]", "byte", "{", "var", "res", "[", "]", "byte", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "buf", ")", ";", "i", "++", "{", "skip", ...
// unindent removes all the indentation from the tombstoned lines
[ "unindent", "removes", "all", "the", "indentation", "from", "the", "tombstoned", "lines" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/printer/nodes.go#L676-L703
train
hashicorp/hcl
hcl/printer/nodes.go
heredocIndent
func (p *printer) heredocIndent(buf []byte) []byte { var res []byte bol := false for _, c := range buf { if bol && c != '\n' { res = append(res, unindent...) } res = append(res, c) bol = c == '\n' } return res }
go
func (p *printer) heredocIndent(buf []byte) []byte { var res []byte bol := false for _, c := range buf { if bol && c != '\n' { res = append(res, unindent...) } res = append(res, c) bol = c == '\n' } return res }
[ "func", "(", "p", "*", "printer", ")", "heredocIndent", "(", "buf", "[", "]", "byte", ")", "[", "]", "byte", "{", "var", "res", "[", "]", "byte", "\n", "bol", ":=", "false", "\n", "for", "_", ",", "c", ":=", "range", "buf", "{", "if", "bol", ...
// heredocIndent marks all the 2nd and further lines as unindentable
[ "heredocIndent", "marks", "all", "the", "2nd", "and", "further", "lines", "as", "unindentable" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/printer/nodes.go#L706-L717
train
hashicorp/hcl
json/parser/flatten.go
flattenObjects
func flattenObjects(node ast.Node) { ast.Walk(node, func(n ast.Node) (ast.Node, bool) { // We only care about lists, because this is what we modify list, ok := n.(*ast.ObjectList) if !ok { return n, true } // Rebuild the item list items := make([]*ast.ObjectItem, 0, len(list.Items)) frontier := make(...
go
func flattenObjects(node ast.Node) { ast.Walk(node, func(n ast.Node) (ast.Node, bool) { // We only care about lists, because this is what we modify list, ok := n.(*ast.ObjectList) if !ok { return n, true } // Rebuild the item list items := make([]*ast.ObjectItem, 0, len(list.Items)) frontier := make(...
[ "func", "flattenObjects", "(", "node", "ast", ".", "Node", ")", "{", "ast", ".", "Walk", "(", "node", ",", "func", "(", "n", "ast", ".", "Node", ")", "(", "ast", ".", "Node", ",", "bool", ")", "{", "// We only care about lists, because this is what we modi...
// flattenObjects takes an AST node, walks it, and flattens
[ "flattenObjects", "takes", "an", "AST", "node", "walks", "it", "and", "flattens" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/parser/flatten.go#L6-L44
train
hashicorp/hcl
lex.go
lexMode
func lexMode(v []byte) lexModeValue { var ( r rune w int offset int ) for { r, w = utf8.DecodeRune(v[offset:]) offset += w if unicode.IsSpace(r) { continue } if r == '{' { return lexModeJson } break } return lexModeHcl }
go
func lexMode(v []byte) lexModeValue { var ( r rune w int offset int ) for { r, w = utf8.DecodeRune(v[offset:]) offset += w if unicode.IsSpace(r) { continue } if r == '{' { return lexModeJson } break } return lexModeHcl }
[ "func", "lexMode", "(", "v", "[", "]", "byte", ")", "lexModeValue", "{", "var", "(", "r", "rune", "\n", "w", "int", "\n", "offset", "int", "\n", ")", "\n\n", "for", "{", "r", ",", "w", "=", "utf8", ".", "DecodeRune", "(", "v", "[", "offset", ":...
// lexMode returns whether we're going to be parsing in JSON // mode or HCL mode.
[ "lexMode", "returns", "whether", "we", "re", "going", "to", "be", "parsing", "in", "JSON", "mode", "or", "HCL", "mode", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/lex.go#L18-L38
train
hashicorp/hcl
hcl/printer/printer.go
Fprint
func Fprint(output io.Writer, node ast.Node) error { return DefaultConfig.Fprint(output, node) }
go
func Fprint(output io.Writer, node ast.Node) error { return DefaultConfig.Fprint(output, node) }
[ "func", "Fprint", "(", "output", "io", ".", "Writer", ",", "node", "ast", ".", "Node", ")", "error", "{", "return", "DefaultConfig", ".", "Fprint", "(", "output", ",", "node", ")", "\n", "}" ]
// Fprint "pretty-prints" an HCL node to output // It calls Config.Fprint with default settings.
[ "Fprint", "pretty", "-", "prints", "an", "HCL", "node", "to", "output", "It", "calls", "Config", ".", "Fprint", "with", "default", "settings", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/printer/printer.go#L47-L49
train
hashicorp/hcl
hcl/printer/printer.go
Format
func Format(src []byte) ([]byte, error) { node, err := parser.Parse(src) if err != nil { return nil, err } var buf bytes.Buffer if err := DefaultConfig.Fprint(&buf, node); err != nil { return nil, err } // Add trailing newline to result buf.WriteString("\n") return buf.Bytes(), nil }
go
func Format(src []byte) ([]byte, error) { node, err := parser.Parse(src) if err != nil { return nil, err } var buf bytes.Buffer if err := DefaultConfig.Fprint(&buf, node); err != nil { return nil, err } // Add trailing newline to result buf.WriteString("\n") return buf.Bytes(), nil }
[ "func", "Format", "(", "src", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "node", ",", "err", ":=", "parser", ".", "Parse", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}"...
// Format formats src HCL and returns the result.
[ "Format", "formats", "src", "HCL", "and", "returns", "the", "result", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/hcl/printer/printer.go#L52-L66
train
hashicorp/hcl
json/token/token.go
HCLToken
func (t Token) HCLToken() hcltoken.Token { switch t.Type { case BOOL: return hcltoken.Token{Type: hcltoken.BOOL, Text: t.Text} case FLOAT: return hcltoken.Token{Type: hcltoken.FLOAT, Text: t.Text} case NULL: return hcltoken.Token{Type: hcltoken.STRING, Text: ""} case NUMBER: return hcltoken.Token{Type: hcl...
go
func (t Token) HCLToken() hcltoken.Token { switch t.Type { case BOOL: return hcltoken.Token{Type: hcltoken.BOOL, Text: t.Text} case FLOAT: return hcltoken.Token{Type: hcltoken.FLOAT, Text: t.Text} case NULL: return hcltoken.Token{Type: hcltoken.STRING, Text: ""} case NUMBER: return hcltoken.Token{Type: hcl...
[ "func", "(", "t", "Token", ")", "HCLToken", "(", ")", "hcltoken", ".", "Token", "{", "switch", "t", ".", "Type", "{", "case", "BOOL", ":", "return", "hcltoken", ".", "Token", "{", "Type", ":", "hcltoken", ".", "BOOL", ",", "Text", ":", "t", ".", ...
// HCLToken converts this token to an HCL token. // // The token type must be a literal type or this will panic.
[ "HCLToken", "converts", "this", "token", "to", "an", "HCL", "token", ".", "The", "token", "type", "must", "be", "a", "literal", "type", "or", "this", "will", "panic", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/token/token.go#L103-L118
train
42wim/matterbridge
bridge/bridge.go
SetChannelMembers
func (b *Bridge) SetChannelMembers(newMembers *config.ChannelMembers) { b.Lock() b.ChannelMembers = newMembers b.Unlock() }
go
func (b *Bridge) SetChannelMembers(newMembers *config.ChannelMembers) { b.Lock() b.ChannelMembers = newMembers b.Unlock() }
[ "func", "(", "b", "*", "Bridge", ")", "SetChannelMembers", "(", "newMembers", "*", "config", ".", "ChannelMembers", ")", "{", "b", ".", "Lock", "(", ")", "\n", "b", ".", "ChannelMembers", "=", "newMembers", "\n", "b", ".", "Unlock", "(", ")", "\n", "...
// SetChannelMembers sets the newMembers to the bridge ChannelMembers
[ "SetChannelMembers", "sets", "the", "newMembers", "to", "the", "bridge", "ChannelMembers" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/bridge.go#L62-L66
train
42wim/matterbridge
hook/rockethook/rockethook.go
New
func New(url string, config Config) *Client { c := &Client{In: make(chan Message), Config: config} tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, //nolint:gosec } c.httpclient = &http.Client{Transport: tr} _, _, err := net.SplitHostPort(c.BindAddress) if err ...
go
func New(url string, config Config) *Client { c := &Client{In: make(chan Message), Config: config} tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, //nolint:gosec } c.httpclient = &http.Client{Transport: tr} _, _, err := net.SplitHostPort(c.BindAddress) if err ...
[ "func", "New", "(", "url", "string", ",", "config", "Config", ")", "*", "Client", "{", "c", ":=", "&", "Client", "{", "In", ":", "make", "(", "chan", "Message", ")", ",", "Config", ":", "config", "}", "\n", "tr", ":=", "&", "http", ".", "Transpor...
// New Rocketchat client.
[ "New", "Rocketchat", "client", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/hook/rockethook/rockethook.go#L38-L50
train
42wim/matterbridge
matterclient/users.go
GetTeamName
func (m *MMClient) GetTeamName(teamId string) string { //nolint:golint m.RLock() defer m.RUnlock() for _, t := range m.OtherTeams { if t.Id == teamId { return t.Team.Name } } return "" }
go
func (m *MMClient) GetTeamName(teamId string) string { //nolint:golint m.RLock() defer m.RUnlock() for _, t := range m.OtherTeams { if t.Id == teamId { return t.Team.Name } } return "" }
[ "func", "(", "m", "*", "MMClient", ")", "GetTeamName", "(", "teamId", "string", ")", "string", "{", "//nolint:golint", "m", ".", "RLock", "(", ")", "\n", "defer", "m", ".", "RUnlock", "(", ")", "\n", "for", "_", ",", "t", ":=", "range", "m", ".", ...
// GetTeamName returns the name of the specified teamId
[ "GetTeamName", "returns", "the", "name", "of", "the", "specified", "teamId" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/matterclient/users.go#L59-L68
train
42wim/matterbridge
bridge/telegram/handlers.go
handleChannels
func (b *Btelegram) handleChannels(rmsg *config.Message, message *tgbotapi.Message, update tgbotapi.Update) *tgbotapi.Message { return b.handleUpdate(rmsg, message, update.ChannelPost, update.EditedChannelPost) }
go
func (b *Btelegram) handleChannels(rmsg *config.Message, message *tgbotapi.Message, update tgbotapi.Update) *tgbotapi.Message { return b.handleUpdate(rmsg, message, update.ChannelPost, update.EditedChannelPost) }
[ "func", "(", "b", "*", "Btelegram", ")", "handleChannels", "(", "rmsg", "*", "config", ".", "Message", ",", "message", "*", "tgbotapi", ".", "Message", ",", "update", "tgbotapi", ".", "Update", ")", "*", "tgbotapi", ".", "Message", "{", "return", "b", ...
// handleChannels checks if it's a channel message and if the message is a new or edited messages
[ "handleChannels", "checks", "if", "it", "s", "a", "channel", "message", "and", "if", "the", "message", "is", "a", "new", "or", "edited", "messages" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/telegram/handlers.go#L30-L32
train
42wim/matterbridge
bridge/telegram/handlers.go
handleGroups
func (b *Btelegram) handleGroups(rmsg *config.Message, message *tgbotapi.Message, update tgbotapi.Update) *tgbotapi.Message { return b.handleUpdate(rmsg, message, update.Message, update.EditedMessage) }
go
func (b *Btelegram) handleGroups(rmsg *config.Message, message *tgbotapi.Message, update tgbotapi.Update) *tgbotapi.Message { return b.handleUpdate(rmsg, message, update.Message, update.EditedMessage) }
[ "func", "(", "b", "*", "Btelegram", ")", "handleGroups", "(", "rmsg", "*", "config", ".", "Message", ",", "message", "*", "tgbotapi", ".", "Message", ",", "update", "tgbotapi", ".", "Update", ")", "*", "tgbotapi", ".", "Message", "{", "return", "b", "....
// handleGroups checks if it's a group message and if the message is a new or edited messages
[ "handleGroups", "checks", "if", "it", "s", "a", "group", "message", "and", "if", "the", "message", "is", "a", "new", "or", "edited", "messages" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/telegram/handlers.go#L35-L37
train
42wim/matterbridge
bridge/telegram/handlers.go
handleForwarded
func (b *Btelegram) handleForwarded(rmsg *config.Message, message *tgbotapi.Message) { if message.ForwardFrom != nil { usernameForward := "" if b.GetBool("UseFirstName") { usernameForward = message.ForwardFrom.FirstName } if usernameForward == "" { usernameForward = message.ForwardFrom.UserName if use...
go
func (b *Btelegram) handleForwarded(rmsg *config.Message, message *tgbotapi.Message) { if message.ForwardFrom != nil { usernameForward := "" if b.GetBool("UseFirstName") { usernameForward = message.ForwardFrom.FirstName } if usernameForward == "" { usernameForward = message.ForwardFrom.UserName if use...
[ "func", "(", "b", "*", "Btelegram", ")", "handleForwarded", "(", "rmsg", "*", "config", ".", "Message", ",", "message", "*", "tgbotapi", ".", "Message", ")", "{", "if", "message", ".", "ForwardFrom", "!=", "nil", "{", "usernameForward", ":=", "\"", "\"",...
// handleForwarded handles forwarded messages
[ "handleForwarded", "handles", "forwarded", "messages" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/telegram/handlers.go#L40-L57
train
42wim/matterbridge
bridge/telegram/handlers.go
handleQuoting
func (b *Btelegram) handleQuoting(rmsg *config.Message, message *tgbotapi.Message) { if message.ReplyToMessage != nil { usernameReply := "" if message.ReplyToMessage.From != nil { if b.GetBool("UseFirstName") { usernameReply = message.ReplyToMessage.From.FirstName } if usernameReply == "" { userna...
go
func (b *Btelegram) handleQuoting(rmsg *config.Message, message *tgbotapi.Message) { if message.ReplyToMessage != nil { usernameReply := "" if message.ReplyToMessage.From != nil { if b.GetBool("UseFirstName") { usernameReply = message.ReplyToMessage.From.FirstName } if usernameReply == "" { userna...
[ "func", "(", "b", "*", "Btelegram", ")", "handleQuoting", "(", "rmsg", "*", "config", ".", "Message", ",", "message", "*", "tgbotapi", ".", "Message", ")", "{", "if", "message", ".", "ReplyToMessage", "!=", "nil", "{", "usernameReply", ":=", "\"", "\"", ...
// handleQuoting handles quoting of previous messages
[ "handleQuoting", "handles", "quoting", "of", "previous", "messages" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/telegram/handlers.go#L60-L81
train
42wim/matterbridge
bridge/telegram/handlers.go
handleUsername
func (b *Btelegram) handleUsername(rmsg *config.Message, message *tgbotapi.Message) { if message.From != nil { rmsg.UserID = strconv.Itoa(message.From.ID) if b.GetBool("UseFirstName") { rmsg.Username = message.From.FirstName } if rmsg.Username == "" { rmsg.Username = message.From.UserName if rmsg.User...
go
func (b *Btelegram) handleUsername(rmsg *config.Message, message *tgbotapi.Message) { if message.From != nil { rmsg.UserID = strconv.Itoa(message.From.ID) if b.GetBool("UseFirstName") { rmsg.Username = message.From.FirstName } if rmsg.Username == "" { rmsg.Username = message.From.UserName if rmsg.User...
[ "func", "(", "b", "*", "Btelegram", ")", "handleUsername", "(", "rmsg", "*", "config", ".", "Message", ",", "message", "*", "tgbotapi", ".", "Message", ")", "{", "if", "message", ".", "From", "!=", "nil", "{", "rmsg", ".", "UserID", "=", "strconv", "...
// handleUsername handles the correct setting of the username
[ "handleUsername", "handles", "the", "correct", "setting", "of", "the", "username" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/telegram/handlers.go#L84-L106
train
42wim/matterbridge
bridge/telegram/handlers.go
handleDelete
func (b *Btelegram) handleDelete(msg *config.Message, chatid int64) (string, error) { if msg.ID == "" { return "", nil } msgid, err := strconv.Atoi(msg.ID) if err != nil { return "", err } _, err = b.c.DeleteMessage(tgbotapi.DeleteMessageConfig{ChatID: chatid, MessageID: msgid}) return "", err }
go
func (b *Btelegram) handleDelete(msg *config.Message, chatid int64) (string, error) { if msg.ID == "" { return "", nil } msgid, err := strconv.Atoi(msg.ID) if err != nil { return "", err } _, err = b.c.DeleteMessage(tgbotapi.DeleteMessageConfig{ChatID: chatid, MessageID: msgid}) return "", err }
[ "func", "(", "b", "*", "Btelegram", ")", "handleDelete", "(", "msg", "*", "config", ".", "Message", ",", "chatid", "int64", ")", "(", "string", ",", "error", ")", "{", "if", "msg", ".", "ID", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "nil...
// handleDelete handles message deleting
[ "handleDelete", "handles", "message", "deleting" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/telegram/handlers.go#L284-L294
train
42wim/matterbridge
bridge/telegram/handlers.go
handleEdit
func (b *Btelegram) handleEdit(msg *config.Message, chatid int64) (string, error) { msgid, err := strconv.Atoi(msg.ID) if err != nil { return "", err } if strings.ToLower(b.GetString("MessageFormat")) == HTMLNick { b.Log.Debug("Using mode HTML - nick only") msg.Text = html.EscapeString(msg.Text) } m := tgbo...
go
func (b *Btelegram) handleEdit(msg *config.Message, chatid int64) (string, error) { msgid, err := strconv.Atoi(msg.ID) if err != nil { return "", err } if strings.ToLower(b.GetString("MessageFormat")) == HTMLNick { b.Log.Debug("Using mode HTML - nick only") msg.Text = html.EscapeString(msg.Text) } m := tgbo...
[ "func", "(", "b", "*", "Btelegram", ")", "handleEdit", "(", "msg", "*", "config", ".", "Message", ",", "chatid", "int64", ")", "(", "string", ",", "error", ")", "{", "msgid", ",", "err", ":=", "strconv", ".", "Atoi", "(", "msg", ".", "ID", ")", "...
// handleEdit handles message editing.
[ "handleEdit", "handles", "message", "editing", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/telegram/handlers.go#L297-L324
train
42wim/matterbridge
bridge/telegram/handlers.go
handleEntities
func (b *Btelegram) handleEntities(rmsg *config.Message, message *tgbotapi.Message) { if message.Entities == nil { return } // for now only do URL replacements for _, e := range *message.Entities { if e.Type == "text_link" { url, err := e.ParseURL() if err != nil { b.Log.Errorf("entity text_link url p...
go
func (b *Btelegram) handleEntities(rmsg *config.Message, message *tgbotapi.Message) { if message.Entities == nil { return } // for now only do URL replacements for _, e := range *message.Entities { if e.Type == "text_link" { url, err := e.ParseURL() if err != nil { b.Log.Errorf("entity text_link url p...
[ "func", "(", "b", "*", "Btelegram", ")", "handleEntities", "(", "rmsg", "*", "config", ".", "Message", ",", "message", "*", "tgbotapi", ".", "Message", ")", "{", "if", "message", ".", "Entities", "==", "nil", "{", "return", "\n", "}", "\n", "// for now...
// handleEntities handles messageEntities
[ "handleEntities", "handles", "messageEntities" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/telegram/handlers.go#L366-L382
train
42wim/matterbridge
bridge/whatsapp/whatsapp.go
Login
func (b *Bwhatsapp) Login() error { b.Log.Debugln("Logging in..") invert := b.GetBool(qrOnWhiteTerminal) // false is the default qrChan := qrFromTerminal(invert) session, err := b.conn.Login(qrChan) if err != nil { b.Log.Warnln("Failed to log in:", err) return err } b.session = &session b.Log.Infof("Logg...
go
func (b *Bwhatsapp) Login() error { b.Log.Debugln("Logging in..") invert := b.GetBool(qrOnWhiteTerminal) // false is the default qrChan := qrFromTerminal(invert) session, err := b.conn.Login(qrChan) if err != nil { b.Log.Warnln("Failed to log in:", err) return err } b.session = &session b.Log.Infof("Logg...
[ "func", "(", "b", "*", "Bwhatsapp", ")", "Login", "(", ")", "error", "{", "b", ".", "Log", ".", "Debugln", "(", "\"", "\"", ")", "\n\n", "invert", ":=", "b", ".", "GetBool", "(", "qrOnWhiteTerminal", ")", "// false is the default", "\n", "qrChan", ":="...
// Login to WhatsApp creating a new session. This will require to scan a QR code on your mobile device
[ "Login", "to", "WhatsApp", "creating", "a", "new", "session", ".", "This", "will", "require", "to", "scan", "a", "QR", "code", "on", "your", "mobile", "device" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/whatsapp/whatsapp.go#L149-L177
train
42wim/matterbridge
bridge/whatsapp/whatsapp.go
JoinChannel
func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error { byJid := isGroupJid(channel.Name) // verify if we are member of the given group if byJid { // channel.Name specifies static group jID, not the name if _, exists := b.conn.Store.Contacts[channel.Name]; !exists { return fmt.Errorf("account doe...
go
func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error { byJid := isGroupJid(channel.Name) // verify if we are member of the given group if byJid { // channel.Name specifies static group jID, not the name if _, exists := b.conn.Store.Contacts[channel.Name]; !exists { return fmt.Errorf("account doe...
[ "func", "(", "b", "*", "Bwhatsapp", ")", "JoinChannel", "(", "channel", "config", ".", "ChannelInfo", ")", "error", "{", "byJid", ":=", "isGroupJid", "(", "channel", ".", "Name", ")", "\n\n", "// verify if we are member of the given group", "if", "byJid", "{", ...
// JoinChannel Join a WhatsApp group specified in gateway config as channel='number-id@g.us' or channel='Channel name' // Required implementation of the Bridger interface // https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16
[ "JoinChannel", "Join", "a", "WhatsApp", "group", "specified", "in", "gateway", "config", "as", "channel", "=", "number", "-", "id" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/whatsapp/whatsapp.go#L196-L238
train
42wim/matterbridge
bridge/discord/discord.go
useWebhook
func (b *Bdiscord) useWebhook() bool { if b.GetString("WebhookURL") != "" { return true } b.channelsMutex.RLock() defer b.channelsMutex.RUnlock() for _, channel := range b.channelInfoMap { if channel.Options.WebhookURL != "" { return true } } return false }
go
func (b *Bdiscord) useWebhook() bool { if b.GetString("WebhookURL") != "" { return true } b.channelsMutex.RLock() defer b.channelsMutex.RUnlock() for _, channel := range b.channelInfoMap { if channel.Options.WebhookURL != "" { return true } } return false }
[ "func", "(", "b", "*", "Bdiscord", ")", "useWebhook", "(", ")", "bool", "{", "if", "b", ".", "GetString", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "return", "true", "\n", "}", "\n\n", "b", ".", "channelsMutex", ".", "RLock", "(", ")", "\n", ...
// useWebhook returns true if we have a webhook defined somewhere
[ "useWebhook", "returns", "true", "if", "we", "have", "a", "webhook", "defined", "somewhere" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/discord/discord.go#L308-L322
train
42wim/matterbridge
bridge/discord/discord.go
isWebhookID
func (b *Bdiscord) isWebhookID(id string) bool { if b.GetString("WebhookURL") != "" { wID, _ := b.splitURL(b.GetString("WebhookURL")) if wID == id { return true } } b.channelsMutex.RLock() defer b.channelsMutex.RUnlock() for _, channel := range b.channelInfoMap { if channel.Options.WebhookURL != "" { ...
go
func (b *Bdiscord) isWebhookID(id string) bool { if b.GetString("WebhookURL") != "" { wID, _ := b.splitURL(b.GetString("WebhookURL")) if wID == id { return true } } b.channelsMutex.RLock() defer b.channelsMutex.RUnlock() for _, channel := range b.channelInfoMap { if channel.Options.WebhookURL != "" { ...
[ "func", "(", "b", "*", "Bdiscord", ")", "isWebhookID", "(", "id", "string", ")", "bool", "{", "if", "b", ".", "GetString", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "wID", ",", "_", ":=", "b", ".", "splitURL", "(", "b", ".", "GetString", "("...
// isWebhookID returns true if the specified id is used in a defined webhook
[ "isWebhookID", "returns", "true", "if", "the", "specified", "id", "is", "used", "in", "a", "defined", "webhook" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/discord/discord.go#L325-L345
train
42wim/matterbridge
gateway/router.go
NewRouter
func NewRouter(rootLogger *logrus.Logger, cfg config.Config, bridgeMap map[string]bridge.Factory) (*Router, error) { logger := rootLogger.WithFields(logrus.Fields{"prefix": "router"}) r := &Router{ Config: cfg, BridgeMap: bridgeMap, Message: make(chan config.Message), MattermostPlug...
go
func NewRouter(rootLogger *logrus.Logger, cfg config.Config, bridgeMap map[string]bridge.Factory) (*Router, error) { logger := rootLogger.WithFields(logrus.Fields{"prefix": "router"}) r := &Router{ Config: cfg, BridgeMap: bridgeMap, Message: make(chan config.Message), MattermostPlug...
[ "func", "NewRouter", "(", "rootLogger", "*", "logrus", ".", "Logger", ",", "cfg", "config", ".", "Config", ",", "bridgeMap", "map", "[", "string", "]", "bridge", ".", "Factory", ")", "(", "*", "Router", ",", "error", ")", "{", "logger", ":=", "rootLogg...
// NewRouter initializes a new Matterbridge router for the specified configuration and // sets up all required gateways.
[ "NewRouter", "initializes", "a", "new", "Matterbridge", "router", "for", "the", "specified", "configuration", "and", "sets", "up", "all", "required", "gateways", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/router.go#L28-L56
train
42wim/matterbridge
gateway/router.go
Start
func (r *Router) Start() error { m := make(map[string]*bridge.Bridge) for _, gw := range r.Gateways { r.logger.Infof("Parsing gateway %s", gw.Name) for _, br := range gw.Bridges { m[br.Account] = br } } for _, br := range m { r.logger.Infof("Starting bridge: %s ", br.Account) err := br.Connect() if e...
go
func (r *Router) Start() error { m := make(map[string]*bridge.Bridge) for _, gw := range r.Gateways { r.logger.Infof("Parsing gateway %s", gw.Name) for _, br := range gw.Bridges { m[br.Account] = br } } for _, br := range m { r.logger.Infof("Starting bridge: %s ", br.Account) err := br.Connect() if e...
[ "func", "(", "r", "*", "Router", ")", "Start", "(", ")", "error", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "*", "bridge", ".", "Bridge", ")", "\n", "for", "_", ",", "gw", ":=", "range", "r", ".", "Gateways", "{", "r", ".", "log...
// Start will connect all gateways belonging to this router and subsequently route messages // between them.
[ "Start", "will", "connect", "all", "gateways", "belonging", "to", "this", "router", "and", "subsequently", "route", "messages", "between", "them", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/router.go#L60-L99
train
42wim/matterbridge
gateway/router.go
disableBridge
func (r *Router) disableBridge(br *bridge.Bridge, err error) bool { if r.BridgeValues().General.IgnoreFailureOnStart { r.logger.Error(err) // setting this bridge empty *br = bridge.Bridge{} return true } return false }
go
func (r *Router) disableBridge(br *bridge.Bridge, err error) bool { if r.BridgeValues().General.IgnoreFailureOnStart { r.logger.Error(err) // setting this bridge empty *br = bridge.Bridge{} return true } return false }
[ "func", "(", "r", "*", "Router", ")", "disableBridge", "(", "br", "*", "bridge", ".", "Bridge", ",", "err", "error", ")", "bool", "{", "if", "r", ".", "BridgeValues", "(", ")", ".", "General", ".", "IgnoreFailureOnStart", "{", "r", ".", "logger", "."...
// disableBridge returns true and empties a bridge if we have IgnoreFailureOnStart configured // otherwise returns false
[ "disableBridge", "returns", "true", "and", "empties", "a", "bridge", "if", "we", "have", "IgnoreFailureOnStart", "configured", "otherwise", "returns", "false" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/router.go#L103-L111
train
42wim/matterbridge
gateway/router.go
updateChannelMembers
func (r *Router) updateChannelMembers() { // TODO sleep a minute because slack can take a while // fix this by having actually connectionDone events send to the router time.Sleep(time.Minute) for { for _, gw := range r.Gateways { for _, br := range gw.Bridges { // only for slack now if br.Protocol != "...
go
func (r *Router) updateChannelMembers() { // TODO sleep a minute because slack can take a while // fix this by having actually connectionDone events send to the router time.Sleep(time.Minute) for { for _, gw := range r.Gateways { for _, br := range gw.Bridges { // only for slack now if br.Protocol != "...
[ "func", "(", "r", "*", "Router", ")", "updateChannelMembers", "(", ")", "{", "// TODO sleep a minute because slack can take a while", "// fix this by having actually connectionDone events send to the router", "time", ".", "Sleep", "(", "time", ".", "Minute", ")", "\n", "for...
// updateChannelMembers sends every minute an GetChannelMembers event to all bridges.
[ "updateChannelMembers", "sends", "every", "minute", "an", "GetChannelMembers", "event", "to", "all", "bridges", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/router.go#L153-L172
train
42wim/matterbridge
bridge/discord/helpers.go
splitURL
func (b *Bdiscord) splitURL(url string) (string, string) { const ( expectedWebhookSplitCount = 7 webhookIdxID = 5 webhookIdxToken = 6 ) webhookURLSplit := strings.Split(url, "/") if len(webhookURLSplit) != expectedWebhookSplitCount { b.Log.Fatalf("%s is no correct discord WebhookURL",...
go
func (b *Bdiscord) splitURL(url string) (string, string) { const ( expectedWebhookSplitCount = 7 webhookIdxID = 5 webhookIdxToken = 6 ) webhookURLSplit := strings.Split(url, "/") if len(webhookURLSplit) != expectedWebhookSplitCount { b.Log.Fatalf("%s is no correct discord WebhookURL",...
[ "func", "(", "b", "*", "Bdiscord", ")", "splitURL", "(", "url", "string", ")", "(", "string", ",", "string", ")", "{", "const", "(", "expectedWebhookSplitCount", "=", "7", "\n", "webhookIdxID", "=", "5", "\n", "webhookIdxToken", "=", "6", "\n", ")", "\...
// splitURL splits a webhookURL and returns the ID and token.
[ "splitURL", "splits", "a", "webhookURL", "and", "returns", "the", "ID", "and", "token", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/discord/helpers.go#L143-L154
train
42wim/matterbridge
gateway/handlers.go
handleEventFailure
func (r *Router) handleEventFailure(msg *config.Message) { if msg.Event != config.EventFailure { return } for _, gw := range r.Gateways { for _, br := range gw.Bridges { if msg.Account == br.Account { go gw.reconnectBridge(br) return } } } }
go
func (r *Router) handleEventFailure(msg *config.Message) { if msg.Event != config.EventFailure { return } for _, gw := range r.Gateways { for _, br := range gw.Bridges { if msg.Account == br.Account { go gw.reconnectBridge(br) return } } } }
[ "func", "(", "r", "*", "Router", ")", "handleEventFailure", "(", "msg", "*", "config", ".", "Message", ")", "{", "if", "msg", ".", "Event", "!=", "config", ".", "EventFailure", "{", "return", "\n", "}", "\n", "for", "_", ",", "gw", ":=", "range", "...
// handleEventFailure handles failures and reconnects bridges.
[ "handleEventFailure", "handles", "failures", "and", "reconnects", "bridges", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/handlers.go#L20-L32
train
42wim/matterbridge
gateway/handlers.go
handleEventGetChannelMembers
func (r *Router) handleEventGetChannelMembers(msg *config.Message) { if msg.Event != config.EventGetChannelMembers { return } for _, gw := range r.Gateways { for _, br := range gw.Bridges { if msg.Account == br.Account { cMembers := msg.Extra[config.EventGetChannelMembers][0].(config.ChannelMembers) r...
go
func (r *Router) handleEventGetChannelMembers(msg *config.Message) { if msg.Event != config.EventGetChannelMembers { return } for _, gw := range r.Gateways { for _, br := range gw.Bridges { if msg.Account == br.Account { cMembers := msg.Extra[config.EventGetChannelMembers][0].(config.ChannelMembers) r...
[ "func", "(", "r", "*", "Router", ")", "handleEventGetChannelMembers", "(", "msg", "*", "config", ".", "Message", ")", "{", "if", "msg", ".", "Event", "!=", "config", ".", "EventGetChannelMembers", "{", "return", "\n", "}", "\n", "for", "_", ",", "gw", ...
// handleEventGetChannelMembers handles channel members
[ "handleEventGetChannelMembers", "handles", "channel", "members" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/handlers.go#L35-L49
train
42wim/matterbridge
gateway/handlers.go
handleEventRejoinChannels
func (r *Router) handleEventRejoinChannels(msg *config.Message) { if msg.Event != config.EventRejoinChannels { return } for _, gw := range r.Gateways { for _, br := range gw.Bridges { if msg.Account == br.Account { br.Joined = make(map[string]bool) if err := br.JoinChannels(); err != nil { r.logg...
go
func (r *Router) handleEventRejoinChannels(msg *config.Message) { if msg.Event != config.EventRejoinChannels { return } for _, gw := range r.Gateways { for _, br := range gw.Bridges { if msg.Account == br.Account { br.Joined = make(map[string]bool) if err := br.JoinChannels(); err != nil { r.logg...
[ "func", "(", "r", "*", "Router", ")", "handleEventRejoinChannels", "(", "msg", "*", "config", ".", "Message", ")", "{", "if", "msg", ".", "Event", "!=", "config", ".", "EventRejoinChannels", "{", "return", "\n", "}", "\n", "for", "_", ",", "gw", ":=", ...
// handleEventRejoinChannels handles rejoining of channels.
[ "handleEventRejoinChannels", "handles", "rejoining", "of", "channels", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/handlers.go#L52-L66
train
42wim/matterbridge
gateway/handlers.go
handleFiles
func (gw *Gateway) handleFiles(msg *config.Message) { reg := regexp.MustCompile("[^a-zA-Z0-9]+") // If we don't have a attachfield or we don't have a mediaserver configured return if msg.Extra == nil || (gw.BridgeValues().General.MediaServerUpload == "" && gw.BridgeValues().General.MediaDownloadPath == "") { ...
go
func (gw *Gateway) handleFiles(msg *config.Message) { reg := regexp.MustCompile("[^a-zA-Z0-9]+") // If we don't have a attachfield or we don't have a mediaserver configured return if msg.Extra == nil || (gw.BridgeValues().General.MediaServerUpload == "" && gw.BridgeValues().General.MediaDownloadPath == "") { ...
[ "func", "(", "gw", "*", "Gateway", ")", "handleFiles", "(", "msg", "*", "config", ".", "Message", ")", "{", "reg", ":=", "regexp", ".", "MustCompile", "(", "\"", "\"", ")", "\n\n", "// If we don't have a attachfield or we don't have a mediaserver configured return",...
// handleFiles uploads or places all files on the given msg to the MediaServer and // adds the new URL of the file on the MediaServer onto the given msg.
[ "handleFiles", "uploads", "or", "places", "all", "files", "on", "the", "given", "msg", "to", "the", "MediaServer", "and", "adds", "the", "new", "URL", "of", "the", "file", "on", "the", "MediaServer", "onto", "the", "given", "msg", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/handlers.go#L70-L119
train
42wim/matterbridge
gateway/handlers.go
handleFilesUpload
func (gw *Gateway) handleFilesUpload(fi *config.FileInfo) error { client := &http.Client{ Timeout: time.Second * 5, } // Use MediaServerUpload. Upload using a PUT HTTP request and basicauth. sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8] //nolint:gosec url := gw.BridgeValues().General.MediaServerUpload + "...
go
func (gw *Gateway) handleFilesUpload(fi *config.FileInfo) error { client := &http.Client{ Timeout: time.Second * 5, } // Use MediaServerUpload. Upload using a PUT HTTP request and basicauth. sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8] //nolint:gosec url := gw.BridgeValues().General.MediaServerUpload + "...
[ "func", "(", "gw", "*", "Gateway", ")", "handleFilesUpload", "(", "fi", "*", "config", ".", "FileInfo", ")", "error", "{", "client", ":=", "&", "http", ".", "Client", "{", "Timeout", ":", "time", ".", "Second", "*", "5", ",", "}", "\n", "// Use Media...
// handleFilesUpload uses MediaServerUpload configuration to upload the file. // Returns error on failure.
[ "handleFilesUpload", "uses", "MediaServerUpload", "configuration", "to", "upload", "the", "file", ".", "Returns", "error", "on", "failure", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/handlers.go#L123-L144
train
42wim/matterbridge
gateway/handlers.go
handleFilesLocal
func (gw *Gateway) handleFilesLocal(fi *config.FileInfo) error { sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8] //nolint:gosec dir := gw.BridgeValues().General.MediaDownloadPath + "/" + sha1sum err := os.Mkdir(dir, os.ModePerm) if err != nil && !os.IsExist(err) { return fmt.Errorf("mediaserver path failed, ...
go
func (gw *Gateway) handleFilesLocal(fi *config.FileInfo) error { sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8] //nolint:gosec dir := gw.BridgeValues().General.MediaDownloadPath + "/" + sha1sum err := os.Mkdir(dir, os.ModePerm) if err != nil && !os.IsExist(err) { return fmt.Errorf("mediaserver path failed, ...
[ "func", "(", "gw", "*", "Gateway", ")", "handleFilesLocal", "(", "fi", "*", "config", ".", "FileInfo", ")", "error", "{", "sha1sum", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sha1", ".", "Sum", "(", "*", "fi", ".", "Data", ")", ")", "["...
// handleFilesLocal use MediaServerPath configuration, places the file on the current filesystem. // Returns error on failure.
[ "handleFilesLocal", "use", "MediaServerPath", "configuration", "places", "the", "file", "on", "the", "current", "filesystem", ".", "Returns", "error", "on", "failure", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/handlers.go#L148-L164
train
42wim/matterbridge
gateway/handlers.go
ignoreEvent
func (gw *Gateway) ignoreEvent(event string, dest *bridge.Bridge) bool { switch event { case config.EventAvatarDownload: // Avatar downloads are only relevant for telegram and mattermost for now if dest.Protocol != "mattermost" && dest.Protocol != "telegram" { return true } case config.EventJoinLeave: // ...
go
func (gw *Gateway) ignoreEvent(event string, dest *bridge.Bridge) bool { switch event { case config.EventAvatarDownload: // Avatar downloads are only relevant for telegram and mattermost for now if dest.Protocol != "mattermost" && dest.Protocol != "telegram" { return true } case config.EventJoinLeave: // ...
[ "func", "(", "gw", "*", "Gateway", ")", "ignoreEvent", "(", "event", "string", ",", "dest", "*", "bridge", ".", "Bridge", ")", "bool", "{", "switch", "event", "{", "case", "config", ".", "EventAvatarDownload", ":", "// Avatar downloads are only relevant for tele...
// ignoreEvent returns true if we need to ignore this event for the specified destination bridge.
[ "ignoreEvent", "returns", "true", "if", "we", "need", "to", "ignore", "this", "event", "for", "the", "specified", "destination", "bridge", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/handlers.go#L167-L186
train
42wim/matterbridge
matterhook/matterhook.go
Send
func (c *Client) Send(msg OMessage) error { buf, err := json.Marshal(msg) if err != nil { return err } resp, err := c.httpclient.Post(c.Url, "application/json", bytes.NewReader(buf)) if err != nil { return err } defer resp.Body.Close() // Read entire body to completion to re-use keep-alive connections. io...
go
func (c *Client) Send(msg OMessage) error { buf, err := json.Marshal(msg) if err != nil { return err } resp, err := c.httpclient.Post(c.Url, "application/json", bytes.NewReader(buf)) if err != nil { return err } defer resp.Body.Close() // Read entire body to completion to re-use keep-alive connections. io...
[ "func", "(", "c", "*", "Client", ")", "Send", "(", "msg", "OMessage", ")", "error", "{", "buf", ",", "err", ":=", "json", ".", "Marshal", "(", "msg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "resp", ",", "err"...
// Send sends a msg to mattermost incoming webhooks URL.
[ "Send", "sends", "a", "msg", "to", "mattermost", "incoming", "webhooks", "URL", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/matterhook/matterhook.go#L150-L168
train
42wim/matterbridge
bridge/helper/helper.go
DownloadFileAuth
func DownloadFileAuth(url string, auth string) (*[]byte, error) { var buf bytes.Buffer client := &http.Client{ Timeout: time.Second * 5, } req, err := http.NewRequest("GET", url, nil) if auth != "" { req.Header.Add("Authorization", auth) } if err != nil { return nil, err } resp, err := client.Do(req) if...
go
func DownloadFileAuth(url string, auth string) (*[]byte, error) { var buf bytes.Buffer client := &http.Client{ Timeout: time.Second * 5, } req, err := http.NewRequest("GET", url, nil) if auth != "" { req.Header.Add("Authorization", auth) } if err != nil { return nil, err } resp, err := client.Do(req) if...
[ "func", "DownloadFileAuth", "(", "url", "string", ",", "auth", "string", ")", "(", "*", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "client", ":=", "&", "http", ".", "Client", "{", "Timeout", ":", "time", "...
// DownloadFileAuth downloads the given URL using the specified authentication token.
[ "DownloadFileAuth", "downloads", "the", "given", "URL", "using", "the", "specified", "authentication", "token", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/helper/helper.go#L27-L47
train
42wim/matterbridge
bridge/helper/helper.go
HandleExtra
func HandleExtra(msg *config.Message, general *config.Protocol) []config.Message { extra := msg.Extra rmsg := []config.Message{} for _, f := range extra[config.EventFileFailureSize] { fi := f.(config.FileInfo) text := fmt.Sprintf("file %s too big to download (%#v > allowed size: %#v)", fi.Name, fi.Size, general....
go
func HandleExtra(msg *config.Message, general *config.Protocol) []config.Message { extra := msg.Extra rmsg := []config.Message{} for _, f := range extra[config.EventFileFailureSize] { fi := f.(config.FileInfo) text := fmt.Sprintf("file %s too big to download (%#v > allowed size: %#v)", fi.Name, fi.Size, general....
[ "func", "HandleExtra", "(", "msg", "*", "config", ".", "Message", ",", "general", "*", "config", ".", "Protocol", ")", "[", "]", "config", ".", "Message", "{", "extra", ":=", "msg", ".", "Extra", "\n", "rmsg", ":=", "[", "]", "config", ".", "Message"...
// HandleExtra manages the supplementary details stored inside a message's 'Extra' field map.
[ "HandleExtra", "manages", "the", "supplementary", "details", "stored", "inside", "a", "message", "s", "Extra", "field", "map", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/helper/helper.go#L88-L102
train
42wim/matterbridge
bridge/helper/helper.go
GetAvatar
func GetAvatar(av map[string]string, userid string, general *config.Protocol) string { if sha, ok := av[userid]; ok { return general.MediaServerDownload + "/" + sha + "/" + userid + ".png" } return "" }
go
func GetAvatar(av map[string]string, userid string, general *config.Protocol) string { if sha, ok := av[userid]; ok { return general.MediaServerDownload + "/" + sha + "/" + userid + ".png" } return "" }
[ "func", "GetAvatar", "(", "av", "map", "[", "string", "]", "string", ",", "userid", "string", ",", "general", "*", "config", ".", "Protocol", ")", "string", "{", "if", "sha", ",", "ok", ":=", "av", "[", "userid", "]", ";", "ok", "{", "return", "gen...
// GetAvatar constructs a URL for a given user-avatar if it is available in the cache.
[ "GetAvatar", "constructs", "a", "URL", "for", "a", "given", "user", "-", "avatar", "if", "it", "is", "available", "in", "the", "cache", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/helper/helper.go#L105-L110
train
42wim/matterbridge
bridge/helper/helper.go
HandleDownloadSize
func HandleDownloadSize(logger *logrus.Entry, msg *config.Message, name string, size int64, general *config.Protocol) error { // check blacklist here for _, entry := range general.MediaDownloadBlackList { if entry != "" { re, err := regexp.Compile(entry) if err != nil { logger.Errorf("incorrect regexp %s ...
go
func HandleDownloadSize(logger *logrus.Entry, msg *config.Message, name string, size int64, general *config.Protocol) error { // check blacklist here for _, entry := range general.MediaDownloadBlackList { if entry != "" { re, err := regexp.Compile(entry) if err != nil { logger.Errorf("incorrect regexp %s ...
[ "func", "HandleDownloadSize", "(", "logger", "*", "logrus", ".", "Entry", ",", "msg", "*", "config", ".", "Message", ",", "name", "string", ",", "size", "int64", ",", "general", "*", "config", ".", "Protocol", ")", "error", "{", "// check blacklist here", ...
// HandleDownloadSize checks a specified filename against the configured download blacklist // and checks a specified file-size against the configure limit.
[ "HandleDownloadSize", "checks", "a", "specified", "filename", "against", "the", "configured", "download", "blacklist", "and", "checks", "a", "specified", "file", "-", "size", "against", "the", "configure", "limit", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/helper/helper.go#L114-L139
train
42wim/matterbridge
bridge/helper/helper.go
HandleDownloadData
func HandleDownloadData(logger *logrus.Entry, msg *config.Message, name, comment, url string, data *[]byte, general *config.Protocol) { var avatar bool logger.Debugf("Download OK %#v %#v", name, len(*data)) if msg.Event == config.EventAvatarDownload { avatar = true } msg.Extra["file"] = append(msg.Extra["file"],...
go
func HandleDownloadData(logger *logrus.Entry, msg *config.Message, name, comment, url string, data *[]byte, general *config.Protocol) { var avatar bool logger.Debugf("Download OK %#v %#v", name, len(*data)) if msg.Event == config.EventAvatarDownload { avatar = true } msg.Extra["file"] = append(msg.Extra["file"],...
[ "func", "HandleDownloadData", "(", "logger", "*", "logrus", ".", "Entry", ",", "msg", "*", "config", ".", "Message", ",", "name", ",", "comment", ",", "url", "string", ",", "data", "*", "[", "]", "byte", ",", "general", "*", "config", ".", "Protocol", ...
// HandleDownloadData adds the data for a remote file into a Matterbridge gateway message.
[ "HandleDownloadData", "adds", "the", "data", "for", "a", "remote", "file", "into", "a", "Matterbridge", "gateway", "message", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/helper/helper.go#L142-L155
train
42wim/matterbridge
bridge/helper/helper.go
ClipMessage
func ClipMessage(text string, length int) string { const clippingMessage = " <clipped message>" if len(text) > length { text = text[:length-len(clippingMessage)] if r, size := utf8.DecodeLastRuneInString(text); r == utf8.RuneError { text = text[:len(text)-size] } text += clippingMessage } return text }
go
func ClipMessage(text string, length int) string { const clippingMessage = " <clipped message>" if len(text) > length { text = text[:length-len(clippingMessage)] if r, size := utf8.DecodeLastRuneInString(text); r == utf8.RuneError { text = text[:len(text)-size] } text += clippingMessage } return text }
[ "func", "ClipMessage", "(", "text", "string", ",", "length", "int", ")", "string", "{", "const", "clippingMessage", "=", "\"", "\"", "\n", "if", "len", "(", "text", ")", ">", "length", "{", "text", "=", "text", "[", ":", "length", "-", "len", "(", ...
// ClipMessage trims a message to the specified length if it exceeds it and adds a warning // to the message in case it does so.
[ "ClipMessage", "trims", "a", "message", "to", "the", "specified", "length", "if", "it", "exceeds", "it", "and", "adds", "a", "warning", "to", "the", "message", "in", "case", "it", "does", "so", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/helper/helper.go#L167-L177
train
42wim/matterbridge
matterclient/matterclient.go
New
func New(login string, pass string, team string, server string) *MMClient { rootLogger := logrus.New() rootLogger.SetFormatter(&prefixed.TextFormatter{ PrefixPadding: 13, DisableColors: true, }) cred := &Credentials{ Login: login, Pass: pass, Team: team, Server: server, } cache, _ := lru.New(50...
go
func New(login string, pass string, team string, server string) *MMClient { rootLogger := logrus.New() rootLogger.SetFormatter(&prefixed.TextFormatter{ PrefixPadding: 13, DisableColors: true, }) cred := &Credentials{ Login: login, Pass: pass, Team: team, Server: server, } cache, _ := lru.New(50...
[ "func", "New", "(", "login", "string", ",", "pass", "string", ",", "team", "string", ",", "server", "string", ")", "*", "MMClient", "{", "rootLogger", ":=", "logrus", ".", "New", "(", ")", "\n", "rootLogger", ".", "SetFormatter", "(", "&", "prefixed", ...
// New will instantiate a new Matterclient with the specified login details without connecting.
[ "New", "will", "instantiate", "a", "new", "Matterclient", "with", "the", "specified", "login", "details", "without", "connecting", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/matterclient/matterclient.go#L74-L97
train
42wim/matterbridge
matterclient/matterclient.go
SetDebugLog
func (m *MMClient) SetDebugLog() { m.rootLogger.SetFormatter(&prefixed.TextFormatter{ PrefixPadding: 13, DisableColors: true, FullTimestamp: false, ForceFormatting: true, }) }
go
func (m *MMClient) SetDebugLog() { m.rootLogger.SetFormatter(&prefixed.TextFormatter{ PrefixPadding: 13, DisableColors: true, FullTimestamp: false, ForceFormatting: true, }) }
[ "func", "(", "m", "*", "MMClient", ")", "SetDebugLog", "(", ")", "{", "m", ".", "rootLogger", ".", "SetFormatter", "(", "&", "prefixed", ".", "TextFormatter", "{", "PrefixPadding", ":", "13", ",", "DisableColors", ":", "true", ",", "FullTimestamp", ":", ...
// SetDebugLog activates debugging logging on all Matterclient log output.
[ "SetDebugLog", "activates", "debugging", "logging", "on", "all", "Matterclient", "log", "output", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/matterclient/matterclient.go#L100-L107
train
42wim/matterbridge
matterclient/matterclient.go
Login
func (m *MMClient) Login() error { // check if this is a first connect or a reconnection firstConnection := true if m.WsConnected { firstConnection = false } m.WsConnected = false if m.WsQuit { return nil } b := &backoff.Backoff{ Min: time.Second, Max: 5 * time.Minute, Jitter: true, } // do i...
go
func (m *MMClient) Login() error { // check if this is a first connect or a reconnection firstConnection := true if m.WsConnected { firstConnection = false } m.WsConnected = false if m.WsQuit { return nil } b := &backoff.Backoff{ Min: time.Second, Max: 5 * time.Minute, Jitter: true, } // do i...
[ "func", "(", "m", "*", "MMClient", ")", "Login", "(", ")", "error", "{", "// check if this is a first connect or a reconnection", "firstConnection", ":=", "true", "\n", "if", "m", ".", "WsConnected", "{", "firstConnection", "=", "false", "\n", "}", "\n", "m", ...
// Login tries to connect the client with the loging details with which it was initialized.
[ "Login", "tries", "to", "connect", "the", "client", "with", "the", "loging", "details", "with", "which", "it", "was", "initialized", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/matterclient/matterclient.go#L122-L162
train
42wim/matterbridge
matterclient/matterclient.go
Logout
func (m *MMClient) Logout() error { m.logger.Debugf("logout as %s (team: %s) on %s", m.Credentials.Login, m.Credentials.Team, m.Credentials.Server) m.WsQuit = true m.WsClient.Close() m.WsClient.UnderlyingConn().Close() if strings.Contains(m.Credentials.Pass, model.SESSION_COOKIE_TOKEN) { m.logger.Debug("Not inva...
go
func (m *MMClient) Logout() error { m.logger.Debugf("logout as %s (team: %s) on %s", m.Credentials.Login, m.Credentials.Team, m.Credentials.Server) m.WsQuit = true m.WsClient.Close() m.WsClient.UnderlyingConn().Close() if strings.Contains(m.Credentials.Pass, model.SESSION_COOKIE_TOKEN) { m.logger.Debug("Not inva...
[ "func", "(", "m", "*", "MMClient", ")", "Logout", "(", ")", "error", "{", "m", ".", "logger", ".", "Debugf", "(", "\"", "\"", ",", "m", ".", "Credentials", ".", "Login", ",", "m", ".", "Credentials", ".", "Team", ",", "m", ".", "Credentials", "."...
// Logout disconnects the client from the chat server.
[ "Logout", "disconnects", "the", "client", "from", "the", "chat", "server", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/matterclient/matterclient.go#L165-L179
train
42wim/matterbridge
matterclient/matterclient.go
WsReceiver
func (m *MMClient) WsReceiver() { for { var rawMsg json.RawMessage var err error if m.WsQuit { m.logger.Debug("exiting WsReceiver") return } if !m.WsConnected { time.Sleep(time.Millisecond * 100) continue } if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil { m.logger.Error("error...
go
func (m *MMClient) WsReceiver() { for { var rawMsg json.RawMessage var err error if m.WsQuit { m.logger.Debug("exiting WsReceiver") return } if !m.WsConnected { time.Sleep(time.Millisecond * 100) continue } if _, rawMsg, err = m.WsClient.ReadMessage(); err != nil { m.logger.Error("error...
[ "func", "(", "m", "*", "MMClient", ")", "WsReceiver", "(", ")", "{", "for", "{", "var", "rawMsg", "json", ".", "RawMessage", "\n", "var", "err", "error", "\n\n", "if", "m", ".", "WsQuit", "{", "m", ".", "logger", ".", "Debug", "(", "\"", "\"", ")...
// WsReceiver implements the core loop that manages the connection to the chat server. In // case of a disconnect it will try to reconnect. A call to this method is blocking until // the 'WsQuite' field of the MMClient object is set to 'true'.
[ "WsReceiver", "implements", "the", "core", "loop", "that", "manages", "the", "connection", "to", "the", "chat", "server", ".", "In", "case", "of", "a", "disconnect", "it", "will", "try", "to", "reconnect", ".", "A", "call", "to", "this", "method", "is", ...
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/matterclient/matterclient.go#L184-L238
train
42wim/matterbridge
matterclient/matterclient.go
StatusLoop
func (m *MMClient) StatusLoop() { retries := 0 backoff := time.Second * 60 if m.OnWsConnect != nil { m.OnWsConnect() } m.logger.Debug("StatusLoop:", m.OnWsConnect != nil) for { if m.WsQuit { return } if m.WsConnected { if err := m.checkAlive(); err != nil { m.logger.Errorf("Connection is not ali...
go
func (m *MMClient) StatusLoop() { retries := 0 backoff := time.Second * 60 if m.OnWsConnect != nil { m.OnWsConnect() } m.logger.Debug("StatusLoop:", m.OnWsConnect != nil) for { if m.WsQuit { return } if m.WsConnected { if err := m.checkAlive(); err != nil { m.logger.Errorf("Connection is not ali...
[ "func", "(", "m", "*", "MMClient", ")", "StatusLoop", "(", ")", "{", "retries", ":=", "0", "\n", "backoff", ":=", "time", ".", "Second", "*", "60", "\n", "if", "m", ".", "OnWsConnect", "!=", "nil", "{", "m", ".", "OnWsConnect", "(", ")", "\n", "}...
// StatusLoop implements a ping-cycle that ensures that the connection to the chat servers // remains alive. In case of a disconnect it will try to reconnect. A call to this method // is blocking until the 'WsQuite' field of the MMClient object is set to 'true'.
[ "StatusLoop", "implements", "a", "ping", "-", "cycle", "that", "ensures", "that", "the", "connection", "to", "the", "chat", "servers", "remains", "alive", ".", "In", "case", "of", "a", "disconnect", "it", "will", "try", "to", "reconnect", ".", "A", "call",...
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/matterclient/matterclient.go#L243-L284
train
42wim/matterbridge
bridge/slack/slack.go
JoinChannel
func (b *Bslack) JoinChannel(channel config.ChannelInfo) error { // We can only join a channel through the Slack API. if b.sc == nil { return nil } b.channels.populateChannels(false) channelInfo, err := b.channels.getChannel(channel.Name) if err != nil { return fmt.Errorf("could not join channel: %#v", err)...
go
func (b *Bslack) JoinChannel(channel config.ChannelInfo) error { // We can only join a channel through the Slack API. if b.sc == nil { return nil } b.channels.populateChannels(false) channelInfo, err := b.channels.getChannel(channel.Name) if err != nil { return fmt.Errorf("could not join channel: %#v", err)...
[ "func", "(", "b", "*", "Bslack", ")", "JoinChannel", "(", "channel", "config", ".", "ChannelInfo", ")", "error", "{", "// We can only join a channel through the Slack API.", "if", "b", ".", "sc", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "b", "."...
// JoinChannel only acts as a verification method that checks whether Matterbridge's // Slack integration is already member of the channel. This is because Slack does not // allow apps or bots to join channels themselves and they need to be invited // manually by a user.
[ "JoinChannel", "only", "acts", "as", "a", "verification", "method", "that", "checks", "whether", "Matterbridge", "s", "Slack", "integration", "is", "already", "member", "of", "the", "channel", ".", "This", "is", "because", "Slack", "does", "not", "allow", "app...
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/slack/slack.go#L148-L170
train
42wim/matterbridge
bridge/slack/slack.go
uploadFile
func (b *Bslack) uploadFile(msg *config.Message, channelID string) { for _, f := range msg.Extra["file"] { fi, ok := f.(config.FileInfo) if !ok { b.Log.Errorf("Received a file with unexpected content: %#v", f) continue } if msg.Text == fi.Comment { msg.Text = "" } // Because the result of the Uplo...
go
func (b *Bslack) uploadFile(msg *config.Message, channelID string) { for _, f := range msg.Extra["file"] { fi, ok := f.(config.FileInfo) if !ok { b.Log.Errorf("Received a file with unexpected content: %#v", f) continue } if msg.Text == fi.Comment { msg.Text = "" } // Because the result of the Uplo...
[ "func", "(", "b", "*", "Bslack", ")", "uploadFile", "(", "msg", "*", "config", ".", "Message", ",", "channelID", "string", ")", "{", "for", "_", ",", "f", ":=", "range", "msg", ".", "Extra", "[", "\"", "\"", "]", "{", "fi", ",", "ok", ":=", "f"...
// uploadFile handles native upload of files
[ "uploadFile", "handles", "native", "upload", "of", "files" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/slack/slack.go#L434-L469
train
42wim/matterbridge
bridge/irc/handlers.go
handleFiles
func (b *Birc) handleFiles(msg *config.Message) bool { if msg.Extra == nil { return false } for _, rmsg := range helper.HandleExtra(msg, b.General) { b.Local <- rmsg } if len(msg.Extra["file"]) == 0 { return false } for _, f := range msg.Extra["file"] { fi := f.(config.FileInfo) if fi.Comment != "" { ...
go
func (b *Birc) handleFiles(msg *config.Message) bool { if msg.Extra == nil { return false } for _, rmsg := range helper.HandleExtra(msg, b.General) { b.Local <- rmsg } if len(msg.Extra["file"]) == 0 { return false } for _, f := range msg.Extra["file"] { fi := f.(config.FileInfo) if fi.Comment != "" { ...
[ "func", "(", "b", "*", "Birc", ")", "handleFiles", "(", "msg", "*", "config", ".", "Message", ")", "bool", "{", "if", "msg", ".", "Extra", "==", "nil", "{", "return", "false", "\n", "}", "\n", "for", "_", ",", "rmsg", ":=", "range", "helper", "."...
// handleFiles returns true if we have handled the files, otherwise return false
[ "handleFiles", "returns", "true", "if", "we", "have", "handled", "the", "files", "otherwise", "return", "false" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/irc/handlers.go#L44-L68
train
42wim/matterbridge
bridge/config/config.go
NewConfig
func NewConfig(rootLogger *logrus.Logger, cfgfile string) Config { logger := rootLogger.WithFields(logrus.Fields{"prefix": "config"}) viper.SetConfigFile(cfgfile) input, err := ioutil.ReadFile(cfgfile) if err != nil { logger.Fatalf("Failed to read configuration file: %#v", err) } mycfg := newConfigFromString(...
go
func NewConfig(rootLogger *logrus.Logger, cfgfile string) Config { logger := rootLogger.WithFields(logrus.Fields{"prefix": "config"}) viper.SetConfigFile(cfgfile) input, err := ioutil.ReadFile(cfgfile) if err != nil { logger.Fatalf("Failed to read configuration file: %#v", err) } mycfg := newConfigFromString(...
[ "func", "NewConfig", "(", "rootLogger", "*", "logrus", ".", "Logger", ",", "cfgfile", "string", ")", "Config", "{", "logger", ":=", "rootLogger", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "\"", "\"", "}", ")", "\n\n", "vipe...
// NewConfig instantiates a new configuration based on the specified configuration file path.
[ "NewConfig", "instantiates", "a", "new", "configuration", "based", "on", "the", "specified", "configuration", "file", "path", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/config/config.go#L224-L242
train
42wim/matterbridge
bridge/config/config.go
NewConfigFromString
func NewConfigFromString(rootLogger *logrus.Logger, input []byte) Config { logger := rootLogger.WithFields(logrus.Fields{"prefix": "config"}) return newConfigFromString(logger, input) }
go
func NewConfigFromString(rootLogger *logrus.Logger, input []byte) Config { logger := rootLogger.WithFields(logrus.Fields{"prefix": "config"}) return newConfigFromString(logger, input) }
[ "func", "NewConfigFromString", "(", "rootLogger", "*", "logrus", ".", "Logger", ",", "input", "[", "]", "byte", ")", "Config", "{", "logger", ":=", "rootLogger", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "\"", "\"", "}", ")...
// NewConfigFromString instantiates a new configuration based on the specified string.
[ "NewConfigFromString", "instantiates", "a", "new", "configuration", "based", "on", "the", "specified", "string", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/config/config.go#L245-L248
train
42wim/matterbridge
bridge/steam/handlers.go
handleFileInfo
func (b *Bsteam) handleFileInfo(msg *config.Message, f interface{}) error { if _, ok := f.(config.FileInfo); !ok { return fmt.Errorf("handleFileInfo cast failed %#v", f) } fi := f.(config.FileInfo) if fi.Comment != "" { msg.Text += fi.Comment + ": " } if fi.URL != "" { msg.Text = fi.URL if fi.Comment != "...
go
func (b *Bsteam) handleFileInfo(msg *config.Message, f interface{}) error { if _, ok := f.(config.FileInfo); !ok { return fmt.Errorf("handleFileInfo cast failed %#v", f) } fi := f.(config.FileInfo) if fi.Comment != "" { msg.Text += fi.Comment + ": " } if fi.URL != "" { msg.Text = fi.URL if fi.Comment != "...
[ "func", "(", "b", "*", "Bsteam", ")", "handleFileInfo", "(", "msg", "*", "config", ".", "Message", ",", "f", "interface", "{", "}", ")", "error", "{", "if", "_", ",", "ok", ":=", "f", ".", "(", "config", ".", "FileInfo", ")", ";", "!", "ok", "{...
// handleFileInfo handles config.FileInfo and adds correct file comment or URL to msg.Text. // Returns error if cast fails.
[ "handleFileInfo", "handles", "config", ".", "FileInfo", "and", "adds", "correct", "file", "comment", "or", "URL", "to", "msg", ".", "Text", ".", "Returns", "error", "if", "cast", "fails", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/steam/handlers.go#L111-L126
train
42wim/matterbridge
bridge/whatsapp/handlers.go
HandleTextMessage
func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) { if message.Info.FromMe { // || !strings.Contains(strings.ToLower(message.Text), "@echo") { return } // whatsapp sends last messages to show context , cut them if message.Info.Timestamp < b.startedAt { return } messageTime := time.Unix(int6...
go
func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) { if message.Info.FromMe { // || !strings.Contains(strings.ToLower(message.Text), "@echo") { return } // whatsapp sends last messages to show context , cut them if message.Info.Timestamp < b.startedAt { return } messageTime := time.Unix(int6...
[ "func", "(", "b", "*", "Bwhatsapp", ")", "HandleTextMessage", "(", "message", "whatsapp", ".", "TextMessage", ")", "{", "if", "message", ".", "Info", ".", "FromMe", "{", "// || !strings.Contains(strings.ToLower(message.Text), \"@echo\") {", "return", "\n", "}", "\n"...
// HandleTextMessage sent from WhatsApp, relay it to the brige
[ "HandleTextMessage", "sent", "from", "WhatsApp", "relay", "it", "to", "the", "brige" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/whatsapp/handlers.go#L28-L89
train
42wim/matterbridge
bridge/slack/helpers.go
populateReceivedMessage
func (b *Bslack) populateReceivedMessage(ev *slack.MessageEvent) (*config.Message, error) { // Use our own func because rtm.GetChannelInfo doesn't work for private channels. channel, err := b.channels.getChannelByID(ev.Channel) if err != nil { return nil, err } rmsg := &config.Message{ Text: ev.Text, Ch...
go
func (b *Bslack) populateReceivedMessage(ev *slack.MessageEvent) (*config.Message, error) { // Use our own func because rtm.GetChannelInfo doesn't work for private channels. channel, err := b.channels.getChannelByID(ev.Channel) if err != nil { return nil, err } rmsg := &config.Message{ Text: ev.Text, Ch...
[ "func", "(", "b", "*", "Bslack", ")", "populateReceivedMessage", "(", "ev", "*", "slack", ".", "MessageEvent", ")", "(", "*", "config", ".", "Message", ",", "error", ")", "{", "// Use our own func because rtm.GetChannelInfo doesn't work for private channels.", "channe...
// populateReceivedMessage shapes the initial Matterbridge message that we will forward to the // router before we apply message-dependent modifications.
[ "populateReceivedMessage", "shapes", "the", "initial", "Matterbridge", "message", "that", "we", "will", "forward", "to", "the", "router", "before", "we", "apply", "message", "-", "dependent", "modifications", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/slack/helpers.go#L16-L56
train
42wim/matterbridge
bridge/slack/helpers.go
getUsersInConversation
func (b *Bslack) getUsersInConversation(channelID string) ([]string, error) { channelMembers := []string{} for { queryParams := &slack.GetUsersInConversationParameters{ ChannelID: channelID, } members, nextCursor, err := b.sc.GetUsersInConversation(queryParams) if err != nil { if err = handleRateLimit(...
go
func (b *Bslack) getUsersInConversation(channelID string) ([]string, error) { channelMembers := []string{} for { queryParams := &slack.GetUsersInConversationParameters{ ChannelID: channelID, } members, nextCursor, err := b.sc.GetUsersInConversation(queryParams) if err != nil { if err = handleRateLimit(...
[ "func", "(", "b", "*", "Bslack", ")", "getUsersInConversation", "(", "channelID", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "channelMembers", ":=", "[", "]", "string", "{", "}", "\n", "for", "{", "queryParams", ":=", "&", "slack",...
// getUsersInConversation returns an array of userIDs that are members of channelID
[ "getUsersInConversation", "returns", "an", "array", "of", "userIDs", "that", "are", "members", "of", "channelID" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/slack/helpers.go#L196-L219
train
42wim/matterbridge
gateway/gateway.go
New
func New(rootLogger *logrus.Logger, cfg *config.Gateway, r *Router) *Gateway { logger := rootLogger.WithFields(logrus.Fields{"prefix": "gateway"}) cache, _ := lru.New(5000) gw := &Gateway{ Channels: make(map[string]*config.ChannelInfo), Message: r.Message, Router: r, Bridges: make(map[string]*bridge.Bri...
go
func New(rootLogger *logrus.Logger, cfg *config.Gateway, r *Router) *Gateway { logger := rootLogger.WithFields(logrus.Fields{"prefix": "gateway"}) cache, _ := lru.New(5000) gw := &Gateway{ Channels: make(map[string]*config.ChannelInfo), Message: r.Message, Router: r, Bridges: make(map[string]*bridge.Bri...
[ "func", "New", "(", "rootLogger", "*", "logrus", ".", "Logger", ",", "cfg", "*", "config", ".", "Gateway", ",", "r", "*", "Router", ")", "*", "Gateway", "{", "logger", ":=", "rootLogger", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\...
// New creates a new Gateway object associated with the specified router and // following the given configuration.
[ "New", "creates", "a", "new", "Gateway", "object", "associated", "with", "the", "specified", "router", "and", "following", "the", "given", "configuration", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/gateway.go#L45-L62
train
42wim/matterbridge
gateway/gateway.go
FindCanonicalMsgID
func (gw *Gateway) FindCanonicalMsgID(protocol string, mID string) string { ID := protocol + " " + mID if gw.Messages.Contains(ID) { return mID } // If not keyed, iterate through cache for downstream, and infer upstream. for _, mid := range gw.Messages.Keys() { v, _ := gw.Messages.Peek(mid) ids := v.([]*BrM...
go
func (gw *Gateway) FindCanonicalMsgID(protocol string, mID string) string { ID := protocol + " " + mID if gw.Messages.Contains(ID) { return mID } // If not keyed, iterate through cache for downstream, and infer upstream. for _, mid := range gw.Messages.Keys() { v, _ := gw.Messages.Peek(mid) ids := v.([]*BrM...
[ "func", "(", "gw", "*", "Gateway", ")", "FindCanonicalMsgID", "(", "protocol", "string", ",", "mID", "string", ")", "string", "{", "ID", ":=", "protocol", "+", "\"", "\"", "+", "mID", "\n", "if", "gw", ".", "Messages", ".", "Contains", "(", "ID", ")"...
// FindCanonicalMsgID returns the ID under which a message was stored in the cache.
[ "FindCanonicalMsgID", "returns", "the", "ID", "under", "which", "a", "message", "was", "stored", "in", "the", "cache", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/gateway.go#L65-L82
train
42wim/matterbridge
gateway/gateway.go
AddBridge
func (gw *Gateway) AddBridge(cfg *config.Bridge) error { br := gw.Router.getBridge(cfg.Account) if br == nil { br = bridge.New(cfg) br.Config = gw.Router.Config br.General = &gw.BridgeValues().General br.Log = gw.logger.WithFields(logrus.Fields{"prefix": br.Protocol}) brconfig := &bridge.Config{ Remote: ...
go
func (gw *Gateway) AddBridge(cfg *config.Bridge) error { br := gw.Router.getBridge(cfg.Account) if br == nil { br = bridge.New(cfg) br.Config = gw.Router.Config br.General = &gw.BridgeValues().General br.Log = gw.logger.WithFields(logrus.Fields{"prefix": br.Protocol}) brconfig := &bridge.Config{ Remote: ...
[ "func", "(", "gw", "*", "Gateway", ")", "AddBridge", "(", "cfg", "*", "config", ".", "Bridge", ")", "error", "{", "br", ":=", "gw", ".", "Router", ".", "getBridge", "(", "cfg", ".", "Account", ")", "\n", "if", "br", "==", "nil", "{", "br", "=", ...
// AddBridge sets up a new bridge in the gateway object with the specified configuration.
[ "AddBridge", "sets", "up", "a", "new", "bridge", "in", "the", "gateway", "object", "with", "the", "specified", "configuration", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/gateway.go#L85-L105
train
42wim/matterbridge
gateway/gateway.go
AddConfig
func (gw *Gateway) AddConfig(cfg *config.Gateway) error { gw.Name = cfg.Name gw.MyConfig = cfg if err := gw.mapChannels(); err != nil { gw.logger.Errorf("mapChannels() failed: %s", err) } for _, br := range append(gw.MyConfig.In, append(gw.MyConfig.InOut, gw.MyConfig.Out...)...) { br := br //scopelint err :=...
go
func (gw *Gateway) AddConfig(cfg *config.Gateway) error { gw.Name = cfg.Name gw.MyConfig = cfg if err := gw.mapChannels(); err != nil { gw.logger.Errorf("mapChannels() failed: %s", err) } for _, br := range append(gw.MyConfig.In, append(gw.MyConfig.InOut, gw.MyConfig.Out...)...) { br := br //scopelint err :=...
[ "func", "(", "gw", "*", "Gateway", ")", "AddConfig", "(", "cfg", "*", "config", ".", "Gateway", ")", "error", "{", "gw", ".", "Name", "=", "cfg", ".", "Name", "\n", "gw", ".", "MyConfig", "=", "cfg", "\n", "if", "err", ":=", "gw", ".", "mapChanne...
// AddConfig associates a new configuration with the gateway object.
[ "AddConfig", "associates", "a", "new", "configuration", "with", "the", "gateway", "object", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/gateway.go#L108-L122
train
42wim/matterbridge
gateway/gateway.go
ignoreTextEmpty
func (gw *Gateway) ignoreTextEmpty(msg *config.Message) bool { if msg.Text != "" { return false } if msg.Event == config.EventUserTyping { return false } // we have an attachment or actual bytes, do not ignore if msg.Extra != nil && (msg.Extra["attachments"] != nil || len(msg.Extra["file"]) > 0 || len...
go
func (gw *Gateway) ignoreTextEmpty(msg *config.Message) bool { if msg.Text != "" { return false } if msg.Event == config.EventUserTyping { return false } // we have an attachment or actual bytes, do not ignore if msg.Extra != nil && (msg.Extra["attachments"] != nil || len(msg.Extra["file"]) > 0 || len...
[ "func", "(", "gw", "*", "Gateway", ")", "ignoreTextEmpty", "(", "msg", "*", "config", ".", "Message", ")", "bool", "{", "if", "msg", ".", "Text", "!=", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "if", "msg", ".", "Event", "==", "config", ...
// ignoreTextEmpty returns true if we need to ignore a message with an empty text.
[ "ignoreTextEmpty", "returns", "true", "if", "we", "need", "to", "ignore", "a", "message", "with", "an", "empty", "text", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/gateway.go#L261-L277
train
42wim/matterbridge
gateway/gateway.go
ignoreText
func (gw *Gateway) ignoreText(text string, input []string) bool { for _, entry := range input { if entry == "" { continue } // TODO do not compile regexps everytime re, err := regexp.Compile(entry) if err != nil { gw.logger.Errorf("incorrect regexp %s", entry) continue } if re.MatchString(text) ...
go
func (gw *Gateway) ignoreText(text string, input []string) bool { for _, entry := range input { if entry == "" { continue } // TODO do not compile regexps everytime re, err := regexp.Compile(entry) if err != nil { gw.logger.Errorf("incorrect regexp %s", entry) continue } if re.MatchString(text) ...
[ "func", "(", "gw", "*", "Gateway", ")", "ignoreText", "(", "text", "string", ",", "input", "[", "]", "string", ")", "bool", "{", "for", "_", ",", "entry", ":=", "range", "input", "{", "if", "entry", "==", "\"", "\"", "{", "continue", "\n", "}", "...
// ignoreText returns true if text matches any of the input regexes.
[ "ignoreText", "returns", "true", "if", "text", "matches", "any", "of", "the", "input", "regexes", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/gateway/gateway.go#L471-L488
train
42wim/matterbridge
bridge/matrix/matrix.go
handleUploadFiles
func (b *Bmatrix) handleUploadFiles(msg *config.Message, channel string) (string, error) { for _, f := range msg.Extra["file"] { if fi, ok := f.(config.FileInfo); ok { b.handleUploadFile(msg, channel, &fi) } } return "", nil }
go
func (b *Bmatrix) handleUploadFiles(msg *config.Message, channel string) (string, error) { for _, f := range msg.Extra["file"] { if fi, ok := f.(config.FileInfo); ok { b.handleUploadFile(msg, channel, &fi) } } return "", nil }
[ "func", "(", "b", "*", "Bmatrix", ")", "handleUploadFiles", "(", "msg", "*", "config", ".", "Message", ",", "channel", "string", ")", "(", "string", ",", "error", ")", "{", "for", "_", ",", "f", ":=", "range", "msg", ".", "Extra", "[", "\"", "\"", ...
// handleUploadFiles handles native upload of files.
[ "handleUploadFiles", "handles", "native", "upload", "of", "files", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/matrix/matrix.go#L280-L287
train
42wim/matterbridge
bridge/matrix/matrix.go
handleUploadFile
func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *config.FileInfo) { content := bytes.NewReader(*fi.Data) sp := strings.Split(fi.Name, ".") mtype := mime.TypeByExtension("." + sp[len(sp)-1]) if !strings.Contains(mtype, "image") && !strings.Contains(mtype, "video") { return } if fi.Comm...
go
func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *config.FileInfo) { content := bytes.NewReader(*fi.Data) sp := strings.Split(fi.Name, ".") mtype := mime.TypeByExtension("." + sp[len(sp)-1]) if !strings.Contains(mtype, "image") && !strings.Contains(mtype, "video") { return } if fi.Comm...
[ "func", "(", "b", "*", "Bmatrix", ")", "handleUploadFile", "(", "msg", "*", "config", ".", "Message", ",", "channel", "string", ",", "fi", "*", "config", ".", "FileInfo", ")", "{", "content", ":=", "bytes", ".", "NewReader", "(", "*", "fi", ".", "Dat...
// handleUploadFile handles native upload of a file.
[ "handleUploadFile", "handles", "native", "upload", "of", "a", "file", "." ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/matrix/matrix.go#L290-L331
train
42wim/matterbridge
bridge/xmpp/xmpp.go
skipMessage
func (b *Bxmpp) skipMessage(message xmpp.Chat) bool { // skip messages from ourselves if b.parseNick(message.Remote) == b.GetString("Nick") { return true } // skip empty messages if message.Text == "" { return true } // skip subject messages if strings.Contains(message.Text, "</subject>") { return true ...
go
func (b *Bxmpp) skipMessage(message xmpp.Chat) bool { // skip messages from ourselves if b.parseNick(message.Remote) == b.GetString("Nick") { return true } // skip empty messages if message.Text == "" { return true } // skip subject messages if strings.Contains(message.Text, "</subject>") { return true ...
[ "func", "(", "b", "*", "Bxmpp", ")", "skipMessage", "(", "message", "xmpp", ".", "Chat", ")", "bool", "{", "// skip messages from ourselves", "if", "b", ".", "parseNick", "(", "message", ".", "Remote", ")", "==", "b", ".", "GetString", "(", "\"", "\"", ...
// skipMessage skips messages that need to be skipped
[ "skipMessage", "skips", "messages", "that", "need", "to", "be", "skipped" ]
1b2feb19e506bc24580d5d61422d0de68349c24e
https://github.com/42wim/matterbridge/blob/1b2feb19e506bc24580d5d61422d0de68349c24e/bridge/xmpp/xmpp.go#L260-L284
train
go-acme/lego
challenge/dns01/dns_challenge.go
CondOption
func CondOption(condition bool, opt ChallengeOption) ChallengeOption { if !condition { // NoOp options return func(*Challenge) error { return nil } } return opt }
go
func CondOption(condition bool, opt ChallengeOption) ChallengeOption { if !condition { // NoOp options return func(*Challenge) error { return nil } } return opt }
[ "func", "CondOption", "(", "condition", "bool", ",", "opt", "ChallengeOption", ")", "ChallengeOption", "{", "if", "!", "condition", "{", "// NoOp options", "return", "func", "(", "*", "Challenge", ")", "error", "{", "return", "nil", "\n", "}", "\n", "}", "...
// CondOption Conditional challenge option.
[ "CondOption", "Conditional", "challenge", "option", "." ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/dns01/dns_challenge.go#L35-L43
train
go-acme/lego
challenge/dns01/dns_challenge.go
PreSolve
func (c *Challenge) PreSolve(authz acme.Authorization) error { domain := challenge.GetTargetedDomain(authz) log.Infof("[%s] acme: Preparing to solve DNS-01", domain) chlng, err := challenge.FindChallenge(challenge.DNS01, authz) if err != nil { return err } if c.provider == nil { return fmt.Errorf("[%s] acme...
go
func (c *Challenge) PreSolve(authz acme.Authorization) error { domain := challenge.GetTargetedDomain(authz) log.Infof("[%s] acme: Preparing to solve DNS-01", domain) chlng, err := challenge.FindChallenge(challenge.DNS01, authz) if err != nil { return err } if c.provider == nil { return fmt.Errorf("[%s] acme...
[ "func", "(", "c", "*", "Challenge", ")", "PreSolve", "(", "authz", "acme", ".", "Authorization", ")", "error", "{", "domain", ":=", "challenge", ".", "GetTargetedDomain", "(", "authz", ")", "\n", "log", ".", "Infof", "(", "\"", "\"", ",", "domain", ")"...
// PreSolve just submits the txt record to the dns provider. // It does not validate record propagation, or do anything at all with the acme server.
[ "PreSolve", "just", "submits", "the", "txt", "record", "to", "the", "dns", "provider", ".", "It", "does", "not", "validate", "record", "propagation", "or", "do", "anything", "at", "all", "with", "the", "acme", "server", "." ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/dns01/dns_challenge.go#L75-L100
train
go-acme/lego
challenge/dns01/dns_challenge.go
CleanUp
func (c *Challenge) CleanUp(authz acme.Authorization) error { log.Infof("[%s] acme: Cleaning DNS-01 challenge", challenge.GetTargetedDomain(authz)) chlng, err := challenge.FindChallenge(challenge.DNS01, authz) if err != nil { return err } keyAuth, err := c.core.GetKeyAuthorization(chlng.Token) if err != nil {...
go
func (c *Challenge) CleanUp(authz acme.Authorization) error { log.Infof("[%s] acme: Cleaning DNS-01 challenge", challenge.GetTargetedDomain(authz)) chlng, err := challenge.FindChallenge(challenge.DNS01, authz) if err != nil { return err } keyAuth, err := c.core.GetKeyAuthorization(chlng.Token) if err != nil {...
[ "func", "(", "c", "*", "Challenge", ")", "CleanUp", "(", "authz", "acme", ".", "Authorization", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "challenge", ".", "GetTargetedDomain", "(", "authz", ")", ")", "\n\n", "chlng", ",", "err", ...
// CleanUp cleans the challenge.
[ "CleanUp", "cleans", "the", "challenge", "." ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/dns01/dns_challenge.go#L145-L159
train
go-acme/lego
challenge/dns01/dns_challenge.go
GetRecord
func GetRecord(domain, keyAuth string) (fqdn string, value string) { keyAuthShaBytes := sha256.Sum256([]byte(keyAuth)) // base64URL encoding without padding value = base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size]) fqdn = fmt.Sprintf("_acme-challenge.%s.", domain) if ok, _ := strconv.ParseBool(o...
go
func GetRecord(domain, keyAuth string) (fqdn string, value string) { keyAuthShaBytes := sha256.Sum256([]byte(keyAuth)) // base64URL encoding without padding value = base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size]) fqdn = fmt.Sprintf("_acme-challenge.%s.", domain) if ok, _ := strconv.ParseBool(o...
[ "func", "GetRecord", "(", "domain", ",", "keyAuth", "string", ")", "(", "fqdn", "string", ",", "value", "string", ")", "{", "keyAuthShaBytes", ":=", "sha256", ".", "Sum256", "(", "[", "]", "byte", "(", "keyAuth", ")", ")", "\n", "// base64URL encoding with...
// GetRecord returns a DNS record which will fulfill the `dns-01` challenge
[ "GetRecord", "returns", "a", "DNS", "record", "which", "will", "fulfill", "the", "dns", "-", "01", "challenge" ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/challenge/dns01/dns_challenge.go#L173-L188
train
go-acme/lego
providers/dns/dnsmadeeasy/dnsmadeeasy.go
NewDNSProviderConfig
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { if config == nil { return nil, errors.New("dnsmadeeasy: the configuration of the DNS provider is nil") } var baseURL string if config.Sandbox { baseURL = "https://api.sandbox.dnsmadeeasy.com/V2.0" } else { if len(config.BaseURL) > 0 { base...
go
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { if config == nil { return nil, errors.New("dnsmadeeasy: the configuration of the DNS provider is nil") } var baseURL string if config.Sandbox { baseURL = "https://api.sandbox.dnsmadeeasy.com/V2.0" } else { if len(config.BaseURL) > 0 { base...
[ "func", "NewDNSProviderConfig", "(", "config", "*", "Config", ")", "(", "*", "DNSProvider", ",", "error", ")", "{", "if", "config", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "baseURL...
// NewDNSProviderConfig return a DNSProvider instance configured for DNS Made Easy.
[ "NewDNSProviderConfig", "return", "a", "DNSProvider", "instance", "configured", "for", "DNS", "Made", "Easy", "." ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dnsmadeeasy/dnsmadeeasy.go#L69-L97
train
go-acme/lego
providers/dns/dnsmadeeasy/dnsmadeeasy.go
CleanUp
func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domainName, keyAuth) authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return fmt.Errorf("dnsmadeeasy: unable to find zone for %s: %v", fqdn, err) } // fetch the domain details domain, err := d.client...
go
func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domainName, keyAuth) authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return fmt.Errorf("dnsmadeeasy: unable to find zone for %s: %v", fqdn, err) } // fetch the domain details domain, err := d.client...
[ "func", "(", "d", "*", "DNSProvider", ")", "CleanUp", "(", "domainName", ",", "token", ",", "keyAuth", "string", ")", "error", "{", "fqdn", ",", "_", ":=", "dns01", ".", "GetRecord", "(", "domainName", ",", "keyAuth", ")", "\n\n", "authZone", ",", "err...
// CleanUp removes the TXT records matching the specified parameters
[ "CleanUp", "removes", "the", "TXT", "records", "matching", "the", "specified", "parameters" ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/dnsmadeeasy/dnsmadeeasy.go#L126-L157
train
go-acme/lego
providers/dns/zoneee/zoneee.go
CleanUp
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { _, value := dns01.GetRecord(domain, keyAuth) records, err := d.getTxtRecords(domain) if err != nil { return fmt.Errorf("zoneee: %v", err) } var id string for _, record := range records { if record.Destination == value { id = record.ID ...
go
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { _, value := dns01.GetRecord(domain, keyAuth) records, err := d.getTxtRecords(domain) if err != nil { return fmt.Errorf("zoneee: %v", err) } var id string for _, record := range records { if record.Destination == value { id = record.ID ...
[ "func", "(", "d", "*", "DNSProvider", ")", "CleanUp", "(", "domain", ",", "token", ",", "keyAuth", "string", ")", "error", "{", "_", ",", "value", ":=", "dns01", ".", "GetRecord", "(", "domain", ",", "keyAuth", ")", "\n\n", "records", ",", "err", ":=...
// CleanUp removes the TXT record previously created
[ "CleanUp", "removes", "the", "TXT", "record", "previously", "created" ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/zoneee/zoneee.go#L110-L134
train
go-acme/lego
providers/dns/iij/iij.go
NewDNSProviderConfig
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { if config.SecretKey == "" || config.AccessKey == "" || config.DoServiceCode == "" { return nil, fmt.Errorf("iij: credentials missing") } return &DNSProvider{ api: doapi.NewAPI(config.AccessKey, config.SecretKey), config: config, }, nil }
go
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { if config.SecretKey == "" || config.AccessKey == "" || config.DoServiceCode == "" { return nil, fmt.Errorf("iij: credentials missing") } return &DNSProvider{ api: doapi.NewAPI(config.AccessKey, config.SecretKey), config: config, }, nil }
[ "func", "NewDNSProviderConfig", "(", "config", "*", "Config", ")", "(", "*", "DNSProvider", ",", "error", ")", "{", "if", "config", ".", "SecretKey", "==", "\"", "\"", "||", "config", ".", "AccessKey", "==", "\"", "\"", "||", "config", ".", "DoServiceCod...
// NewDNSProviderConfig takes a given config // and returns a custom configured DNSProvider instance
[ "NewDNSProviderConfig", "takes", "a", "given", "config", "and", "returns", "a", "custom", "configured", "DNSProvider", "instance" ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/iij/iij.go#L58-L67
train
go-acme/lego
providers/dns/rackspace/client.go
getHostedZoneID
func (d *DNSProvider) getHostedZoneID(fqdn string) (int, error) { authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return 0, err } result, err := d.makeRequest(http.MethodGet, fmt.Sprintf("/domains?name=%s", dns01.UnFqdn(authZone)), nil) if err != nil { return 0, err } var zoneSearchResponse Zon...
go
func (d *DNSProvider) getHostedZoneID(fqdn string) (int, error) { authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return 0, err } result, err := d.makeRequest(http.MethodGet, fmt.Sprintf("/domains?name=%s", dns01.UnFqdn(authZone)), nil) if err != nil { return 0, err } var zoneSearchResponse Zon...
[ "func", "(", "d", "*", "DNSProvider", ")", "getHostedZoneID", "(", "fqdn", "string", ")", "(", "int", ",", "error", ")", "{", "authZone", ",", "err", ":=", "dns01", ".", "FindZoneByFqdn", "(", "fqdn", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// getHostedZoneID performs a lookup to get the DNS zone which needs // modifying for a given FQDN
[ "getHostedZoneID", "performs", "a", "lookup", "to", "get", "the", "DNS", "zone", "which", "needs", "modifying", "for", "a", "given", "FQDN" ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/rackspace/client.go#L85-L108
train
go-acme/lego
providers/dns/rackspace/client.go
findTxtRecord
func (d *DNSProvider) findTxtRecord(fqdn string, zoneID int) (*Record, error) { result, err := d.makeRequest(http.MethodGet, fmt.Sprintf("/domains/%d/records?type=TXT&name=%s", zoneID, dns01.UnFqdn(fqdn)), nil) if err != nil { return nil, err } var records Records err = json.Unmarshal(result, &records) if err ...
go
func (d *DNSProvider) findTxtRecord(fqdn string, zoneID int) (*Record, error) { result, err := d.makeRequest(http.MethodGet, fmt.Sprintf("/domains/%d/records?type=TXT&name=%s", zoneID, dns01.UnFqdn(fqdn)), nil) if err != nil { return nil, err } var records Records err = json.Unmarshal(result, &records) if err ...
[ "func", "(", "d", "*", "DNSProvider", ")", "findTxtRecord", "(", "fqdn", "string", ",", "zoneID", "int", ")", "(", "*", "Record", ",", "error", ")", "{", "result", ",", "err", ":=", "d", ".", "makeRequest", "(", "http", ".", "MethodGet", ",", "fmt", ...
// findTxtRecord searches a DNS zone for a TXT record with a specific name
[ "findTxtRecord", "searches", "a", "DNS", "zone", "for", "a", "TXT", "record", "with", "a", "specific", "name" ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/rackspace/client.go#L111-L132
train
go-acme/lego
providers/dns/rackspace/client.go
makeRequest
func (d *DNSProvider) makeRequest(method, uri string, body io.Reader) (json.RawMessage, error) { url := d.cloudDNSEndpoint + uri req, err := http.NewRequest(method, url, body) if err != nil { return nil, err } req.Header.Set("X-Auth-Token", d.token) req.Header.Set("Content-Type", "application/json") resp, e...
go
func (d *DNSProvider) makeRequest(method, uri string, body io.Reader) (json.RawMessage, error) { url := d.cloudDNSEndpoint + uri req, err := http.NewRequest(method, url, body) if err != nil { return nil, err } req.Header.Set("X-Auth-Token", d.token) req.Header.Set("Content-Type", "application/json") resp, e...
[ "func", "(", "d", "*", "DNSProvider", ")", "makeRequest", "(", "method", ",", "uri", "string", ",", "body", "io", ".", "Reader", ")", "(", "json", ".", "RawMessage", ",", "error", ")", "{", "url", ":=", "d", ".", "cloudDNSEndpoint", "+", "uri", "\n\n...
// makeRequest is a wrapper function used for making DNS API requests
[ "makeRequest", "is", "a", "wrapper", "function", "used", "for", "making", "DNS", "API", "requests" ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/rackspace/client.go#L135-L164
train
go-acme/lego
providers/dns/rackspace/rackspace.go
NewDNSProviderConfig
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { if config == nil { return nil, errors.New("rackspace: the configuration of the DNS provider is nil") } if config.APIUser == "" || config.APIKey == "" { return nil, fmt.Errorf("rackspace: credentials missing") } identity, err := login(config) ...
go
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { if config == nil { return nil, errors.New("rackspace: the configuration of the DNS provider is nil") } if config.APIUser == "" || config.APIKey == "" { return nil, fmt.Errorf("rackspace: credentials missing") } identity, err := login(config) ...
[ "func", "NewDNSProviderConfig", "(", "config", "*", "Config", ")", "(", "*", "DNSProvider", ",", "error", ")", "{", "if", "config", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "config",...
// NewDNSProviderConfig return a DNSProvider instance configured for Rackspace. // It authenticates against the API, also grabbing the DNS Endpoint.
[ "NewDNSProviderConfig", "return", "a", "DNSProvider", "instance", "configured", "for", "Rackspace", ".", "It", "authenticates", "against", "the", "API", "also", "grabbing", "the", "DNS", "Endpoint", "." ]
29c63545ce6fffd8289c55c39d81c4fde993533d
https://github.com/go-acme/lego/blob/29c63545ce6fffd8289c55c39d81c4fde993533d/providers/dns/rackspace/rackspace.go#L69-L102
train