예제 #1
0
// CatTestrunResultsURL returns a md formatted cat testrun results url
func CatTestrunResultsURL(dir string) string {
	config, _ := common.NewConfig()
	if config.URLs.BaseCatURL == "" {
		return dir
	}

	return fmt.Sprintf("<%s%s|results dir>", config.URLs.BaseCatURL, dir)
}
예제 #2
0
// P4WebBranchURL returns a md formatted p4web url
func P4WebBranchURL(branch, cln string) string {
	config, _ := common.NewConfig()
	if config.URLTemplates.P4WebBranch == "" {
		return branch
	}

	return fmt.Sprintf(config.URLTemplates.P4WebBranch, branch, cln, cln)
}
예제 #3
0
// CatAreaURL returns a md formatted cat area url
func CatAreaURL(area string) string {
	config, _ := common.NewConfig()
	if config.URLTemplates.CatArea == "" {
		return area
	}

	return fmt.Sprintf(config.URLTemplates.CatArea, area, area)
}
예제 #4
0
// CatTestrunURL returns a md formatted cat testrun url
func CatTestrunURL(testrun int, friendly string) string {
	config, _ := common.NewConfig()
	if config.URLTemplates.CatTestrun == "" {
		return friendly
	}

	return fmt.Sprintf(config.URLTemplates.CatTestrun, testrun, friendly)
}
예제 #5
0
// BuildwebTargetURL returns a md formatted buildweb url for a target
func BuildwebTargetURL(target string) string {
	config, _ := common.NewConfig()
	if config.URLTemplates.BuildwebTarget == "" {
		return target
	}

	return fmt.Sprintf(config.URLTemplates.BuildwebTarget, target, target)
}
예제 #6
0
// BuildwebSbURL returns a md formatted buildweb url for a sandbox build
func BuildwebSbURL(sb int, friendly string) string {
	config, _ := common.NewConfig()
	if config.URLTemplates.BuildwebSb == "" {
		return strconv.Itoa(sb)
	}

	return fmt.Sprintf(config.URLTemplates.BuildwebSb, sb, friendly)
}
예제 #7
0
// BuildwebBranchURL returns a md formatted buildweb url for a branch
func BuildwebBranchURL(branch string) string {
	config, _ := common.NewConfig()
	if config.URLTemplates.BuildwebBranch == "" {
		return branch
	}

	return fmt.Sprintf(config.URLTemplates.BuildwebBranch, branch, branch)
}
예제 #8
0
func main() {
	config, err := common.NewConfig()
	if err != nil {
		die(fmt.Errorf("error reading configuration file: %v", err))
	}

	db, err := common.InitDatabase()
	if err != nil {
		die(fmt.Errorf("error initializing the database: %v", err))
	}
	defer db.Close()

	client := slack.New(config.SlackbotAuthToken)
	client.SetDebug(config.Debug)

	authRes, err := client.AuthTest()
	if err != nil {
		die(fmt.Errorf("error calling AuthTest: %s", err))
	}
	log.Printf("URL: %s", authRes.URL)
	log.Printf("Team: %s:%s", authRes.TeamID, authRes.Team)
	log.Printf("User: %s:%s", authRes.UserID, authRes.User)

	userID := authRes.UserID
	botIDs := []string{
		fmt.Sprintf("<@%s>:", userID),
		fmt.Sprintf("<@%s>", userID)}
	log.Printf("vropsbot identifiers: %s", botIDs)

	rtm := client.NewRTM()
	go rtm.ManageConnection()

	go initCaches(client)

	comm.SB.ChanResponse = comm.RespChan(client, config.SwitchBoard.ResponseChannelSize)
	comm.SB.ChanPersist = comm.SaveChan(config.SwitchBoard.SaveChannelSize, db)
	comm.SB.ChanHeartbeat = comm.HeartbeatChan(config.SwitchBoard.HeartbeatChannelSize, db)

	if err := bot.PM.Prepare(); err != nil {
		die(fmt.Errorf("error calling Plugin Manager Prepare: %s", err))
	}

	go bot.PM.Start()

	comm.SB.ChanPersist <- &common.KVStore{
		Key:   "start",
		Value: time.Now().String()}
	os.Exit(bot.Pump(rtm, botIDs))
}
예제 #9
0
// Prepare initializes context
func (plugin *base) Prepare() (err error) {
	plugin.config, err = common.NewConfig()

	return
}