Exemplo n.º 1
0
func NewFor(user string) (*Mavenlink, error) {
	token, err := db.GetSetting(user, "MAVENLINK_TOKEN")
	if err != nil {
		return nil, err
	}
	return NewMavenlink(token.Value, false), nil
}
Exemplo n.º 2
0
func NewFor(user string) (*Pivotal, error) {
	token, err := db.GetSetting(user, "PIVOTAL_TOKEN")
	if err != nil {
		return nil, err
	}
	return NewPivotal(token.Value, false), nil
}
Exemplo n.º 3
0
func conn(user string) (*pivotal.Pivotal, error) {
	token, err := db.GetSetting(user, "PIVOTAL_TOKEN")
	if err != nil {
		return nil, err
	}
	if token == nil {
		return nil, errors.New("No PIVOTAL_TOKEN set for @" + user)
	}
	con := pivotal.NewPivotal(token.Value, false)
	return con, nil
}
Exemplo n.º 4
0
func (r bot) getClient(user string) (*github.Client, error) {
	token, err := db.GetSetting(user, "GITHUB_TOKEN")
	if err != nil {
		return nil, err
	}
	if token == nil {
		return nil, errors.New("Missing `GITHUB_TOKEN`. Run `!gh auth` for more info.")
	}
	ts := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: token.Value},
	)
	tc := oauth2.NewClient(oauth2.NoContext, ts)

	return github.NewClient(tc), nil
}
Exemplo n.º 5
0
func (r bot) sendAuth(p *robots.Payload, cmd utils.Command) error {
	s, err := db.GetSetting(p.UserName, "PIVOTAL_TOKEN")
	if err != nil {
		return err
	}

	if s != nil {
		r.handler.Send(p, "You are already connected with Pivotal.")
		return nil
	}

	msg := `*Authenticating with Pivotal Tracker*
1. Visit your profile here <https://www.pivotaltracker.com/profile>
2. Copy your API token at the bottom of the page
3. Run the command:
   ` + "`/store set PIVOTAL_TOKEN=<token>`"
	r.handler.Send(p, msg)
	return nil
}
Exemplo n.º 6
0
func (r bot) auth(p *robots.Payload, cmd utils.Command) error {
	s, err := db.GetSetting(p.UserName, "GITHUB_TOKEN")
	if err != nil {
		return err
	}

	if s != nil {
		r.handler.Send(p, "You are already connected with GitHub.")
		return nil
	}

	r.handler.Send(p, `*Authenticating with GitHub*
1. Head over to your personal access tokens URL
	 https://github.com/settings/tokens

2. Click *Generate new token* button
3. Give your new token a name (_GistiaBot_ for instance)
4. Select the scopes you want to allow access
5. Click *Generate token*
6. Copy your token to the clipboard
7. Run the command:
   `+"`/store set GITHUB_TOKEN=<token>`")
	return nil
}