This repository has been archived by the owner on Oct 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docs, minor refactor to API to hold organization as field (#83)
Update docs, minor refactor to API to hold organization as field
- Loading branch information
1 parent
089187f
commit 9b6e70e
Showing
18 changed files
with
153 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package bot contains Rocket's Slack bot class | ||
package bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package cmd contains Rocket's Slack command framework | ||
package cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/nlopes/slack" | ||
"github.com/ubclaunchpad/rocket/model" | ||
) | ||
|
||
// Context stores a Slack message and the user who sent it. | ||
type Context struct { | ||
Message *slack.Msg | ||
User model.Member | ||
Options map[string]Option | ||
} | ||
|
||
// CommandHandler is the interface all handlers of Rocket commands must implement. | ||
type CommandHandler func(Context) (string, slack.PostMessageParameters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
) | ||
|
||
// Option represents a parameter that can be passed as part of a | ||
// Rocket command | ||
type Option struct { | ||
// Key is this option's identifier. Of course, keys for different options | ||
// under the same command should always be unique. For exmaple, one might | ||
// create a command with one option who's key is `name`. In this case the | ||
// user would assign a value to this key in their Slack command with | ||
// `name={myvalue}`. | ||
Key string | ||
Value string | ||
|
||
// HelpText is a description of what the option is used for. | ||
HelpText string | ||
|
||
// Format is a `regexp.Regexp` object that specifies the required format of | ||
// a value for an option. The `cmd` framework will enforce that this format | ||
// is met when a user enters a value for a given option, and will return an | ||
// appropriate error response if this is not the case. Commonly used format | ||
// `Regex`s can be found in [bot/util.go](bot/util.go). | ||
Format *regexp.Regexp | ||
|
||
// Required defines whether or not a value for this option is required when | ||
// a user uses this command. The `cmd` framework will enforce that a value | ||
// is set for each required option when a user enters a command, and will | ||
// return an appropriate error if this is not the case. | ||
Required bool | ||
} | ||
|
||
// validate returns nil if the given value meets the format requirements for | ||
// this option, returns the validation error otherwise. | ||
func (o *Option) validate(value string) error { | ||
// Check that the value meets the required format | ||
if !o.Format.MatchString(value) { | ||
return fmt.Errorf("Invalid format for option \"%s\". "+ | ||
"Format must match regular expression %s.", o.Key, o.Format.String()) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package config contains Rocket's configuration setup and structs | ||
package config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package data provides Rocket's interface to its database | ||
package data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
Rocket is the management and onboarding system for UBC Launch Pad. | ||
It is a Slack bot that features GitHub integration, a robust command | ||
framework, and a simple interface through which plugins can easily be added. | ||
*/ | ||
package main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package github contains Rocket's interface to GitHub's API. | ||
package github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package model contains the structs that define members and teams. | ||
package model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Package plugin contains the Plugin interface through which new functionality | ||
// is added to Rocket. | ||
package plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package core contains Rocket's core functionality in the form of a plugin. | ||
package core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Package welcome contains the Welcome plugin that welcomes new users to the | ||
// Slack workspace | ||
package welcome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Package server implements a read-only REST API interface to Rocket's team | ||
// management data. | ||
package server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters