id
int32
0
167k
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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
126,900
go-playground/log
log.go
WithError
func WithError(err error) Entry { ne := newEntryWithFields(logFields) return withErrFn(ne, err) }
go
func WithError(err error) Entry { ne := newEntryWithFields(logFields) return withErrFn(ne, err) }
[ "func", "WithError", "(", "err", "error", ")", "Entry", "{", "ne", ":=", "newEntryWithFields", "(", "logFields", ")", "\n", "return", "withErrFn", "(", "ne", ",", "err", ")", "\n", "}" ]
// WithError add a minimal stack trace to the log Entry
[ "WithError", "add", "a", "minimal", "stack", "trace", "to", "the", "log", "Entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L166-L169
126,901
go-playground/log
log.go
Infof
func Infof(s string, v ...interface{}) { e := newEntryWithFields(logFields) e.Infof(s, v...) }
go
func Infof(s string, v ...interface{}) { e := newEntryWithFields(logFields) e.Infof(s, v...) }
[ "func", "Infof", "(", "s", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "e", ":=", "newEntryWithFields", "(", "logFields", ")", "\n", "e", ".", "Infof", "(", "s", ",", "v", "...", ")", "\n", "}" ]
// Infof logs a normal. information, entry with formatiing
[ "Infof", "logs", "a", "normal", ".", "information", "entry", "with", "formatiing" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/log.go#L190-L193
126,902
go-playground/log
errors/segmentio/segmentio.go
ErrorsGoWithError
func ErrorsGoWithError(e log.Entry, err error) log.Entry { // normally would call newEntry, but instead will shallow copy // because it's not exposed. ne := new(log.Entry) *ne = *(&e) flds := make([]log.Field, 0, len(e.Fields)) flds = append(flds, e.Fields...) flds = append(flds, log.Field{Key: "error", Value: ...
go
func ErrorsGoWithError(e log.Entry, err error) log.Entry { // normally would call newEntry, but instead will shallow copy // because it's not exposed. ne := new(log.Entry) *ne = *(&e) flds := make([]log.Field, 0, len(e.Fields)) flds = append(flds, e.Fields...) flds = append(flds, log.Field{Key: "error", Value: ...
[ "func", "ErrorsGoWithError", "(", "e", "log", ".", "Entry", ",", "err", "error", ")", "log", ".", "Entry", "{", "// normally would call newEntry, but instead will shallow copy", "// because it's not exposed.", "ne", ":=", "new", "(", "log", ".", "Entry", ")", "\n", ...
// ErrorsGoWithError is a custom WithError function that can be used by using log's // SetWithErrorFn function.
[ "ErrorsGoWithError", "is", "a", "custom", "WithError", "function", "that", "can", "be", "used", "by", "using", "log", "s", "SetWithErrorFn", "function", "." ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/errors/segmentio/segmentio.go#L18-L51
126,903
go-playground/log
handlers/console/console.go
New
func New(redirectSTDOut bool) *Console { if redirectSTDOut { done := make(chan struct{}) go handleStdLogger(done) <-done // have to wait, it was running too quickly and some messages can be lost } return &Console{ colors: defaultColors, writer: os.Stderr, timestampFormat: "2006-01-02 1...
go
func New(redirectSTDOut bool) *Console { if redirectSTDOut { done := make(chan struct{}) go handleStdLogger(done) <-done // have to wait, it was running too quickly and some messages can be lost } return &Console{ colors: defaultColors, writer: os.Stderr, timestampFormat: "2006-01-02 1...
[ "func", "New", "(", "redirectSTDOut", "bool", ")", "*", "Console", "{", "if", "redirectSTDOut", "{", "done", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "go", "handleStdLogger", "(", "done", ")", "\n", "<-", "done", "// have to wait, it was r...
// New returns a new instance of the console logger
[ "New", "returns", "a", "new", "instance", "of", "the", "console", "logger" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/console/console.go#L44-L57
126,904
go-playground/log
handlers/console/console.go
handleStdLogger
func handleStdLogger(done chan<- struct{}) { r, w := io.Pipe() defer func() { _ = r.Close() _ = w.Close() }() stdlog.SetOutput(w) scanner := bufio.NewScanner(r) go func() { done <- struct{}{} }() for scanner.Scan() { log.WithField("stdlog", true).Info(scanner.Text()) } }
go
func handleStdLogger(done chan<- struct{}) { r, w := io.Pipe() defer func() { _ = r.Close() _ = w.Close() }() stdlog.SetOutput(w) scanner := bufio.NewScanner(r) go func() { done <- struct{}{} }() for scanner.Scan() { log.WithField("stdlog", true).Info(scanner.Text()) } }
[ "func", "handleStdLogger", "(", "done", "chan", "<-", "struct", "{", "}", ")", "{", "r", ",", "w", ":=", "io", ".", "Pipe", "(", ")", "\n", "defer", "func", "(", ")", "{", "_", "=", "r", ".", "Close", "(", ")", "\n", "_", "=", "w", ".", "Cl...
// this will redirect the output of
[ "this", "will", "redirect", "the", "output", "of" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/console/console.go#L78-L96
126,905
go-playground/log
entry.go
Debug
func (e Entry) Debug(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = DebugLevel HandleEntry(e) }
go
func (e Entry) Debug(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = DebugLevel HandleEntry(e) }
[ "func", "(", "e", "Entry", ")", "Debug", "(", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprint", "(", "v", "...", ")", "\n", "e", ".", "Level", "=", "DebugLevel", "\n", "HandleEntry", "(", "e", ")", "\n...
// Debug logs a debug entry
[ "Debug", "logs", "a", "debug", "entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L61-L65
126,906
go-playground/log
entry.go
Info
func (e Entry) Info(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = InfoLevel HandleEntry(e) }
go
func (e Entry) Info(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = InfoLevel HandleEntry(e) }
[ "func", "(", "e", "Entry", ")", "Info", "(", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprint", "(", "v", "...", ")", "\n", "e", ".", "Level", "=", "InfoLevel", "\n", "HandleEntry", "(", "e", ")", "\n",...
// Info logs a normal. information, entry
[ "Info", "logs", "a", "normal", ".", "information", "entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L75-L79
126,907
go-playground/log
entry.go
Infof
func (e Entry) Infof(s string, v ...interface{}) { e.Message = fmt.Sprintf(s, v...) e.Level = InfoLevel HandleEntry(e) }
go
func (e Entry) Infof(s string, v ...interface{}) { e.Message = fmt.Sprintf(s, v...) e.Level = InfoLevel HandleEntry(e) }
[ "func", "(", "e", "Entry", ")", "Infof", "(", "s", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprintf", "(", "s", ",", "v", "...", ")", "\n", "e", ".", "Level", "=", "InfoLevel", "\n", "...
// Infof logs a normal. information, entry with formatting
[ "Infof", "logs", "a", "normal", ".", "information", "entry", "with", "formatting" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L82-L86
126,908
go-playground/log
entry.go
Notice
func (e Entry) Notice(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = NoticeLevel HandleEntry(e) }
go
func (e Entry) Notice(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = NoticeLevel HandleEntry(e) }
[ "func", "(", "e", "Entry", ")", "Notice", "(", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprint", "(", "v", "...", ")", "\n", "e", ".", "Level", "=", "NoticeLevel", "\n", "HandleEntry", "(", "e", ")", "...
// Notice logs a notice log entry
[ "Notice", "logs", "a", "notice", "log", "entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L89-L93
126,909
go-playground/log
entry.go
Warn
func (e Entry) Warn(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = WarnLevel HandleEntry(e) }
go
func (e Entry) Warn(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = WarnLevel HandleEntry(e) }
[ "func", "(", "e", "Entry", ")", "Warn", "(", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprint", "(", "v", "...", ")", "\n", "e", ".", "Level", "=", "WarnLevel", "\n", "HandleEntry", "(", "e", ")", "\n",...
// Warn logs a warn log entry
[ "Warn", "logs", "a", "warn", "log", "entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L103-L107
126,910
go-playground/log
entry.go
Panic
func (e Entry) Panic(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = PanicLevel HandleEntry(e) exitFunc(1) }
go
func (e Entry) Panic(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = PanicLevel HandleEntry(e) exitFunc(1) }
[ "func", "(", "e", "Entry", ")", "Panic", "(", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprint", "(", "v", "...", ")", "\n", "e", ".", "Level", "=", "PanicLevel", "\n", "HandleEntry", "(", "e", ")", "\n...
// Panic logs a panic log entry
[ "Panic", "logs", "a", "panic", "log", "entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L117-L122
126,911
go-playground/log
entry.go
Alert
func (e Entry) Alert(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = AlertLevel HandleEntry(e) }
go
func (e Entry) Alert(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = AlertLevel HandleEntry(e) }
[ "func", "(", "e", "Entry", ")", "Alert", "(", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprint", "(", "v", "...", ")", "\n", "e", ".", "Level", "=", "AlertLevel", "\n", "HandleEntry", "(", "e", ")", "\n...
// Alert logs an alert log entry
[ "Alert", "logs", "an", "alert", "log", "entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L133-L137
126,912
go-playground/log
entry.go
Fatal
func (e Entry) Fatal(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = FatalLevel HandleEntry(e) exitFunc(1) }
go
func (e Entry) Fatal(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = FatalLevel HandleEntry(e) exitFunc(1) }
[ "func", "(", "e", "Entry", ")", "Fatal", "(", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprint", "(", "v", "...", ")", "\n", "e", ".", "Level", "=", "FatalLevel", "\n", "HandleEntry", "(", "e", ")", "\n...
// Fatal logs a fatal log entry
[ "Fatal", "logs", "a", "fatal", "log", "entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L147-L152
126,913
go-playground/log
entry.go
Error
func (e Entry) Error(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = ErrorLevel HandleEntry(e) }
go
func (e Entry) Error(v ...interface{}) { e.Message = fmt.Sprint(v...) e.Level = ErrorLevel HandleEntry(e) }
[ "func", "(", "e", "Entry", ")", "Error", "(", "v", "...", "interface", "{", "}", ")", "{", "e", ".", "Message", "=", "fmt", ".", "Sprint", "(", "v", "...", ")", "\n", "e", ".", "Level", "=", "ErrorLevel", "\n", "HandleEntry", "(", "e", ")", "\n...
// Error logs an error log entry
[ "Error", "logs", "an", "error", "log", "entry" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/entry.go#L163-L167
126,914
go-playground/log
errors/pkg/pkg.go
ErrorsWithError
func ErrorsWithError(e log.Entry, err error) log.Entry { // normally would call newEntry, but instead will shallow copy // because it's not exposed. ne := new(log.Entry) *ne = *(&e) flds := make([]log.Field, 0, len(e.Fields)) flds = append(flds, e.Fields...) flds = append(flds, log.Field{Key: "error", Value: er...
go
func ErrorsWithError(e log.Entry, err error) log.Entry { // normally would call newEntry, but instead will shallow copy // because it's not exposed. ne := new(log.Entry) *ne = *(&e) flds := make([]log.Field, 0, len(e.Fields)) flds = append(flds, e.Fields...) flds = append(flds, log.Field{Key: "error", Value: er...
[ "func", "ErrorsWithError", "(", "e", "log", ".", "Entry", ",", "err", "error", ")", "log", ".", "Entry", "{", "// normally would call newEntry, but instead will shallow copy", "// because it's not exposed.", "ne", ":=", "new", "(", "log", ".", "Entry", ")", "\n", ...
// ErrorsWithError is a custom WithError function that can be used by using log's // SetWithErrorFn function.
[ "ErrorsWithError", "is", "a", "custom", "WithError", "function", "that", "can", "be", "used", "by", "using", "log", "s", "SetWithErrorFn", "function", "." ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/errors/pkg/pkg.go#L17-L45
126,915
go-playground/log
handlers/syslog/syslog.go
GetDisplayColor
func (s *Syslog) GetDisplayColor(level log.Level) ansi.EscSeq { return s.colors[level] }
go
func (s *Syslog) GetDisplayColor(level log.Level) ansi.EscSeq { return s.colors[level] }
[ "func", "(", "s", "*", "Syslog", ")", "GetDisplayColor", "(", "level", "log", ".", "Level", ")", "ansi", ".", "EscSeq", "{", "return", "s", ".", "colors", "[", "level", "]", "\n", "}" ]
// GetDisplayColor returns the color for the given log level
[ "GetDisplayColor", "returns", "the", "color", "for", "the", "given", "log", "level" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/syslog/syslog.go#L93-L95
126,916
go-playground/log
handlers/email/email.go
New
func New(host string, port int, username string, password string, from string, to []string) *Email { e := &Email{ enabled: true, timestampFormat: log.DefaultTimeFormat, host: host, port: port, username: username, password: password, from: from, to:...
go
func New(host string, port int, username string, password string, from string, to []string) *Email { e := &Email{ enabled: true, timestampFormat: log.DefaultTimeFormat, host: host, port: port, username: username, password: password, from: from, to:...
[ "func", "New", "(", "host", "string", ",", "port", "int", ",", "username", "string", ",", "password", "string", ",", "from", "string", ",", "to", "[", "]", "string", ")", "*", "Email", "{", "e", ":=", "&", "Email", "{", "enabled", ":", "true", ",",...
// New returns a new instance of the email logger
[ "New", "returns", "a", "new", "instance", "of", "the", "email", "logger" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/email/email.go#L54-L68
126,917
go-playground/log
handlers/email/email.go
SetTemplate
func (email *Email) SetTemplate(htmlTemplate string) { email.rw.Lock() defer email.rw.Unlock() // parse email htmlTemplate, will panic if fails email.template = template.Must(template.New("email").Funcs( template.FuncMap{ "ts": func(e log.Entry) (ts string) { ts = e.Timestamp.Format(email.timestampFormat)...
go
func (email *Email) SetTemplate(htmlTemplate string) { email.rw.Lock() defer email.rw.Unlock() // parse email htmlTemplate, will panic if fails email.template = template.Must(template.New("email").Funcs( template.FuncMap{ "ts": func(e log.Entry) (ts string) { ts = e.Timestamp.Format(email.timestampFormat)...
[ "func", "(", "email", "*", "Email", ")", "SetTemplate", "(", "htmlTemplate", "string", ")", "{", "email", ".", "rw", ".", "Lock", "(", ")", "\n", "defer", "email", ".", "rw", ".", "Unlock", "(", ")", "\n\n", "// parse email htmlTemplate, will panic if fails"...
// SetTemplate sets Email's html template to be used for email body
[ "SetTemplate", "sets", "Email", "s", "html", "template", "to", "be", "used", "for", "email", "body" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/email/email.go#L71-L84
126,918
go-playground/log
handlers/email/email.go
SetFormatFunc
func (email *Email) SetFormatFunc(fn FormatFunc) { email.rw.Lock() defer email.rw.Unlock() email.formatFunc = fn }
go
func (email *Email) SetFormatFunc(fn FormatFunc) { email.rw.Lock() defer email.rw.Unlock() email.formatFunc = fn }
[ "func", "(", "email", "*", "Email", ")", "SetFormatFunc", "(", "fn", "FormatFunc", ")", "{", "email", ".", "rw", ".", "Lock", "(", ")", "\n", "defer", "email", ".", "rw", ".", "Unlock", "(", ")", "\n\n", "email", ".", "formatFunc", "=", "fn", "\n",...
// SetFormatFunc sets FormatFunc each worker will call to get // a Formatter func
[ "SetFormatFunc", "sets", "FormatFunc", "each", "worker", "will", "call", "to", "get", "a", "Formatter", "func" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/email/email.go#L112-L117
126,919
go-playground/log
handlers/email/email.go
SetEmailConfig
func (email *Email) SetEmailConfig(host string, port int, username string, password string, from string, to []string) { email.rw.Lock() defer email.rw.Unlock() email.host = host email.port = port email.username = username email.password = password email.from = from email.to = to email.formatter = email.format...
go
func (email *Email) SetEmailConfig(host string, port int, username string, password string, from string, to []string) { email.rw.Lock() defer email.rw.Unlock() email.host = host email.port = port email.username = username email.password = password email.from = from email.to = to email.formatter = email.format...
[ "func", "(", "email", "*", "Email", ")", "SetEmailConfig", "(", "host", "string", ",", "port", "int", ",", "username", "string", ",", "password", "string", ",", "from", "string", ",", "to", "[", "]", "string", ")", "{", "email", ".", "rw", ".", "Lock...
// SetEmailConfig allows updating of the email config in flight and is thread safe.
[ "SetEmailConfig", "allows", "updating", "of", "the", "email", "config", "in", "flight", "and", "is", "thread", "safe", "." ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/email/email.go#L120-L131
126,920
go-playground/log
handlers/email/email.go
SetEnabled
func (email *Email) SetEnabled(enabled bool) { email.rw.Lock() defer email.rw.Unlock() email.enabled = enabled }
go
func (email *Email) SetEnabled(enabled bool) { email.rw.Lock() defer email.rw.Unlock() email.enabled = enabled }
[ "func", "(", "email", "*", "Email", ")", "SetEnabled", "(", "enabled", "bool", ")", "{", "email", ".", "rw", ".", "Lock", "(", ")", "\n", "defer", "email", ".", "rw", ".", "Unlock", "(", ")", "\n\n", "email", ".", "enabled", "=", "enabled", "\n", ...
// SetEnabled enables or disables the email handler sending emails
[ "SetEnabled", "enables", "or", "disables", "the", "email", "handler", "sending", "emails" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/email/email.go#L134-L139
126,921
go-playground/log
_examples/custom-handler/main.go
Log
func (c *CustomHandler) Log(e log.Entry) { // below prints to os.Stderr but could marshal to JSON // and send to central logging server // --------- // |----------> | console | // ...
go
func (c *CustomHandler) Log(e log.Entry) { // below prints to os.Stderr but could marshal to JSON // and send to central logging server // --------- // |----------> | console | // ...
[ "func", "(", "c", "*", "CustomHandler", ")", "Log", "(", "e", "log", ".", "Entry", ")", "{", "// below prints to os.Stderr but could marshal to JSON", "// and send to central logging server", "//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ---------", "// \t\t\t\t ...
// Log accepts log entries to be processed
[ "Log", "accepts", "log", "entries", "to", "be", "processed" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/_examples/custom-handler/main.go#L16-L37
126,922
go-playground/log
handlers/http/http.go
New
func New(remoteHost string, method string, header stdhttp.Header) (*HTTP, error) { if _, err := url.Parse(remoteHost); err != nil { return nil, err } h := &HTTP{ remoteHost: remoteHost, timestampFormat: log.DefaultTimeFormat, header: header, method: method, client: stdhtt...
go
func New(remoteHost string, method string, header stdhttp.Header) (*HTTP, error) { if _, err := url.Parse(remoteHost); err != nil { return nil, err } h := &HTTP{ remoteHost: remoteHost, timestampFormat: log.DefaultTimeFormat, header: header, method: method, client: stdhtt...
[ "func", "New", "(", "remoteHost", "string", ",", "method", "string", ",", "header", "stdhttp", ".", "Header", ")", "(", "*", "HTTP", ",", "error", ")", "{", "if", "_", ",", "err", ":=", "url", ".", "Parse", "(", "remoteHost", ")", ";", "err", "!=",...
// New returns a new instance of the http logger
[ "New", "returns", "a", "new", "instance", "of", "the", "http", "logger" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/http/http.go#L43-L57
126,923
go-playground/log
handlers/http/hipchat/hipchat.go
New
func New(api APIVersion, remoteHost string, contentType string, authToken string, application string) (*HipChat, error) { // test here https://developer.atlassian.com/hipchat/guide/hipchat-rest-api that api token has access authToken = "Bearer " + authToken client := &stdhttp.Client{} req, err := stdhttp.NewReque...
go
func New(api APIVersion, remoteHost string, contentType string, authToken string, application string) (*HipChat, error) { // test here https://developer.atlassian.com/hipchat/guide/hipchat-rest-api that api token has access authToken = "Bearer " + authToken client := &stdhttp.Client{} req, err := stdhttp.NewReque...
[ "func", "New", "(", "api", "APIVersion", ",", "remoteHost", "string", ",", "contentType", "string", ",", "authToken", "string", ",", "application", "string", ")", "(", "*", "HipChat", ",", "error", ")", "{", "// test here https://developer.atlassian.com/hipchat/guid...
// New returns a new instance of the HipChat logger
[ "New", "returns", "a", "new", "instance", "of", "the", "HipChat", "logger" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/http/hipchat/hipchat.go#L121-L159
126,924
go-playground/log
handlers/http/hipchat/hipchat.go
SetTemplate
func (hc *HipChat) SetTemplate(htmlTemplate string) { hc.template = template.Must(template.New("hipchat").Funcs( template.FuncMap{ "ts": func(e log.Entry) (ts string) { ts = e.Timestamp.Format(hc.TimestampFormat()) return }, }, ).Parse(htmlTemplate)) }
go
func (hc *HipChat) SetTemplate(htmlTemplate string) { hc.template = template.Must(template.New("hipchat").Funcs( template.FuncMap{ "ts": func(e log.Entry) (ts string) { ts = e.Timestamp.Format(hc.TimestampFormat()) return }, }, ).Parse(htmlTemplate)) }
[ "func", "(", "hc", "*", "HipChat", ")", "SetTemplate", "(", "htmlTemplate", "string", ")", "{", "hc", ".", "template", "=", "template", ".", "Must", "(", "template", ".", "New", "(", "\"", "\"", ")", ".", "Funcs", "(", "template", ".", "FuncMap", "{"...
// SetTemplate sets Hipchats html template to be used for email body
[ "SetTemplate", "sets", "Hipchats", "html", "template", "to", "be", "used", "for", "email", "body" ]
fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19
https://github.com/go-playground/log/blob/fdcdf507e3bf20900bc1a44b0cbd73fee5bcbe19/handlers/http/hipchat/hipchat.go#L162-L171
126,925
itsabot/itsabot
core/util.go
RandAlphaNumSeq
func RandAlphaNumSeq(n int) string { b := make([]rune, n) for i := range b { b[i] = alphaNum[rand.Intn(len(alphaNum))] } return string(b) }
go
func RandAlphaNumSeq(n int) string { b := make([]rune, n) for i := range b { b[i] = alphaNum[rand.Intn(len(alphaNum))] } return string(b) }
[ "func", "RandAlphaNumSeq", "(", "n", "int", ")", "string", "{", "b", ":=", "make", "(", "[", "]", "rune", ",", "n", ")", "\n", "for", "i", ":=", "range", "b", "{", "b", "[", "i", "]", "=", "alphaNum", "[", "rand", ".", "Intn", "(", "len", "("...
// RandAlphaNumSeq generates a random sequence of alpha-numeric characters of // length n.
[ "RandAlphaNumSeq", "generates", "a", "random", "sequence", "of", "alpha", "-", "numeric", "characters", "of", "length", "n", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/util.go#L26-L32
126,926
itsabot/itsabot
shared/datatypes/scheduled_event.go
Send
func (s *ScheduledEvent) Send(c *sms.Conn) error { switch s.FlexIDType { case FIDTPhone: if err := c.Send(s.FlexID, s.Content); err != nil { return err } default: return fmt.Errorf("unrecognized flexidtype: %d", s.FlexIDType) } return nil }
go
func (s *ScheduledEvent) Send(c *sms.Conn) error { switch s.FlexIDType { case FIDTPhone: if err := c.Send(s.FlexID, s.Content); err != nil { return err } default: return fmt.Errorf("unrecognized flexidtype: %d", s.FlexIDType) } return nil }
[ "func", "(", "s", "*", "ScheduledEvent", ")", "Send", "(", "c", "*", "sms", ".", "Conn", ")", "error", "{", "switch", "s", ".", "FlexIDType", "{", "case", "FIDTPhone", ":", "if", "err", ":=", "c", ".", "Send", "(", "s", ".", "FlexID", ",", "s", ...
// Send a scheduled event. Currently only phones are supported.
[ "Send", "a", "scheduled", "event", ".", "Currently", "only", "phones", "are", "supported", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/scheduled_event.go#L20-L30
126,927
itsabot/itsabot
core/process.go
preprocess
func preprocess(r *http.Request) (*dt.Msg, error) { req := &dt.Request{} err := json.NewDecoder(r.Body).Decode(req) if err != nil { log.Info("could not parse empty body", err) return nil, err } sendPostReceiveEvent(&req.CMD) u, err := dt.GetUser(db, req) if err != nil { return nil, err } sendPreProcessin...
go
func preprocess(r *http.Request) (*dt.Msg, error) { req := &dt.Request{} err := json.NewDecoder(r.Body).Decode(req) if err != nil { log.Info("could not parse empty body", err) return nil, err } sendPostReceiveEvent(&req.CMD) u, err := dt.GetUser(db, req) if err != nil { return nil, err } sendPreProcessin...
[ "func", "preprocess", "(", "r", "*", "http", ".", "Request", ")", "(", "*", "dt", ".", "Msg", ",", "error", ")", "{", "req", ":=", "&", "dt", ".", "Request", "{", "}", "\n", "err", ":=", "json", ".", "NewDecoder", "(", "r", ".", "Body", ")", ...
// preprocess converts a user input into a Msg that's been persisted to the // database
[ "preprocess", "converts", "a", "user", "input", "into", "a", "Msg", "that", "s", "been", "persisted", "to", "the", "database" ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/process.go#L20-L35
126,928
itsabot/itsabot
core/message.go
NewMsg
func NewMsg(u *dt.User, cmd string) (*dt.Msg, error) { tokens := TokenizeSentence(cmd) stems := StemTokens(tokens) si := ner.classifyTokens(tokens) // Get the intents as determined by each plugin for pluginID, c := range bClassifiers { scores, idx, _ := c.ProbScores(stems) log.Debug("intent score", pluginInte...
go
func NewMsg(u *dt.User, cmd string) (*dt.Msg, error) { tokens := TokenizeSentence(cmd) stems := StemTokens(tokens) si := ner.classifyTokens(tokens) // Get the intents as determined by each plugin for pluginID, c := range bClassifiers { scores, idx, _ := c.ProbScores(stems) log.Debug("intent score", pluginInte...
[ "func", "NewMsg", "(", "u", "*", "dt", ".", "User", ",", "cmd", "string", ")", "(", "*", "dt", ".", "Msg", ",", "error", ")", "{", "tokens", ":=", "TokenizeSentence", "(", "cmd", ")", "\n", "stems", ":=", "StemTokens", "(", "tokens", ")", "\n", "...
// NewMsg builds a message struct with Tokens, Stems, and a Structured Input.
[ "NewMsg", "builds", "a", "message", "struct", "with", "Tokens", "Stems", "and", "a", "Structured", "Input", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/message.go#L9-L39
126,929
itsabot/itsabot
shared/datatypes/message.go
GetMsg
func GetMsg(db *sqlx.DB, id uint64) (*Msg, error) { q := `SELECT id, sentence, abotsent FROM messages WHERE id=$1` m := &Msg{} if err := db.Get(m, q, id); err != nil { return nil, err } return m, nil }
go
func GetMsg(db *sqlx.DB, id uint64) (*Msg, error) { q := `SELECT id, sentence, abotsent FROM messages WHERE id=$1` m := &Msg{} if err := db.Get(m, q, id); err != nil { return nil, err } return m, nil }
[ "func", "GetMsg", "(", "db", "*", "sqlx", ".", "DB", ",", "id", "uint64", ")", "(", "*", "Msg", ",", "error", ")", "{", "q", ":=", "`SELECT id, sentence, abotsent\n\t FROM messages\n\t WHERE id=$1`", "\n", "m", ":=", "&", "Msg", "{", "}", "\n", "...
// GetMsg returns a message for a given message ID.
[ "GetMsg", "returns", "a", "message", "for", "a", "given", "message", "ID", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/message.go#L35-L44
126,930
itsabot/itsabot
shared/datatypes/message.go
Update
func (m *Msg) Update(db *sqlx.DB) error { q := `UPDATE messages SET needstraining=$1 WHERE id=$2` if _, err := db.Exec(q, m.NeedsTraining, m.ID); err != nil { return err } return nil }
go
func (m *Msg) Update(db *sqlx.DB) error { q := `UPDATE messages SET needstraining=$1 WHERE id=$2` if _, err := db.Exec(q, m.NeedsTraining, m.ID); err != nil { return err } return nil }
[ "func", "(", "m", "*", "Msg", ")", "Update", "(", "db", "*", "sqlx", ".", "DB", ")", "error", "{", "q", ":=", "`UPDATE messages SET needstraining=$1 WHERE id=$2`", "\n", "if", "_", ",", "err", ":=", "db", ".", "Exec", "(", "q", ",", "m", ".", "NeedsT...
// Update a message as needing training.
[ "Update", "a", "message", "as", "needing", "training", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/message.go#L47-L53
126,931
itsabot/itsabot
shared/datatypes/message.go
Save
func (m *Msg) Save(db *sqlx.DB) error { var pluginName string if m.Plugin != nil { pluginName = m.Plugin.Config.Name } q := `INSERT INTO messages (userid, sentence, plugin, route, abotsent, needstraining, flexid, flexidtype, trained) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id` row :...
go
func (m *Msg) Save(db *sqlx.DB) error { var pluginName string if m.Plugin != nil { pluginName = m.Plugin.Config.Name } q := `INSERT INTO messages (userid, sentence, plugin, route, abotsent, needstraining, flexid, flexidtype, trained) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id` row :...
[ "func", "(", "m", "*", "Msg", ")", "Save", "(", "db", "*", "sqlx", ".", "DB", ")", "error", "{", "var", "pluginName", "string", "\n", "if", "m", ".", "Plugin", "!=", "nil", "{", "pluginName", "=", "m", ".", "Plugin", ".", "Config", ".", "Name", ...
// Save a message to the database, updating the message ID.
[ "Save", "a", "message", "to", "the", "database", "updating", "the", "message", "ID", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/message.go#L56-L72
126,932
itsabot/itsabot
shared/datatypes/message.go
GetLastPlugin
func (m *Msg) GetLastPlugin(db *sqlx.DB) (string, string, error) { var res struct { Plugin string Route string } var err error if m.User.ID > 0 { q := `SELECT route, plugin FROM messages WHERE userid=$1 AND abotsent IS FALSE ORDER BY createdat DESC` err = db.Get(&res, q, m.User.ID) } else ...
go
func (m *Msg) GetLastPlugin(db *sqlx.DB) (string, string, error) { var res struct { Plugin string Route string } var err error if m.User.ID > 0 { q := `SELECT route, plugin FROM messages WHERE userid=$1 AND abotsent IS FALSE ORDER BY createdat DESC` err = db.Get(&res, q, m.User.ID) } else ...
[ "func", "(", "m", "*", "Msg", ")", "GetLastPlugin", "(", "db", "*", "sqlx", ".", "DB", ")", "(", "string", ",", "string", ",", "error", ")", "{", "var", "res", "struct", "{", "Plugin", "string", "\n", "Route", "string", "\n", "}", "\n", "var", "e...
// GetLastPlugin for a given user so the previous plugin can be called again if // no new trigger is detected.
[ "GetLastPlugin", "for", "a", "given", "user", "so", "the", "previous", "plugin", "can", "be", "called", "again", "if", "no", "new", "trigger", "is", "detected", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/message.go#L76-L97
126,933
itsabot/itsabot
shared/interface/emailsender/emailsender.go
Open
func Open(driverName, auth string) (*Conn, error) { driversMu.RLock() driveri, ok := drivers[driverName] driversMu.RUnlock() if !ok { return nil, fmt.Errorf("sms: unknown driver %q (forgotten import?)", driverName) } conn, err := driveri.Open(auth) if err != nil { return nil, err } c := &Conn{ driver:...
go
func Open(driverName, auth string) (*Conn, error) { driversMu.RLock() driveri, ok := drivers[driverName] driversMu.RUnlock() if !ok { return nil, fmt.Errorf("sms: unknown driver %q (forgotten import?)", driverName) } conn, err := driveri.Open(auth) if err != nil { return nil, err } c := &Conn{ driver:...
[ "func", "Open", "(", "driverName", ",", "auth", "string", ")", "(", "*", "Conn", ",", "error", ")", "{", "driversMu", ".", "RLock", "(", ")", "\n", "driveri", ",", "ok", ":=", "drivers", "[", "driverName", "]", "\n", "driversMu", ".", "RUnlock", "(",...
// Open a connection to a registered driver.
[ "Open", "a", "connection", "to", "a", "registered", "driver", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/interface/emailsender/emailsender.go#L52-L69
126,934
itsabot/itsabot
shared/interface/emailsender/emailsender.go
SendHTML
func (c *Conn) SendHTML(to []string, from, subj, html string) error { return c.conn.SendHTML(to, from, subj, html) }
go
func (c *Conn) SendHTML(to []string, from, subj, html string) error { return c.conn.SendHTML(to, from, subj, html) }
[ "func", "(", "c", "*", "Conn", ")", "SendHTML", "(", "to", "[", "]", "string", ",", "from", ",", "subj", ",", "html", "string", ")", "error", "{", "return", "c", ".", "conn", ".", "SendHTML", "(", "to", ",", "from", ",", "subj", ",", "html", ")...
// SendHTML email through the opened driver connection.
[ "SendHTML", "email", "through", "the", "opened", "driver", "connection", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/interface/emailsender/emailsender.go#L72-L74
126,935
itsabot/itsabot
shared/interface/emailsender/emailsender.go
SendPlainText
func (c *Conn) SendPlainText(to []string, from, subj, plaintext string) error { return c.conn.SendPlainText(to, from, subj, plaintext) }
go
func (c *Conn) SendPlainText(to []string, from, subj, plaintext string) error { return c.conn.SendPlainText(to, from, subj, plaintext) }
[ "func", "(", "c", "*", "Conn", ")", "SendPlainText", "(", "to", "[", "]", "string", ",", "from", ",", "subj", ",", "plaintext", "string", ")", "error", "{", "return", "c", ".", "conn", ".", "SendPlainText", "(", "to", ",", "from", ",", "subj", ",",...
// SendPlainText email through the opened driver connection.
[ "SendPlainText", "email", "through", "the", "opened", "driver", "connection", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/interface/emailsender/emailsender.go#L77-L79
126,936
itsabot/itsabot
core/context.go
saveContext
func saveContext(db *sqlx.DB, in *dt.Msg) error { if err := saveTimeContext(db, in); err != nil { return err } if err := savePeopleContext(db, in); err != nil { return err } return nil }
go
func saveContext(db *sqlx.DB, in *dt.Msg) error { if err := saveTimeContext(db, in); err != nil { return err } if err := savePeopleContext(db, in); err != nil { return err } return nil }
[ "func", "saveContext", "(", "db", "*", "sqlx", ".", "DB", ",", "in", "*", "dt", ".", "Msg", ")", "error", "{", "if", "err", ":=", "saveTimeContext", "(", "db", ",", "in", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if"...
// saveContext records context in the database across multiple categories.
[ "saveContext", "records", "context", "in", "the", "database", "across", "multiple", "categories", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/context.go#L22-L30
126,937
itsabot/itsabot
core/context.go
saveTimeContext
func saveTimeContext(db *sqlx.DB, in *dt.Msg) error { if len(in.StructuredInput.Times) == 0 { return nil } byt, err := json.Marshal(in.StructuredInput.Times) if err != nil { return err } if in.User.ID > 0 { q := `INSERT INTO states (key, value, userid, pluginname) VALUES ($1, $2, $3, '') ON ...
go
func saveTimeContext(db *sqlx.DB, in *dt.Msg) error { if len(in.StructuredInput.Times) == 0 { return nil } byt, err := json.Marshal(in.StructuredInput.Times) if err != nil { return err } if in.User.ID > 0 { q := `INSERT INTO states (key, value, userid, pluginname) VALUES ($1, $2, $3, '') ON ...
[ "func", "saveTimeContext", "(", "db", "*", "sqlx", ".", "DB", ",", "in", "*", "dt", ".", "Msg", ")", "error", "{", "if", "len", "(", "in", ".", "StructuredInput", ".", "Times", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "byt", ",", ...
// saveTimeContext records contextual information about the time being // discussed, enabling Abot to replace things like "then" with the time it // should represent.
[ "saveTimeContext", "records", "contextual", "information", "about", "the", "time", "being", "discussed", "enabling", "Abot", "to", "replace", "things", "like", "then", "with", "the", "time", "it", "should", "represent", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/context.go#L35-L62
126,938
itsabot/itsabot
core/context.go
savePeopleContext
func savePeopleContext(db *sqlx.DB, in *dt.Msg) error { if len(in.StructuredInput.People) == 0 { return nil } byt, err := json.Marshal(in.StructuredInput.People) if err != nil { return err } if in.User.ID > 0 { q := `INSERT INTO states (key, value, userid, pluginname) VALUES ($1, $2, $3, '') ...
go
func savePeopleContext(db *sqlx.DB, in *dt.Msg) error { if len(in.StructuredInput.People) == 0 { return nil } byt, err := json.Marshal(in.StructuredInput.People) if err != nil { return err } if in.User.ID > 0 { q := `INSERT INTO states (key, value, userid, pluginname) VALUES ($1, $2, $3, '') ...
[ "func", "savePeopleContext", "(", "db", "*", "sqlx", ".", "DB", ",", "in", "*", "dt", ".", "Msg", ")", "error", "{", "if", "len", "(", "in", ".", "StructuredInput", ".", "People", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "byt", ",",...
// savePeopleContext records contextual information about people being // discussed, enabling Abot to replace things like "him", "her", or "they" with // the names the pronouns represent.
[ "savePeopleContext", "records", "contextual", "information", "about", "people", "being", "discussed", "enabling", "Abot", "to", "replace", "things", "like", "him", "her", "or", "they", "with", "the", "names", "the", "pronouns", "represent", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/context.go#L67-L94
126,939
itsabot/itsabot
core/context.go
addTimeContext
func addTimeContext(db *sqlx.DB, in *dt.Msg) error { var addContext bool for _, stem := range in.Stems { if stem == "then" { addContext = true break } } if !addContext { return nil } var byt []byte var err error if in.User.ID > 0 { q := `SELECT value FROM states WHERE userid=$1 AND key=$2` err =...
go
func addTimeContext(db *sqlx.DB, in *dt.Msg) error { var addContext bool for _, stem := range in.Stems { if stem == "then" { addContext = true break } } if !addContext { return nil } var byt []byte var err error if in.User.ID > 0 { q := `SELECT value FROM states WHERE userid=$1 AND key=$2` err =...
[ "func", "addTimeContext", "(", "db", "*", "sqlx", ".", "DB", ",", "in", "*", "dt", ".", "Msg", ")", "error", "{", "var", "addContext", "bool", "\n", "for", "_", ",", "stem", ":=", "range", "in", ".", "Stems", "{", "if", "stem", "==", "\"", "\"", ...
// addTimeContext adds a time context to a Message if the word "then" is found.
[ "addTimeContext", "adds", "a", "time", "context", "to", "a", "Message", "if", "the", "word", "then", "is", "found", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/context.go#L114-L148
126,940
itsabot/itsabot
core/context.go
addPeopleContext
func addPeopleContext(db *sqlx.DB, in *dt.Msg) error { var addContext, singular bool var sex dt.Sex for _, stem := range in.Stems { switch stem { case "us": addContext = true case "him", "he": addContext, singular = true, true if sex == dt.SexFemale { sex = dt.SexEither } else if sex != dt.SexE...
go
func addPeopleContext(db *sqlx.DB, in *dt.Msg) error { var addContext, singular bool var sex dt.Sex for _, stem := range in.Stems { switch stem { case "us": addContext = true case "him", "he": addContext, singular = true, true if sex == dt.SexFemale { sex = dt.SexEither } else if sex != dt.SexE...
[ "func", "addPeopleContext", "(", "db", "*", "sqlx", ".", "DB", ",", "in", "*", "dt", ".", "Msg", ")", "error", "{", "var", "addContext", ",", "singular", "bool", "\n", "var", "sex", "dt", ".", "Sex", "\n", "for", "_", ",", "stem", ":=", "range", ...
// addPeopleContext adds people based on context to the sentence when // appropriate pronouns are found, like "us", "him", "her", or "them".
[ "addPeopleContext", "adds", "people", "based", "on", "context", "to", "the", "sentence", "when", "appropriate", "pronouns", "are", "found", "like", "us", "him", "her", "or", "them", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/context.go#L152-L220
126,941
itsabot/itsabot
core/nlp.go
classifyTokens
func (c classifier) classifyTokens(tokens []string) *dt.StructuredInput { var s dt.StructuredInput var sections []string for _, t := range tokens { var found bool lower := strings.ToLower(t) _, exists := c["C"+lower] if exists { s.Commands = append(s.Commands, lower) found = true } _, exists = c["O...
go
func (c classifier) classifyTokens(tokens []string) *dt.StructuredInput { var s dt.StructuredInput var sections []string for _, t := range tokens { var found bool lower := strings.ToLower(t) _, exists := c["C"+lower] if exists { s.Commands = append(s.Commands, lower) found = true } _, exists = c["O...
[ "func", "(", "c", "classifier", ")", "classifyTokens", "(", "tokens", "[", "]", "string", ")", "*", "dt", ".", "StructuredInput", "{", "var", "s", "dt", ".", "StructuredInput", "\n", "var", "sections", "[", "]", "string", "\n", "for", "_", ",", "t", ...
// classifyTokens builds a StructuredInput from a tokenized sentence.
[ "classifyTokens", "builds", "a", "StructuredInput", "from", "a", "tokenized", "sentence", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/nlp.go#L24-L95
126,942
itsabot/itsabot
core/nlp.go
buildOffensiveMap
func buildOffensiveMap() (map[string]struct{}, error) { o := map[string]struct{}{} p := filepath.Join("data", "offensive.txt") fi, err := os.Open(p) if err != nil { return o, err } scanner := bufio.NewScanner(fi) scanner.Split(bufio.ScanLines) for scanner.Scan() { o[scanner.Text()] = struct{}{} } err = fi...
go
func buildOffensiveMap() (map[string]struct{}, error) { o := map[string]struct{}{} p := filepath.Join("data", "offensive.txt") fi, err := os.Open(p) if err != nil { return o, err } scanner := bufio.NewScanner(fi) scanner.Split(bufio.ScanLines) for scanner.Scan() { o[scanner.Text()] = struct{}{} } err = fi...
[ "func", "buildOffensiveMap", "(", ")", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "error", ")", "{", "o", ":=", "map", "[", "string", "]", "struct", "{", "}", "{", "}", "\n", "p", ":=", "filepath", ".", "Join", "(", "\"", "\"", ",...
// buildOffensiveMap creates a map of offensive terms for which Abot will refuse // to respond. This helps ensure that users are somewhat respectful to Abot and // her human trainers, since sentences caught by the OffensiveMap are rejected // before any human ever sees them.
[ "buildOffensiveMap", "creates", "a", "map", "of", "offensive", "terms", "for", "which", "Abot", "will", "refuse", "to", "respond", ".", "This", "helps", "ensure", "that", "users", "are", "somewhat", "respectful", "to", "Abot", "and", "her", "human", "trainers"...
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/nlp.go#L193-L207
126,943
itsabot/itsabot
core/nlp.go
RespondWithNicety
func RespondWithNicety(in *dt.Msg) string { for _, w := range in.Stems { // Since these are stems, some of them look incorrectly spelled. // Needless to say, these are the correct Porter2 Snowball stems switch w { case "thank": return "You're welcome!" case "cool", "sweet", "awesom", "neat", "perfect": ...
go
func RespondWithNicety(in *dt.Msg) string { for _, w := range in.Stems { // Since these are stems, some of them look incorrectly spelled. // Needless to say, these are the correct Porter2 Snowball stems switch w { case "thank": return "You're welcome!" case "cool", "sweet", "awesom", "neat", "perfect": ...
[ "func", "RespondWithNicety", "(", "in", "*", "dt", ".", "Msg", ")", "string", "{", "for", "_", ",", "w", ":=", "range", "in", ".", "Stems", "{", "// Since these are stems, some of them look incorrectly spelled.", "// Needless to say, these are the correct Porter2 Snowball...
// RespondWithNicety replies to niceties that humans use, but Abot can ignore. // Words like "Thank you" are not necessary for a robot, but it's important Abot // respond correctly nonetheless.
[ "RespondWithNicety", "replies", "to", "niceties", "that", "humans", "use", "but", "Abot", "can", "ignore", ".", "Words", "like", "Thank", "you", "are", "not", "necessary", "for", "a", "robot", "but", "it", "s", "important", "Abot", "respond", "correctly", "n...
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/nlp.go#L212-L228
126,944
itsabot/itsabot
core/nlp.go
RespondWithHelp
func RespondWithHelp(in *dt.Msg) string { if len(in.StructuredInput.Commands) != 1 { return "" } if in.StructuredInput.Commands[0] != "help" { return "" } if in.Plugin != nil { use := randUseForPlugin(in.Plugin) use2 := randUseForPlugin(in.Plugin) if use == use2 { return fmt.Sprintf("Try telling me %q...
go
func RespondWithHelp(in *dt.Msg) string { if len(in.StructuredInput.Commands) != 1 { return "" } if in.StructuredInput.Commands[0] != "help" { return "" } if in.Plugin != nil { use := randUseForPlugin(in.Plugin) use2 := randUseForPlugin(in.Plugin) if use == use2 { return fmt.Sprintf("Try telling me %q...
[ "func", "RespondWithHelp", "(", "in", "*", "dt", ".", "Msg", ")", "string", "{", "if", "len", "(", "in", ".", "StructuredInput", ".", "Commands", ")", "!=", "1", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "in", ".", "StructuredInput", ".", "...
// RespondWithHelp replies to the user when he or she asks for "help".
[ "RespondWithHelp", "replies", "to", "the", "user", "when", "he", "or", "she", "asks", "for", "help", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/nlp.go#L231-L259
126,945
itsabot/itsabot
core/nlp.go
RespondWithHelpConfused
func RespondWithHelpConfused(in *dt.Msg) string { if in.Plugin != nil { use := randUseForPlugin(in.Plugin) use2 := randUseForPlugin(in.Plugin) if use == use2 { return fmt.Sprintf("%s You can try telling me %q", ConfusedLang(), use) } return fmt.Sprintf("%s You can try telling me %q or %q", Confused...
go
func RespondWithHelpConfused(in *dt.Msg) string { if in.Plugin != nil { use := randUseForPlugin(in.Plugin) use2 := randUseForPlugin(in.Plugin) if use == use2 { return fmt.Sprintf("%s You can try telling me %q", ConfusedLang(), use) } return fmt.Sprintf("%s You can try telling me %q or %q", Confused...
[ "func", "RespondWithHelpConfused", "(", "in", "*", "dt", ".", "Msg", ")", "string", "{", "if", "in", ".", "Plugin", "!=", "nil", "{", "use", ":=", "randUseForPlugin", "(", "in", ".", "Plugin", ")", "\n", "use2", ":=", "randUseForPlugin", "(", "in", "."...
// RespondWithHelpConfused replies to the user when Abot is confused.
[ "RespondWithHelpConfused", "replies", "to", "the", "user", "when", "Abot", "is", "confused", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/nlp.go#L262-L282
126,946
itsabot/itsabot
core/nlp.go
randUse
func randUse() string { if len(PluginsGo) == 0 { return "" } pluginUses := PluginsGo[rand.Intn(len(PluginsGo))].Usage if pluginUses == nil || len(pluginUses) == 0 { return "" } return pluginUses[rand.Intn(len(pluginUses))] }
go
func randUse() string { if len(PluginsGo) == 0 { return "" } pluginUses := PluginsGo[rand.Intn(len(PluginsGo))].Usage if pluginUses == nil || len(pluginUses) == 0 { return "" } return pluginUses[rand.Intn(len(pluginUses))] }
[ "func", "randUse", "(", ")", "string", "{", "if", "len", "(", "PluginsGo", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "pluginUses", ":=", "PluginsGo", "[", "rand", ".", "Intn", "(", "len", "(", "PluginsGo", ")", ")", "]", ".", "U...
// randUse returns a random use from among all plugins.
[ "randUse", "returns", "a", "random", "use", "from", "among", "all", "plugins", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/nlp.go#L285-L294
126,947
itsabot/itsabot
core/nlp.go
randUseForPlugin
func randUseForPlugin(plugin *dt.Plugin) string { if plugin.Config.Usage == nil { return "" } return plugin.Config.Usage[rand.Intn(len(plugin.Config.Usage))] }
go
func randUseForPlugin(plugin *dt.Plugin) string { if plugin.Config.Usage == nil { return "" } return plugin.Config.Usage[rand.Intn(len(plugin.Config.Usage))] }
[ "func", "randUseForPlugin", "(", "plugin", "*", "dt", ".", "Plugin", ")", "string", "{", "if", "plugin", ".", "Config", ".", "Usage", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "plugin", ".", "Config", ".", "Usage", "[", "rand...
// randUseForPlugin returns a random use from a specific plugin.
[ "randUseForPlugin", "returns", "a", "random", "use", "from", "a", "specific", "plugin", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/nlp.go#L297-L302
126,948
itsabot/itsabot
core/nlp.go
RespondWithOffense
func RespondWithOffense(in *dt.Msg) string { for _, w := range in.Stems { _, ok := offensive[w] if ok { return "I'm sorry, but I don't respond to rude language." } } return "" }
go
func RespondWithOffense(in *dt.Msg) string { for _, w := range in.Stems { _, ok := offensive[w] if ok { return "I'm sorry, but I don't respond to rude language." } } return "" }
[ "func", "RespondWithOffense", "(", "in", "*", "dt", ".", "Msg", ")", "string", "{", "for", "_", ",", "w", ":=", "range", "in", ".", "Stems", "{", "_", ",", "ok", ":=", "offensive", "[", "w", "]", "\n", "if", "ok", "{", "return", "\"", "\"", "\n...
// RespondWithOffense is a one-off function to respond to rude user language by // refusing to process the command.
[ "RespondWithOffense", "is", "a", "one", "-", "off", "function", "to", "respond", "to", "rude", "user", "language", "by", "refusing", "to", "process", "the", "command", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/nlp.go#L306-L314
126,949
itsabot/itsabot
shared/helpers/address/address.go
Parse
func Parse(s string) (*dt.Address, error) { s = regexAddress.FindString(s) if len(s) == 0 { log.Debug("missing address") return nil, ErrInvalidAddress } log.Debug("address", s) tmp := regexZip.FindStringIndex(s) var zip string if tmp != nil { zip = s[tmp[0]:tmp[1]] s = s[:tmp[0]] } else { log.Debug("n...
go
func Parse(s string) (*dt.Address, error) { s = regexAddress.FindString(s) if len(s) == 0 { log.Debug("missing address") return nil, ErrInvalidAddress } log.Debug("address", s) tmp := regexZip.FindStringIndex(s) var zip string if tmp != nil { zip = s[tmp[0]:tmp[1]] s = s[:tmp[0]] } else { log.Debug("n...
[ "func", "Parse", "(", "s", "string", ")", "(", "*", "dt", ".", "Address", ",", "error", ")", "{", "s", "=", "regexAddress", ".", "FindString", "(", "s", ")", "\n", "if", "len", "(", "s", ")", "==", "0", "{", "log", ".", "Debug", "(", "\"", "\...
// Parse a string to return a fully-validated U.S. address.
[ "Parse", "a", "string", "to", "return", "a", "fully", "-", "validated", "U", ".", "S", ".", "address", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/helpers/address/address.go#L98-L165
126,950
itsabot/itsabot
core/boot.go
compileAssets
func compileAssets() error { p := filepath.Join("cmd", "compileassets.sh") outC, err := exec. Command("/bin/sh", "-c", p). CombinedOutput() if err != nil { log.Debug(string(outC)) return err } return nil }
go
func compileAssets() error { p := filepath.Join("cmd", "compileassets.sh") outC, err := exec. Command("/bin/sh", "-c", p). CombinedOutput() if err != nil { log.Debug(string(outC)) return err } return nil }
[ "func", "compileAssets", "(", ")", "error", "{", "p", ":=", "filepath", ".", "Join", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "outC", ",", "err", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "p", ")", ".", "CombinedO...
// compileAssets compresses and merges assets from Abot core and all plugins on // boot. In development, this step is repeated on each server HTTP request prior // to serving any assets.
[ "compileAssets", "compresses", "and", "merges", "assets", "from", "Abot", "core", "and", "all", "plugins", "on", "boot", ".", "In", "development", "this", "step", "is", "repeated", "on", "each", "server", "HTTP", "request", "prior", "to", "serving", "any", "...
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/boot.go#L165-L175
126,951
itsabot/itsabot
core/boot.go
ConnectDB
func ConnectDB(name string) (*sqlx.DB, error) { if len(name) == 0 { dir, err := os.Getwd() if err != nil { return nil, err } name = filepath.Base(dir) } dbConnStr := DBConnectionString(name) log.Debug("connecting to db") return sqlx.Connect("postgres", dbConnStr) }
go
func ConnectDB(name string) (*sqlx.DB, error) { if len(name) == 0 { dir, err := os.Getwd() if err != nil { return nil, err } name = filepath.Base(dir) } dbConnStr := DBConnectionString(name) log.Debug("connecting to db") return sqlx.Connect("postgres", dbConnStr) }
[ "func", "ConnectDB", "(", "name", "string", ")", "(", "*", "sqlx", ".", "DB", ",", "error", ")", "{", "if", "len", "(", "name", ")", "==", "0", "{", "dir", ",", "err", ":=", "os", ".", "Getwd", "(", ")", "\n", "if", "err", "!=", "nil", "{", ...
// ConnectDB opens a connection to the database. The name is the name of the // database to connect to. If empty, it defaults to the current directory's // name.
[ "ConnectDB", "opens", "a", "connection", "to", "the", "database", ".", "The", "name", "is", "the", "name", "of", "the", "database", "to", "connect", "to", ".", "If", "empty", "it", "defaults", "to", "the", "current", "directory", "s", "name", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/boot.go#L207-L218
126,952
itsabot/itsabot
core/boot.go
DBConnectionString
func DBConnectionString(name string) string { dbConnStr := os.Getenv("ABOT_DATABASE_URL") if dbConnStr == "" { dbConnStr = "host=127.0.0.1 user=postgres" } if len(dbConnStr) <= 11 || dbConnStr[:11] != "postgres://" { dbConnStr += " sslmode=disable dbname=" + name if strings.ToLower(os.Getenv("ABOT_ENV")) == "...
go
func DBConnectionString(name string) string { dbConnStr := os.Getenv("ABOT_DATABASE_URL") if dbConnStr == "" { dbConnStr = "host=127.0.0.1 user=postgres" } if len(dbConnStr) <= 11 || dbConnStr[:11] != "postgres://" { dbConnStr += " sslmode=disable dbname=" + name if strings.ToLower(os.Getenv("ABOT_ENV")) == "...
[ "func", "DBConnectionString", "(", "name", "string", ")", "string", "{", "dbConnStr", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "dbConnStr", "==", "\"", "\"", "{", "dbConnStr", "=", "\"", "\"", "\n", "}", "\n", "if", "len", "(", ...
// DBConnectionString returns the connection parameters for connecting to the // database.
[ "DBConnectionString", "returns", "the", "connection", "parameters", "for", "connecting", "to", "the", "database", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/boot.go#L222-L234
126,953
itsabot/itsabot
core/boot.go
LoadConf
func LoadConf() error { p := filepath.Join("plugins.json") okVal := fmt.Sprintf("open %s: no such file or directory", p) contents, err := ioutil.ReadFile(p) if err != nil && err.Error() != okVal { return err } return json.Unmarshal(contents, conf) }
go
func LoadConf() error { p := filepath.Join("plugins.json") okVal := fmt.Sprintf("open %s: no such file or directory", p) contents, err := ioutil.ReadFile(p) if err != nil && err.Error() != okVal { return err } return json.Unmarshal(contents, conf) }
[ "func", "LoadConf", "(", ")", "error", "{", "p", ":=", "filepath", ".", "Join", "(", "\"", "\"", ")", "\n", "okVal", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ")", "\n", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", ...
// LoadConf plugins.json into a usable struct.
[ "LoadConf", "plugins", ".", "json", "into", "a", "usable", "struct", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/boot.go#L237-L245
126,954
itsabot/itsabot
core/boot.go
LoadEnvVars
func LoadEnvVars() error { if envLoaded { return nil } if len(os.Getenv("ABOT_PATH")) == 0 { p := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "itsabot", "abot") log.Debug("ABOT_PATH not set. defaulting to", p) if err := os.Setenv("ABOT_PATH", p); err != nil { return err } } if len(os.Ge...
go
func LoadEnvVars() error { if envLoaded { return nil } if len(os.Getenv("ABOT_PATH")) == 0 { p := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "itsabot", "abot") log.Debug("ABOT_PATH not set. defaulting to", p) if err := os.Setenv("ABOT_PATH", p); err != nil { return err } } if len(os.Ge...
[ "func", "LoadEnvVars", "(", ")", "error", "{", "if", "envLoaded", "{", "return", "nil", "\n", "}", "\n", "if", "len", "(", "os", ".", "Getenv", "(", "\"", "\"", ")", ")", "==", "0", "{", "p", ":=", "filepath", ".", "Join", "(", "os", ".", "Gete...
// LoadEnvVars from abot.env into memory
[ "LoadEnvVars", "from", "abot", ".", "env", "into", "memory" ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/boot.go#L248-L311
126,955
itsabot/itsabot
core/boot.go
LoadPluginsGo
func LoadPluginsGo() error { p := filepath.Join("plugins.go") okVal := fmt.Sprintf("open %s: no such file or directory", p) contents, err := ioutil.ReadFile(p) if err != nil && err.Error() != okVal { return err } var val []byte var foundStart bool var nestLvl int for _, b := range contents { switch b { c...
go
func LoadPluginsGo() error { p := filepath.Join("plugins.go") okVal := fmt.Sprintf("open %s: no such file or directory", p) contents, err := ioutil.ReadFile(p) if err != nil && err.Error() != okVal { return err } var val []byte var foundStart bool var nestLvl int for _, b := range contents { switch b { c...
[ "func", "LoadPluginsGo", "(", ")", "error", "{", "p", ":=", "filepath", ".", "Join", "(", "\"", "\"", ")", "\n", "okVal", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ")", "\n", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", ...
// LoadPluginsGo loads the plugins.go file into memory.
[ "LoadPluginsGo", "loads", "the", "plugins", ".", "go", "file", "into", "memory", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/boot.go#L314-L350
126,956
itsabot/itsabot
core/boot.go
trainClassifiers
func trainClassifiers() error { for _, pconf := range PluginsGo { ss, err := fetchTrainingSentences(pconf.ID, pconf.Name) if err != nil { return err } // Assemble list of Bayesian classes from all trained intents // for this plugin. m is used to keep track of the classes // already taught to each class...
go
func trainClassifiers() error { for _, pconf := range PluginsGo { ss, err := fetchTrainingSentences(pconf.ID, pconf.Name) if err != nil { return err } // Assemble list of Bayesian classes from all trained intents // for this plugin. m is used to keep track of the classes // already taught to each class...
[ "func", "trainClassifiers", "(", ")", "error", "{", "for", "_", ",", "pconf", ":=", "range", "PluginsGo", "{", "ss", ",", "err", ":=", "fetchTrainingSentences", "(", "pconf", ".", "ID", ",", "pconf", ".", "Name", ")", "\n", "if", "err", "!=", "nil", ...
// trainClassifiers trains classifiers for each plugin.
[ "trainClassifiers", "trains", "classifiers", "for", "each", "plugin", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/boot.go#L353-L402
126,957
itsabot/itsabot
shared/datatypes/slice.go
Scan
func (u *Uint64Slice) Scan(src interface{}) error { asBytes, ok := src.([]byte) if !ok { return errors.New("scan source was not []bytes") } str := string(asBytes) str = str[1 : len(str)-1] csvReader := csv.NewReader(strings.NewReader(str)) slice, err := csvReader.Read() if err != nil && err.Error() != "EOF" {...
go
func (u *Uint64Slice) Scan(src interface{}) error { asBytes, ok := src.([]byte) if !ok { return errors.New("scan source was not []bytes") } str := string(asBytes) str = str[1 : len(str)-1] csvReader := csv.NewReader(strings.NewReader(str)) slice, err := csvReader.Read() if err != nil && err.Error() != "EOF" {...
[ "func", "(", "u", "*", "Uint64Slice", ")", "Scan", "(", "src", "interface", "{", "}", ")", "error", "{", "asBytes", ",", "ok", ":=", "src", ".", "(", "[", "]", "byte", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New", "(", "\"", ...
// Scan converts to a slice of uint64.
[ "Scan", "converts", "to", "a", "slice", "of", "uint64", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/slice.go#L16-L38
126,958
itsabot/itsabot
shared/datatypes/slice.go
Value
func (u Uint64Slice) Value() (driver.Value, error) { var ss []string for i := 0; i < len(u); i++ { tmp := strconv.FormatUint(u[i], 10) ss = append(ss, tmp) } return "{" + strings.Join(ss, ",") + "}", nil }
go
func (u Uint64Slice) Value() (driver.Value, error) { var ss []string for i := 0; i < len(u); i++ { tmp := strconv.FormatUint(u[i], 10) ss = append(ss, tmp) } return "{" + strings.Join(ss, ",") + "}", nil }
[ "func", "(", "u", "Uint64Slice", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "var", "ss", "[", "]", "string", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "u", ")", ";", "i", "++", "{", "tmp", ":=...
// Value converts to a slice of uint64.
[ "Value", "converts", "to", "a", "slice", "of", "uint64", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/slice.go#L41-L48
126,959
itsabot/itsabot
shared/datatypes/slice.go
String
func (s StringSlice) String() string { if len(s) == 0 { return "" } var ss string for _, w := range s { ss += " " + w } return ss[1:] }
go
func (s StringSlice) String() string { if len(s) == 0 { return "" } var ss string for _, w := range s { ss += " " + w } return ss[1:] }
[ "func", "(", "s", "StringSlice", ")", "String", "(", ")", "string", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "var", "ss", "string", "\n", "for", "_", ",", "w", ":=", "range", "s", "{", "ss", "+="...
// String converts a StringSlice into a string with each word separated by // spaces.
[ "String", "converts", "a", "StringSlice", "into", "a", "string", "with", "each", "word", "separated", "by", "spaces", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/slice.go#L103-L112
126,960
itsabot/itsabot
shared/datatypes/slice.go
Map
func (s StringSlice) Map() map[string]struct{} { m := map[string]struct{}{} for _, w := range s { m[w] = struct{}{} } return m }
go
func (s StringSlice) Map() map[string]struct{} { m := map[string]struct{}{} for _, w := range s { m[w] = struct{}{} } return m }
[ "func", "(", "s", "StringSlice", ")", "Map", "(", ")", "map", "[", "string", "]", "struct", "{", "}", "{", "m", ":=", "map", "[", "string", "]", "struct", "{", "}", "{", "}", "\n", "for", "_", ",", "w", ":=", "range", "s", "{", "m", "[", "w...
// Map converts a StringSlice into a map to check quickly if words exist within // it.
[ "Map", "converts", "a", "StringSlice", "into", "a", "map", "to", "check", "quickly", "if", "words", "exist", "within", "it", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/slice.go#L128-L134
126,961
itsabot/itsabot
core/template/forgot_password_email.go
ForgotPasswordEmail
func ForgotPasswordEmail(name, secret string) string { h := `<html><body>` h += fmt.Sprintf("<p>Hi %s:</p>", name) h += "<p>Please click the following link to reset your password. This link will expire in 30 minutes.</p>" h += fmt.Sprintf("<p>%s</p>", os.Getenv("ABOT_URL")+"/reset_password?s="+secret) h += "<p>If ...
go
func ForgotPasswordEmail(name, secret string) string { h := `<html><body>` h += fmt.Sprintf("<p>Hi %s:</p>", name) h += "<p>Please click the following link to reset your password. This link will expire in 30 minutes.</p>" h += fmt.Sprintf("<p>%s</p>", os.Getenv("ABOT_URL")+"/reset_password?s="+secret) h += "<p>If ...
[ "func", "ForgotPasswordEmail", "(", "name", ",", "secret", "string", ")", "string", "{", "h", ":=", "`<html><body>`", "\n", "h", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", "\n", "h", "+=", "\"", "\"", "\n", "h", "+=", "fmt", "....
// ForgotPasswordEmail takes a user's name and a secret token stored in the // database and returns an HTML-format email.
[ "ForgotPasswordEmail", "takes", "a", "user", "s", "name", "and", "a", "secret", "token", "stored", "in", "the", "database", "and", "returns", "an", "HTML", "-", "format", "email", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/template/forgot_password_email.go#L13-L23
126,962
itsabot/itsabot
core/websocket/websocket.go
NewAtomicWebSocketSet
func NewAtomicWebSocketSet() AtomicWebSocketSet { return AtomicWebSocketSet{ sockets: map[uint64]*websocket.Conn{}, mutex: &sync.Mutex{}, } }
go
func NewAtomicWebSocketSet() AtomicWebSocketSet { return AtomicWebSocketSet{ sockets: map[uint64]*websocket.Conn{}, mutex: &sync.Mutex{}, } }
[ "func", "NewAtomicWebSocketSet", "(", ")", "AtomicWebSocketSet", "{", "return", "AtomicWebSocketSet", "{", "sockets", ":", "map", "[", "uint64", "]", "*", "websocket", ".", "Conn", "{", "}", ",", "mutex", ":", "&", "sync", ".", "Mutex", "{", "}", ",", "}...
// NewAtomicWebSocketSet returns an AtomicWebSocketSet to maintain open // WebSocket connections on a per-user basis.
[ "NewAtomicWebSocketSet", "returns", "an", "AtomicWebSocketSet", "to", "maintain", "open", "WebSocket", "connections", "on", "a", "per", "-", "user", "basis", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/websocket/websocket.go#L24-L29
126,963
itsabot/itsabot
core/websocket/websocket.go
Get
func (as AtomicWebSocketSet) Get(userID uint64) *websocket.Conn { var conn *websocket.Conn as.mutex.Lock() conn = as.sockets[userID] as.mutex.Unlock() runtime.Gosched() return conn }
go
func (as AtomicWebSocketSet) Get(userID uint64) *websocket.Conn { var conn *websocket.Conn as.mutex.Lock() conn = as.sockets[userID] as.mutex.Unlock() runtime.Gosched() return conn }
[ "func", "(", "as", "AtomicWebSocketSet", ")", "Get", "(", "userID", "uint64", ")", "*", "websocket", ".", "Conn", "{", "var", "conn", "*", "websocket", ".", "Conn", "\n", "as", ".", "mutex", ".", "Lock", "(", ")", "\n", "conn", "=", "as", ".", "soc...
// Get returns a WebSocket connection for a given userID in a thread-safe way.
[ "Get", "returns", "a", "WebSocket", "connection", "for", "a", "given", "userID", "in", "a", "thread", "-", "safe", "way", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/websocket/websocket.go#L32-L39
126,964
itsabot/itsabot
core/websocket/websocket.go
NotifySockets
func (as AtomicWebSocketSet) NotifySockets(uid uint64, cmd, ret string) error { s := as.Get(uid) if s == nil { // Trainer is not online. return nil } t := time.Now() data := []struct { Sentence string AvaSent bool CreatedAt *time.Time }{ { Sentence: cmd, AvaSent: false, CreatedAt: &t, ...
go
func (as AtomicWebSocketSet) NotifySockets(uid uint64, cmd, ret string) error { s := as.Get(uid) if s == nil { // Trainer is not online. return nil } t := time.Now() data := []struct { Sentence string AvaSent bool CreatedAt *time.Time }{ { Sentence: cmd, AvaSent: false, CreatedAt: &t, ...
[ "func", "(", "as", "AtomicWebSocketSet", ")", "NotifySockets", "(", "uid", "uint64", ",", "cmd", ",", "ret", "string", ")", "error", "{", "s", ":=", "as", ".", "Get", "(", "uid", ")", "\n", "if", "s", "==", "nil", "{", "// Trainer is not online.", "ret...
// NotifySockets sends listening clients new messages over WebSockets, // eliminating the need for trainers to constantly reload the page.
[ "NotifySockets", "sends", "listening", "clients", "new", "messages", "over", "WebSockets", "eliminating", "the", "need", "for", "trainers", "to", "constantly", "reload", "the", "page", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/websocket/websocket.go#L51-L81
126,965
itsabot/itsabot
core/plugin.go
Get
func (pm PkgMap) Get(k string) *dt.Plugin { var p *dt.Plugin pm.mutex.Lock() p = pm.plugins[k] pm.mutex.Unlock() runtime.Gosched() return p }
go
func (pm PkgMap) Get(k string) *dt.Plugin { var p *dt.Plugin pm.mutex.Lock() p = pm.plugins[k] pm.mutex.Unlock() runtime.Gosched() return p }
[ "func", "(", "pm", "PkgMap", ")", "Get", "(", "k", "string", ")", "*", "dt", ".", "Plugin", "{", "var", "p", "*", "dt", ".", "Plugin", "\n", "pm", ".", "mutex", ".", "Lock", "(", ")", "\n", "p", "=", "pm", ".", "plugins", "[", "k", "]", "\n...
// Get is a thread-safe, locking way to access the values of a PkgMap.
[ "Get", "is", "a", "thread", "-", "safe", "locking", "way", "to", "access", "the", "values", "of", "a", "PkgMap", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/plugin.go#L43-L50
126,966
itsabot/itsabot
core/plugin.go
Set
func (pm PkgMap) Set(k string, v *dt.Plugin) { pm.mutex.Lock() pm.plugins[k] = v pm.mutex.Unlock() runtime.Gosched() }
go
func (pm PkgMap) Set(k string, v *dt.Plugin) { pm.mutex.Lock() pm.plugins[k] = v pm.mutex.Unlock() runtime.Gosched() }
[ "func", "(", "pm", "PkgMap", ")", "Set", "(", "k", "string", ",", "v", "*", "dt", ".", "Plugin", ")", "{", "pm", ".", "mutex", ".", "Lock", "(", ")", "\n", "pm", ".", "plugins", "[", "k", "]", "=", "v", "\n", "pm", ".", "mutex", ".", "Unloc...
// Set is a thread-safe, locking way to set the values of a PkgMap.
[ "Set", "is", "a", "thread", "-", "safe", "locking", "way", "to", "set", "the", "values", "of", "a", "PkgMap", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/plugin.go#L53-L58
126,967
itsabot/itsabot
core/plugin.go
GetPlugin
func GetPlugin(db *sqlx.DB, m *dt.Msg) (p *dt.Plugin, route string, directroute, followup bool, err error) { // Iterate through all intents to see if any plugin has been registered // for the route for _, i := range m.StructuredInput.Intents { route = "I_" + strings.ToLower(i) log.Debug("searching for route", ...
go
func GetPlugin(db *sqlx.DB, m *dt.Msg) (p *dt.Plugin, route string, directroute, followup bool, err error) { // Iterate through all intents to see if any plugin has been registered // for the route for _, i := range m.StructuredInput.Intents { route = "I_" + strings.ToLower(i) log.Debug("searching for route", ...
[ "func", "GetPlugin", "(", "db", "*", "sqlx", ".", "DB", ",", "m", "*", "dt", ".", "Msg", ")", "(", "p", "*", "dt", ".", "Plugin", ",", "route", "string", ",", "directroute", ",", "followup", "bool", ",", "err", "error", ")", "{", "// Iterate throug...
// GetPlugin attempts to find a plugin and route for the given msg input if none // can be found, it checks the database for the last route used and gets the // plugin for that. If there is no previously used plugin, we return // errMissingPlugin. The bool value return indicates whether this plugin is // different from...
[ "GetPlugin", "attempts", "to", "find", "a", "plugin", "and", "route", "for", "the", "given", "msg", "input", "if", "none", "can", "be", "found", "it", "checks", "the", "database", "for", "the", "last", "route", "used", "and", "gets", "the", "plugin", "fo...
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/plugin.go#L65-L118
126,968
itsabot/itsabot
core/analytics.go
updateAnalytics
func updateAnalytics(interval time.Duration) { t := time.NewTicker(time.Hour) select { case now := <-t.C: updateAnalyticsTick(now) updateAnalytics(interval) } }
go
func updateAnalytics(interval time.Duration) { t := time.NewTicker(time.Hour) select { case now := <-t.C: updateAnalyticsTick(now) updateAnalytics(interval) } }
[ "func", "updateAnalytics", "(", "interval", "time", ".", "Duration", ")", "{", "t", ":=", "time", ".", "NewTicker", "(", "time", ".", "Hour", ")", "\n", "select", "{", "case", "now", ":=", "<-", "t", ".", "C", ":", "updateAnalyticsTick", "(", "now", ...
// updateAnalytics recursively calls itself to continue running.
[ "updateAnalytics", "recursively", "calls", "itself", "to", "continue", "running", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/analytics.go#L21-L28
126,969
itsabot/itsabot
shared/datatypes/plugin.go
DeleteMemory
func (p *Plugin) DeleteMemory(in *Msg, k string) { var err error if in.User.ID > 0 { q := `DELETE FROM states WHERE userid=$1 AND pluginname=$2 AND key=$3` _, err = p.DB.Exec(q, in.User.ID, p.Config.Name, k) } else { q := `DELETE FROM states WHERE flexid=$1 AND flexidtype=$2 AND pluginname=$3 ...
go
func (p *Plugin) DeleteMemory(in *Msg, k string) { var err error if in.User.ID > 0 { q := `DELETE FROM states WHERE userid=$1 AND pluginname=$2 AND key=$3` _, err = p.DB.Exec(q, in.User.ID, p.Config.Name, k) } else { q := `DELETE FROM states WHERE flexid=$1 AND flexidtype=$2 AND pluginname=$3 ...
[ "func", "(", "p", "*", "Plugin", ")", "DeleteMemory", "(", "in", "*", "Msg", ",", "k", "string", ")", "{", "var", "err", "error", "\n", "if", "in", ".", "User", ".", "ID", ">", "0", "{", "q", ":=", "`DELETE FROM states\n\t\t WHERE userid=$1 AND plug...
// DeleteMemory deletes a memory for a given key. It is not an error to delete // a key that does not exist.
[ "DeleteMemory", "deletes", "a", "memory", "for", "a", "given", "key", ".", "It", "is", "not", "an", "error", "to", "delete", "a", "key", "that", "does", "not", "exist", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/plugin.go#L220-L237
126,970
itsabot/itsabot
shared/datatypes/plugin.go
GetSetting
func (p *Plugin) GetSetting(name string) string { if p.Config.Settings[name] == nil { pluginName := p.Config.Name if len(pluginName) == 0 { pluginName = "plugin" } m := fmt.Sprintf( "missing setting %s. please declare it in the %s's plugin.json", name, pluginName) log.Fatal(m) } var val string q ...
go
func (p *Plugin) GetSetting(name string) string { if p.Config.Settings[name] == nil { pluginName := p.Config.Name if len(pluginName) == 0 { pluginName = "plugin" } m := fmt.Sprintf( "missing setting %s. please declare it in the %s's plugin.json", name, pluginName) log.Fatal(m) } var val string q ...
[ "func", "(", "p", "*", "Plugin", ")", "GetSetting", "(", "name", "string", ")", "string", "{", "if", "p", ".", "Config", ".", "Settings", "[", "name", "]", "==", "nil", "{", "pluginName", ":=", "p", ".", "Config", ".", "Name", "\n", "if", "len", ...
// GetSetting retrieves a specific setting's value. It throws a fatal error if // the setting has not been declared in the plugin's plugin.json file.
[ "GetSetting", "retrieves", "a", "specific", "setting", "s", "value", ".", "It", "throws", "a", "fatal", "error", "if", "the", "setting", "has", "not", "been", "declared", "in", "the", "plugin", "s", "plugin", ".", "json", "file", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/plugin.go#L241-L263
126,971
itsabot/itsabot
shared/language/language.go
Greeting
func Greeting(r *rand.Rand, name string) string { var n int if len(name) == 0 { n = r.Intn(3) switch n { case 0: return fmt.Sprintf("Hi, %s.", name) case 1: return fmt.Sprintf("Hello, %s.", name) case 2: return fmt.Sprintf("Hi there, %s.", name) } } else { n = r.Intn(3) switch n { case 0: ...
go
func Greeting(r *rand.Rand, name string) string { var n int if len(name) == 0 { n = r.Intn(3) switch n { case 0: return fmt.Sprintf("Hi, %s.", name) case 1: return fmt.Sprintf("Hello, %s.", name) case 2: return fmt.Sprintf("Hi there, %s.", name) } } else { n = r.Intn(3) switch n { case 0: ...
[ "func", "Greeting", "(", "r", "*", "rand", ".", "Rand", ",", "name", "string", ")", "string", "{", "var", "n", "int", "\n", "if", "len", "(", "name", ")", "==", "0", "{", "n", "=", "r", ".", "Intn", "(", "3", ")", "\n", "switch", "n", "{", ...
// Greeting returns a randomized greeting.
[ "Greeting", "returns", "a", "randomized", "greeting", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/language.go#L69-L92
126,972
itsabot/itsabot
shared/language/language.go
SuggestedPlace
func SuggestedPlace(s string) string { n := rand.Intn(4) switch n { case 0: return "How does this place look? " + s case 1: return "How about " + s + "?" case 2: return "Have you been here before? " + s case 3: return "You could try this: " + s } log.Debug("suggestedPlace failed to return a response") ...
go
func SuggestedPlace(s string) string { n := rand.Intn(4) switch n { case 0: return "How does this place look? " + s case 1: return "How about " + s + "?" case 2: return "Have you been here before? " + s case 3: return "You could try this: " + s } log.Debug("suggestedPlace failed to return a response") ...
[ "func", "SuggestedPlace", "(", "s", "string", ")", "string", "{", "n", ":=", "rand", ".", "Intn", "(", "4", ")", "\n", "switch", "n", "{", "case", "0", ":", "return", "\"", "\"", "+", "s", "\n", "case", "1", ":", "return", "\"", "\"", "+", "s",...
// SuggestedPlace returns a randomized place suggestion useful for recommending // restaurants, businesses, etc.
[ "SuggestedPlace", "returns", "a", "randomized", "place", "suggestion", "useful", "for", "recommending", "restaurants", "businesses", "etc", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/language.go#L130-L144
126,973
itsabot/itsabot
shared/language/language.go
SuggestedProduct
func SuggestedProduct(s string, num uint) string { var n int var val, flair string if num > 0 { n = rand.Intn(3) switch n { case 0, 1: flair = ", then" case 2: // do nothing } } n = rand.Intn(6) switch n { case 0: val = "I found just the thing" case 1: val = "This is the one for you" case 2: ...
go
func SuggestedProduct(s string, num uint) string { var n int var val, flair string if num > 0 { n = rand.Intn(3) switch n { case 0, 1: flair = ", then" case 2: // do nothing } } n = rand.Intn(6) switch n { case 0: val = "I found just the thing" case 1: val = "This is the one for you" case 2: ...
[ "func", "SuggestedProduct", "(", "s", "string", ",", "num", "uint", ")", "string", "{", "var", "n", "int", "\n", "var", "val", ",", "flair", "string", "\n", "if", "num", ">", "0", "{", "n", "=", "rand", ".", "Intn", "(", "3", ")", "\n", "switch",...
// SuggestedProduct returns natural language, randomized text for a product // suggestion.
[ "SuggestedProduct", "returns", "natural", "language", "randomized", "text", "for", "a", "product", "suggestion", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/language.go#L148-L175
126,974
itsabot/itsabot
shared/language/language.go
QuestionLocation
func QuestionLocation(loc string) string { if len(loc) == 0 { n := rand.Intn(10) switch n { case 0: return "Where are you?" case 1: return "Where are you now?" case 2: return "Sure thing. Where are you?" case 3: return "Sure thing. Where are you now?" case 4: return "Happy to help. Where a...
go
func QuestionLocation(loc string) string { if len(loc) == 0 { n := rand.Intn(10) switch n { case 0: return "Where are you?" case 1: return "Where are you now?" case 2: return "Sure thing. Where are you?" case 3: return "Sure thing. Where are you now?" case 4: return "Happy to help. Where a...
[ "func", "QuestionLocation", "(", "loc", "string", ")", "string", "{", "if", "len", "(", "loc", ")", "==", "0", "{", "n", ":=", "rand", ".", "Intn", "(", "10", ")", "\n", "switch", "n", "{", "case", "0", ":", "return", "\"", "\"", "\n", "case", ...
// QuestionLocation returns a randomized question asking a user where they are.
[ "QuestionLocation", "returns", "a", "randomized", "question", "asking", "a", "user", "where", "they", "are", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/language.go#L415-L442
126,975
itsabot/itsabot
shared/language/language.go
Yes
func Yes(s string) bool { s = strings.ToLower(s) _, ok := yes[s] return ok }
go
func Yes(s string) bool { s = strings.ToLower(s) _, ok := yes[s] return ok }
[ "func", "Yes", "(", "s", "string", ")", "bool", "{", "s", "=", "strings", ".", "ToLower", "(", "s", ")", "\n", "_", ",", "ok", ":=", "yes", "[", "s", "]", "\n", "return", "ok", "\n", "}" ]
// Yes determines if a specific word is a positive "Yes" response. For example, // "yeah" returns true.
[ "Yes", "determines", "if", "a", "specific", "word", "is", "a", "positive", "Yes", "response", ".", "For", "example", "yeah", "returns", "true", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/language.go#L446-L450
126,976
itsabot/itsabot
shared/language/language.go
No
func No(s string) bool { s = strings.ToLower(s) _, ok := no[s] return ok }
go
func No(s string) bool { s = strings.ToLower(s) _, ok := no[s] return ok }
[ "func", "No", "(", "s", "string", ")", "bool", "{", "s", "=", "strings", ".", "ToLower", "(", "s", ")", "\n", "_", ",", "ok", ":=", "no", "[", "s", "]", "\n", "return", "ok", "\n", "}" ]
// No determines if a specific word is a "No" response. For example, "nah" // returns true.
[ "No", "determines", "if", "a", "specific", "word", "is", "a", "No", "response", ".", "For", "example", "nah", "returns", "true", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/language.go#L454-L458
126,977
itsabot/itsabot
shared/language/language.go
RemoveStopWords
func RemoveStopWords(ss []string) []string { var removal []int for i, s := range ss { if Contains(StopWords, s) { removal = append(removal, i) } } for _, i := range removal { ss = append(ss[:i], ss[i+1:]...) } return ss }
go
func RemoveStopWords(ss []string) []string { var removal []int for i, s := range ss { if Contains(StopWords, s) { removal = append(removal, i) } } for _, i := range removal { ss = append(ss[:i], ss[i+1:]...) } return ss }
[ "func", "RemoveStopWords", "(", "ss", "[", "]", "string", ")", "[", "]", "string", "{", "var", "removal", "[", "]", "int", "\n", "for", "i", ",", "s", ":=", "range", "ss", "{", "if", "Contains", "(", "StopWords", ",", "s", ")", "{", "removal", "=...
// RemoveStopWords finds and removes stopwords from a slice of strings.
[ "RemoveStopWords", "finds", "and", "removes", "stopwords", "from", "a", "slice", "of", "strings", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/language.go#L573-L584
126,978
itsabot/itsabot
core/log/log.go
New
func New(pluginName string) *Logger { lg := log.New(os.Stdout, "", log.Ldate|log.Ltime) if len(pluginName) == 0 { return &Logger{logger: lg} } return &Logger{ prefix: fmt.Sprintf("[%s] ", pluginName), logger: lg, } }
go
func New(pluginName string) *Logger { lg := log.New(os.Stdout, "", log.Ldate|log.Ltime) if len(pluginName) == 0 { return &Logger{logger: lg} } return &Logger{ prefix: fmt.Sprintf("[%s] ", pluginName), logger: lg, } }
[ "func", "New", "(", "pluginName", "string", ")", "*", "Logger", "{", "lg", ":=", "log", ".", "New", "(", "os", ".", "Stdout", ",", "\"", "\"", ",", "log", ".", "Ldate", "|", "log", ".", "Ltime", ")", "\n", "if", "len", "(", "pluginName", ")", "...
// New returns a Logger which supports a custom prefix representing a plugin's // name.
[ "New", "returns", "a", "Logger", "which", "supports", "a", "custom", "prefix", "representing", "a", "plugin", "s", "name", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/log/log.go#L100-L109
126,979
itsabot/itsabot
core/log/log.go
Fatal
func (l *Logger) Fatal(v ...interface{}) { l.logger.Fatalf("%s", l.prefix+fmt.Sprintln(v...)) }
go
func (l *Logger) Fatal(v ...interface{}) { l.logger.Fatalf("%s", l.prefix+fmt.Sprintln(v...)) }
[ "func", "(", "l", "*", "Logger", ")", "Fatal", "(", "v", "...", "interface", "{", "}", ")", "{", "l", ".", "logger", ".", "Fatalf", "(", "\"", "\"", ",", "l", ".", "prefix", "+", "fmt", ".", "Sprintln", "(", "v", "...", ")", ")", "\n", "}" ]
// Fatal logs a statement and kills the running process.
[ "Fatal", "logs", "a", "statement", "and", "kills", "the", "running", "process", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/log/log.go#L142-L144
126,980
itsabot/itsabot
shared/task/iterate.go
Iterate
func Iterate(p *dt.Plugin, label string, opts OptsIterate) []dt.State { if len(label) == 0 { label = "__iterableStart" } return []dt.State{ { Label: label, OnEntry: func(in *dt.Msg) string { var ss []string mem := p.GetMemory(in, opts.IterableMemKey) if len(mem.Val) == 0 { mem.Val = []byte...
go
func Iterate(p *dt.Plugin, label string, opts OptsIterate) []dt.State { if len(label) == 0 { label = "__iterableStart" } return []dt.State{ { Label: label, OnEntry: func(in *dt.Msg) string { var ss []string mem := p.GetMemory(in, opts.IterableMemKey) if len(mem.Val) == 0 { mem.Val = []byte...
[ "func", "Iterate", "(", "p", "*", "dt", ".", "Plugin", ",", "label", "string", ",", "opts", "OptsIterate", ")", "[", "]", "dt", ".", "State", "{", "if", "len", "(", "label", ")", "==", "0", "{", "label", "=", "\"", "\"", "\n", "}", "\n", "retur...
// Iterate through a set of options allowing the user to select one before // continuing.
[ "Iterate", "through", "a", "set", "of", "options", "allowing", "the", "user", "to", "select", "one", "before", "continuing", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/task/iterate.go#L27-L79
126,981
itsabot/itsabot
shared/task/iterate.go
ResetIterate
func ResetIterate(p *dt.Plugin, in *dt.Msg) { p.DeleteMemory(in, keySelection) }
go
func ResetIterate(p *dt.Plugin, in *dt.Msg) { p.DeleteMemory(in, keySelection) }
[ "func", "ResetIterate", "(", "p", "*", "dt", ".", "Plugin", ",", "in", "*", "dt", ".", "Msg", ")", "{", "p", ".", "DeleteMemory", "(", "in", ",", "keySelection", ")", "\n", "}" ]
// ResetIterate should be called from within your plugin's SetOnReset function // if you use the Iterable task.
[ "ResetIterate", "should", "be", "called", "from", "within", "your", "plugin", "s", "SetOnReset", "function", "if", "you", "use", "the", "Iterable", "task", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/task/iterate.go#L83-L85
126,982
itsabot/itsabot
shared/datatypes/http_route.go
AddRoutes
func (hm HandlerMap) AddRoutes(prefix string, r *httprouter.Router) { for httpRoute, h := range hm { p := path.Join("/", prefix, httpRoute.Path) r.HandlerFunc(httpRoute.Method, p, h) } }
go
func (hm HandlerMap) AddRoutes(prefix string, r *httprouter.Router) { for httpRoute, h := range hm { p := path.Join("/", prefix, httpRoute.Path) r.HandlerFunc(httpRoute.Method, p, h) } }
[ "func", "(", "hm", "HandlerMap", ")", "AddRoutes", "(", "prefix", "string", ",", "r", "*", "httprouter", ".", "Router", ")", "{", "for", "httpRoute", ",", "h", ":=", "range", "hm", "{", "p", ":=", "path", ".", "Join", "(", "\"", "\"", ",", "prefix"...
// AddRoutes to the router dynamically, enabling drivers to add routes to an // application at runtime usually as part of their initialization.
[ "AddRoutes", "to", "the", "router", "dynamically", "enabling", "drivers", "to", "add", "routes", "to", "an", "application", "at", "runtime", "usually", "as", "part", "of", "their", "initialization", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/http_route.go#L29-L34
126,983
itsabot/itsabot
shared/datatypes/http_route.go
NewHandlerMap
func NewHandlerMap(rhs []RouteHandler) HandlerMap { hm := HandlerMap{} for _, rh := range rhs { route := HTTPRoute{ Path: rh.Path, Method: rh.Method, } hm[route] = rh.Handler } return hm }
go
func NewHandlerMap(rhs []RouteHandler) HandlerMap { hm := HandlerMap{} for _, rh := range rhs { route := HTTPRoute{ Path: rh.Path, Method: rh.Method, } hm[route] = rh.Handler } return hm }
[ "func", "NewHandlerMap", "(", "rhs", "[", "]", "RouteHandler", ")", "HandlerMap", "{", "hm", ":=", "HandlerMap", "{", "}", "\n", "for", "_", ",", "rh", ":=", "range", "rhs", "{", "route", ":=", "HTTPRoute", "{", "Path", ":", "rh", ".", "Path", ",", ...
// NewHandlerMap builds a HandlerMap from a slice of RouteHandlers. This is a // convenience function, since using RouteHandlers directly is very verbose for // plugins.
[ "NewHandlerMap", "builds", "a", "HandlerMap", "from", "a", "slice", "of", "RouteHandlers", ".", "This", "is", "a", "convenience", "function", "since", "using", "RouteHandlers", "directly", "is", "very", "verbose", "for", "plugins", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/http_route.go#L39-L49
126,984
itsabot/itsabot
shared/interface/sms/sms.go
Send
func (c *Conn) Send(to, msg string) error { return c.conn.Send(to, msg) }
go
func (c *Conn) Send(to, msg string) error { return c.conn.Send(to, msg) }
[ "func", "(", "c", "*", "Conn", ")", "Send", "(", "to", ",", "msg", "string", ")", "error", "{", "return", "c", ".", "conn", ".", "Send", "(", "to", ",", "msg", ")", "\n", "}" ]
// Send an SMS message through an opened driver connection. The from number is // handled by the driver.
[ "Send", "an", "SMS", "message", "through", "an", "opened", "driver", "connection", ".", "The", "from", "number", "is", "handled", "by", "the", "driver", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/interface/sms/sms.go#L77-L79
126,985
itsabot/itsabot
shared/language/summarize.go
Contains
func Contains(wordList []string, s string) bool { s = strings.TrimRight(strings.ToLower(s), ".,;:!?'\"") for _, word := range wordList { if s == word { return true } } return false }
go
func Contains(wordList []string, s string) bool { s = strings.TrimRight(strings.ToLower(s), ".,;:!?'\"") for _, word := range wordList { if s == word { return true } } return false }
[ "func", "Contains", "(", "wordList", "[", "]", "string", ",", "s", "string", ")", "bool", "{", "s", "=", "strings", ".", "TrimRight", "(", "strings", ".", "ToLower", "(", "s", ")", ",", "\"", "\\\"", "\"", ")", "\n", "for", "_", ",", "word", ":="...
// Contains determines whether a slice of strings contains a specific word.
[ "Contains", "determines", "whether", "a", "slice", "of", "strings", "contains", "a", "specific", "word", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/summarize.go#L6-L14
126,986
itsabot/itsabot
core/handlers.go
newRouter
func newRouter() *httprouter.Router { router := httprouter.New() router.ServeFiles("/public/*filepath", http.Dir("public")) if os.Getenv("ABOT_ENV") != "production" { initCMDGroup(router) } // Web routes router.HandlerFunc("GET", "/", hIndex) router.HandlerFunc("POST", "/", hMain) router.HandlerFunc("OPTION...
go
func newRouter() *httprouter.Router { router := httprouter.New() router.ServeFiles("/public/*filepath", http.Dir("public")) if os.Getenv("ABOT_ENV") != "production" { initCMDGroup(router) } // Web routes router.HandlerFunc("GET", "/", hIndex) router.HandlerFunc("POST", "/", hMain) router.HandlerFunc("OPTION...
[ "func", "newRouter", "(", ")", "*", "httprouter", ".", "Router", "{", "router", ":=", "httprouter", ".", "New", "(", ")", "\n", "router", ".", "ServeFiles", "(", "\"", "\"", ",", "http", ".", "Dir", "(", "\"", "\"", ")", ")", "\n\n", "if", "os", ...
// newRouter initializes and returns a router.
[ "newRouter", "initializes", "and", "returns", "a", "router", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L42-L84
126,987
itsabot/itsabot
core/handlers.go
hIndex
func hIndex(w http.ResponseWriter, r *http.Request) { var err error env := os.Getenv("ABOT_ENV") if env != "production" && env != "test" { p := filepath.Join("assets", "html", "layout.html") tmplLayout, err = template.ParseFiles(p) if err != nil { writeErrorInternal(w, err) return } if err = compileA...
go
func hIndex(w http.ResponseWriter, r *http.Request) { var err error env := os.Getenv("ABOT_ENV") if env != "production" && env != "test" { p := filepath.Join("assets", "html", "layout.html") tmplLayout, err = template.ParseFiles(p) if err != nil { writeErrorInternal(w, err) return } if err = compileA...
[ "func", "hIndex", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "err", "error", "\n", "env", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "env", "!=", "\"", "\"", "&&", "env", "...
// hIndex presents the homepage to the user and populates the HTML with // server-side variables.
[ "hIndex", "presents", "the", "homepage", "to", "the", "user", "and", "populates", "the", "HTML", "with", "server", "-", "side", "variables", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L88-L113
126,988
itsabot/itsabot
core/handlers.go
hMain
func hMain(w http.ResponseWriter, r *http.Request) { errMsg := "Something went wrong with my wiring... I'll get that fixed up soon." ret, err := ProcessText(r) if err != nil { if len(ret) > 0 { ret = errMsg } log.Info("failed to process text.", err) // TODO notify plugins listening for errors } w.Header...
go
func hMain(w http.ResponseWriter, r *http.Request) { errMsg := "Something went wrong with my wiring... I'll get that fixed up soon." ret, err := ProcessText(r) if err != nil { if len(ret) > 0 { ret = errMsg } log.Info("failed to process text.", err) // TODO notify plugins listening for errors } w.Header...
[ "func", "hMain", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "errMsg", ":=", "\"", "\"", "\n", "ret", ",", "err", ":=", "ProcessText", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "if", "len", ...
// hMain is the endpoint to hit when you want a direct response via JSON. // The Abot console uses this endpoint.
[ "hMain", "is", "the", "endpoint", "to", "hit", "when", "you", "want", "a", "direct", "response", "via", "JSON", ".", "The", "Abot", "console", "uses", "this", "endpoint", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L117-L133
126,989
itsabot/itsabot
core/handlers.go
hOptions
func hOptions(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Access-Control-Allow-Origin") w.WriteHeader(http.StatusOK) }
go
func hOptions(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Access-Control-Allow-Origin") w.WriteHeader(http.StatusOK) }
[ "func", "hOptions", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "w", ".", "Header", "(", ")", ".", "Set", "("...
// hOptions sets appropriate response headers in cases like browser-based // communication with Abot.
[ "hOptions", "sets", "appropriate", "response", "headers", "in", "cases", "like", "browser", "-", "based", "communication", "with", "Abot", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L137-L141
126,990
itsabot/itsabot
core/handlers.go
hapiLogoutSubmit
func hapiLogoutSubmit(w http.ResponseWriter, r *http.Request) { cookie, err := r.Cookie("id") if err != nil { writeError(w, err) return } uid := cookie.Value if uid == "null" { http.Error(w, "id was null", http.StatusBadRequest) return } q := `DELETE FROM sessions WHERE userid=$1` if _, err = db.Exec(q,...
go
func hapiLogoutSubmit(w http.ResponseWriter, r *http.Request) { cookie, err := r.Cookie("id") if err != nil { writeError(w, err) return } uid := cookie.Value if uid == "null" { http.Error(w, "id was null", http.StatusBadRequest) return } q := `DELETE FROM sessions WHERE userid=$1` if _, err = db.Exec(q,...
[ "func", "hapiLogoutSubmit", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "cookie", ",", "err", ":=", "r", ".", "Cookie", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "writeError", "(", "w",...
// hapiLogoutSubmit processes a logout request deleting the session from // the server.
[ "hapiLogoutSubmit", "processes", "a", "logout", "request", "deleting", "the", "session", "from", "the", "server", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L145-L162
126,991
itsabot/itsabot
core/handlers.go
hapiLoginSubmit
func hapiLoginSubmit(w http.ResponseWriter, r *http.Request) { var req struct { Email string Password string } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeErrorInternal(w, err) return } var u struct { ID uint64 Password []byte Admin bool } q := `SELECT id, password...
go
func hapiLoginSubmit(w http.ResponseWriter, r *http.Request) { var req struct { Email string Password string } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeErrorInternal(w, err) return } var u struct { ID uint64 Password []byte Admin bool } q := `SELECT id, password...
[ "func", "hapiLoginSubmit", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "req", "struct", "{", "Email", "string", "\n", "Password", "string", "\n", "}", "\n", "if", "err", ":=", "json", ".", "NewDecode...
// hapiLoginSubmit processes a logout request deleting the session from // the server.
[ "hapiLoginSubmit", "processes", "a", "logout", "request", "deleting", "the", "session", "from", "the", "server", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L166-L232
126,992
itsabot/itsabot
core/handlers.go
hapiProfile
func hapiProfile(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isLoggedIn(w, r) { return } } cookie, err := r.Cookie("id") if err != nil { writeErrorInternal(w, err) return } uid := cookie.Value var user struct { Name string Email string Phones []dt.Phone ...
go
func hapiProfile(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isLoggedIn(w, r) { return } } cookie, err := r.Cookie("id") if err != nil { writeErrorInternal(w, err) return } uid := cookie.Value var user struct { Name string Email string Phones []dt.Phone ...
[ "func", "hapiProfile", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isLoggedIn", "(", "w", ",", "r", ")", "{", "ret...
// hapiProfile shows a user profile with the user's current addresses, credit // cards, and contact information.
[ "hapiProfile", "shows", "a", "user", "profile", "with", "the", "user", "s", "current", "addresses", "credit", "cards", "and", "contact", "information", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L346-L378
126,993
itsabot/itsabot
core/handlers.go
hapiForgotPasswordSubmit
func hapiForgotPasswordSubmit(w http.ResponseWriter, r *http.Request) { var req struct{ Email string } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeErrorInternal(w, err) return } var user dt.User q := `SELECT id, name, email FROM users WHERE email=$1` err := db.Get(&user, q, req.Email) i...
go
func hapiForgotPasswordSubmit(w http.ResponseWriter, r *http.Request) { var req struct{ Email string } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeErrorInternal(w, err) return } var user dt.User q := `SELECT id, name, email FROM users WHERE email=$1` err := db.Get(&user, q, req.Email) i...
[ "func", "hapiForgotPasswordSubmit", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "req", "struct", "{", "Email", "string", "}", "\n", "if", "err", ":=", "json", ".", "NewDecoder", "(", "r", ".", "Body"...
// hapiForgotPasswordSubmit asks the server to send the user a "Forgot // Password" email with instructions for resetting their password.
[ "hapiForgotPasswordSubmit", "asks", "the", "server", "to", "send", "the", "user", "a", "Forgot", "Password", "email", "with", "instructions", "for", "resetting", "their", "password", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L429-L457
126,994
itsabot/itsabot
core/handlers.go
hapiResetPasswordSubmit
func hapiResetPasswordSubmit(w http.ResponseWriter, r *http.Request) { var req struct { Password string Secret string } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeErrorInternal(w, err) return } if len(req.Password) < 8 { writeError(w, errors.New("Your password must be at least 8 ...
go
func hapiResetPasswordSubmit(w http.ResponseWriter, r *http.Request) { var req struct { Password string Secret string } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeErrorInternal(w, err) return } if len(req.Password) < 8 { writeError(w, errors.New("Your password must be at least 8 ...
[ "func", "hapiResetPasswordSubmit", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "req", "struct", "{", "Password", "string", "\n", "Secret", "string", "\n", "}", "\n", "if", "err", ":=", "json", ".", "...
// hapiResetPasswordSubmit is arrived at through the email generated by // hapiForgotPasswordSubmit. This endpoint resets the user password with // another bcrypt hash after validating on the server that their new password is // sufficient.
[ "hapiResetPasswordSubmit", "is", "arrived", "at", "through", "the", "email", "generated", "by", "hapiForgotPasswordSubmit", ".", "This", "endpoint", "resets", "the", "user", "password", "with", "another", "bcrypt", "hash", "after", "validating", "on", "the", "server...
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L463-L517
126,995
itsabot/itsabot
core/handlers.go
hapiAdminExists
func hapiAdminExists(w http.ResponseWriter, r *http.Request) { var count int q := `SELECT COUNT(*) FROM users WHERE admin=TRUE LIMIT 1` if err := db.Get(&count, q); err != nil { writeErrorInternal(w, err) return } byt, err := json.Marshal(count > 0) if err != nil { writeErrorInternal(w, err) return } _,...
go
func hapiAdminExists(w http.ResponseWriter, r *http.Request) { var count int q := `SELECT COUNT(*) FROM users WHERE admin=TRUE LIMIT 1` if err := db.Get(&count, q); err != nil { writeErrorInternal(w, err) return } byt, err := json.Marshal(count > 0) if err != nil { writeErrorInternal(w, err) return } _,...
[ "func", "hapiAdminExists", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "count", "int", "\n", "q", ":=", "`SELECT COUNT(*) FROM users WHERE admin=TRUE LIMIT 1`", "\n", "if", "err", ":=", "db", ".", "Get", "...
// hapiAdminExists checks if an admin exists in the database.
[ "hapiAdminExists", "checks", "if", "an", "admin", "exists", "in", "the", "database", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L520-L536
126,996
itsabot/itsabot
core/handlers.go
hapiPlugins
func hapiPlugins(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } var settings []struct { Name string Value string PluginName string } q := `SELECT name, value, pluginname FROM settings` if ...
go
func hapiPlugins(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } var settings []struct { Name string Value string PluginName string } q := `SELECT name, value, pluginname FROM settings` if ...
[ "func", "hapiPlugins", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")", "{", "return...
// hapiPlugins responds with all of the server's installed plugin // configurations from each their respective plugin.json files and // database-stored configuration.
[ "hapiPlugins", "responds", "with", "all", "of", "the", "server", "s", "installed", "plugin", "configurations", "from", "each", "their", "respective", "plugin", ".", "json", "files", "and", "database", "-", "stored", "configuration", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L541-L588
126,997
itsabot/itsabot
core/handlers.go
hapiConversationsNeedTraining
func hapiConversationsNeedTraining(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } msgs := []struct { Sentence string FlexID *string CreatedAt time.Time UserID uint64 FlexIDType *int }{} ...
go
func hapiConversationsNeedTraining(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } msgs := []struct { Sentence string FlexID *string CreatedAt time.Time UserID uint64 FlexIDType *int }{} ...
[ "func", "hapiConversationsNeedTraining", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")"...
// hapiConversationsNeedTraining returns a list of all sentences that require a // human response.
[ "hapiConversationsNeedTraining", "returns", "a", "list", "of", "all", "sentences", "that", "require", "a", "human", "response", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L592-L631
126,998
itsabot/itsabot
core/handlers.go
hapiSendMessage
func hapiSendMessage(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } if !isValidCSRF(w, r) { return } } var req struct { UserID uint64 FlexID string FlexIDType dt.FlexIDType Name str...
go
func hapiSendMessage(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } if !isValidCSRF(w, r) { return } } var req struct { UserID uint64 FlexID string FlexIDType dt.FlexIDType Name str...
[ "func", "hapiSendMessage", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")", "{", "re...
// hapiSendMessage enables an admin to send a message to a user on behalf of // Abot from the Response Panel.
[ "hapiSendMessage", "enables", "an", "admin", "to", "send", "a", "message", "to", "a", "user", "on", "behalf", "of", "Abot", "from", "the", "Response", "Panel", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L780-L850
126,999
itsabot/itsabot
core/handlers.go
hapiAdmins
func hapiAdmins(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } var admins []struct { ID uint64 Name string Email string } q := `SELECT id, name, email FROM users WHERE admin=TRUE` err := db.Selec...
go
func hapiAdmins(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } var admins []struct { ID uint64 Name string Email string } q := `SELECT id, name, email FROM users WHERE admin=TRUE` err := db.Selec...
[ "func", "hapiAdmins", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")", "{", "return"...
// hapiAdmins returns a list of all admins with the training and manage team // permissions.
[ "hapiAdmins", "returns", "a", "list", "of", "all", "admins", "with", "the", "training", "and", "manage", "team", "permissions", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L854-L883