当前位置: 首页>>代码示例>>Golang>>正文


Golang Bot.LoadConfig方法代码示例

本文整理汇总了Golang中github.com/abourget/slick.Bot.LoadConfig方法的典型用法代码示例。如果您正苦于以下问题:Golang Bot.LoadConfig方法的具体用法?Golang Bot.LoadConfig怎么用?Golang Bot.LoadConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/abourget/slick.Bot的用法示例。


在下文中一共展示了Bot.LoadConfig方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: InitWebServerAuth

func (p *OAuthPlugin) InitWebServerAuth(bot *slick.Bot, webserver slick.WebServer) {
	p.webserver = webserver

	var config struct {
		WebAuthConfig OAuthConfig
	}
	bot.LoadConfig(&config)

	conf := config.WebAuthConfig
	webserver.SetAuthMiddleware(func(handler http.Handler) http.Handler {
		return &OAuthMiddleware{
			handler:   handler,
			plugin:    p,
			webserver: webserver,
			bot:       bot,
			oauthCfg: &oauth2.Config{
				ClientID:     conf.ClientID,
				ClientSecret: conf.ClientSecret,
				RedirectURL:  conf.RedirectURL + "/oauth2callback",
				Scopes:       []string{"identify"},
				Endpoint: oauth2.Endpoint{
					AuthURL:  "https://slack.com/oauth/authorize",
					TokenURL: "https://slack.com/api/oauth.access",
				},
			},
		}
	})
	webserver.SetAuthenticatedUserFunc(p.AuthenticatedUser)
}
开发者ID:Skarlso,项目名称:slick,代码行数:29,代码来源:auth.go

示例2: InitWebServer

func (webapp *Webapp) InitWebServer(bot *slick.Bot, enabledPlugins []string) {
	var conf struct {
		Webapp WebappConfig
	}
	bot.LoadConfig(&conf)

	webapp.bot = bot
	webapp.enabledPlugins = enabledPlugins
	webapp.config = &conf.Webapp
	webapp.store = sessions.NewCookieStore([]byte(conf.Webapp.SessionAuthKey), []byte(conf.Webapp.SessionEncryptKey))
	webapp.privateRouter = mux.NewRouter()
	webapp.publicRouter = mux.NewRouter()

	webapp.privateRouter.HandleFunc("/", webapp.handleRoot)

	web = webapp
}
开发者ID:plotly,项目名称:slick,代码行数:17,代码来源:webapp.go

示例3: InitPlugin

func (healthy *Healthy) InitPlugin(bot *slick.Bot) {
	var conf struct {
		HealthCheck struct {
			Urls []string
		}
	}

	bot.LoadConfig(&conf)

	healthy.urls = conf.HealthCheck.Urls

	bot.ListenFor(&slick.Conversation{
		MentionsMeOnly: true,
		ContainsAny:    []string{"health", "healthy?", "health_check"},
		HandlerFunc:    healthy.ChatHandler,
	})
}
开发者ID:plotly,项目名称:slick,代码行数:17,代码来源:healthy.go

示例4: InitPlugin

func (wicked *Wicked) InitPlugin(bot *slick.Bot) {
	wicked.bot = bot
	wicked.meetings = make(map[string]*Meeting)

	var conf struct {
		Wicked struct {
			Confrooms []string `json:"conf_rooms"`
		}
	}
	bot.LoadConfig(&conf)
	for _, confroom := range conf.Wicked.Confrooms {
		wicked.confRooms = append(wicked.confRooms, confroom)
	}

	bot.ListenFor(&slick.Conversation{
		HandlerFunc: wicked.ChatHandler,
	})
}
开发者ID:plotly,项目名称:slick,代码行数:18,代码来源:wicked.go

示例5: InitPlugin

func (p *Plugin) InitPlugin(bot *slick.Bot) {
	p.bot = bot

	err := bot.DB.Update(func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists(bucketName)
		return err
	})
	if err != nil {
		log.Fatalln("Couldn't create the `recognition` bucket")
	}

	var conf struct {
		Recognition Config
	}
	bot.LoadConfig(&conf)
	p.config = conf.Recognition

	p.store = &boltStore{db: bot.DB}

	p.listenRecognize()
	p.listenUpvotes()
}
开发者ID:errows,项目名称:slick,代码行数:22,代码来源:plugin.go

示例6: InitPlugin

func (bugger *Bugger) InitPlugin(bot *slick.Bot) {

	/*
	 * Get an array of issues matching Filters
	 */
	bugger.bot = bot

	var conf struct {
		Github github.Conf
	}

	bot.LoadConfig(&conf)

	bugger.ghclient = github.Client{
		Conf: conf.Github,
	}

	bot.Listen(&slick.Listener{
		MessageHandlerFunc: bugger.ChatHandler,
	})

}
开发者ID:Skarlso,项目名称:slick,代码行数:22,代码来源:bugger.go

示例7: InitWebPlugin

func (tabula *TabulaRasa) InitWebPlugin(bot *slick.Bot, privRouter *mux.Router, pubRouter *mux.Router) {
	var asanaConf struct {
		Asana struct {
			APIKey    string `json:"api_key"`
			Workspace string `json:"workspace"`
		}
	}

	bot.LoadConfig(&asanaConf)

	asanaClient := asana.NewClient(asanaConf.Asana.APIKey, asanaConf.Asana.Workspace)

	tabula.bot = bot
	tabula.asanaClient = asanaClient

	privRouter.HandleFunc("/plugins/tabularasa", func(w http.ResponseWriter, r *http.Request) {

		tabula.TabulaRasta()

	})

}
开发者ID:plotly,项目名称:slick,代码行数:22,代码来源:tabularasa.go

示例8: InitPlugin

func (dep *Deployer) InitPlugin(bot *slick.Bot) {
	var conf struct {
		Deployer DeployerConfig
	}
	bot.LoadConfig(&conf)

	dep.bot = bot
	dep.pubsub = pubsub.New(100)
	dep.config = &conf.Deployer
	dep.env = os.Getenv("PLOTLY_ENV")

	if dep.env == "" {
		dep.env = "debug"
	}

	dep.loadInternalAPI()

	go dep.pubsubForwardReply()

	bot.ListenFor(&slick.Conversation{
		HandlerFunc:    dep.ChatHandler,
		MentionsMeOnly: true,
	})
}
开发者ID:plotly,项目名称:slick,代码行数:24,代码来源:deployer.go

示例9: InitWebPlugin

func (hooker *Hooker) InitWebPlugin(bot *slick.Bot, privRouter *mux.Router, pubRouter *mux.Router) {
	hooker.bot = bot

	var conf struct {
		Hooker HookerConfig
	}
	bot.LoadConfig(&conf)
	hooker.config = conf.Hooker

	pubRouter.HandleFunc("/public/updated_slick_repo", hooker.updatedSlickRepo)

	stripeUrl := fmt.Sprintf("/public/stripehook/%s", hooker.config.StripeSecret)
	pubRouter.HandleFunc(stripeUrl, hooker.onPayingUser)

	pubRouter.HandleFunc("/public/monit", hooker.onMonit)

	privRouter.HandleFunc("/plugins/hooker.json", func(w http.ResponseWriter, r *http.Request) {
		if r.Method != "GET" {
			http.Error(w, "Method not accepted", 405)
			return
		}

	})
}
开发者ID:plotly,项目名称:slick,代码行数:24,代码来源:hooker.go


注:本文中的github.com/abourget/slick.Bot.LoadConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。