當前位置: 首頁>>代碼示例>>Golang>>正文


Golang plotbot.Bot類代碼示例

本文整理匯總了Golang中github.com/plotly/plotbot.Bot的典型用法代碼示例。如果您正苦於以下問題:Golang Bot類的具體用法?Golang Bot怎麽用?Golang Bot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Bot類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: InitPlugin

func (plotberry *PlotBerry) InitPlugin(bot *plotbot.Bot) {

	var conf struct {
		Plotberry PlotberryConf
	}
	err := bot.LoadConfig(&conf)
	if err != nil {
		log.Fatalln("Error loading PlotBerry config section: ", err)
		return
	}

	plotberry.bot = bot
	plotberry.pingTime = time.Duration(conf.Plotberry.PingTime) * time.Second
	plotberry.eraLength = conf.Plotberry.EraLength
	plotberry.endpoint = conf.Plotberry.EndPoint

	// if plotberry.eraLength is 0 we will get a divide by zero error - lets abort first
	if plotberry.eraLength == 0 {
		log.Fatal("Plotberry.eraLength may not be zero (divide by zero error), please set the configuration")
		return
	}

	statchan := make(chan TotalUsers, 100)

	go plotberry.launchWatcher(statchan)
	go plotberry.launchCounter(statchan)

	bot.ListenFor(&plotbot.Conversation{
		HandlerFunc: plotberry.ChatHandler,
	})
}
開發者ID:pkdevboxy,項目名稱:plotbot,代碼行數:31,代碼來源:plotberry.go

示例2: InitWebServerAuth

func (p *OAuthPlugin) InitWebServerAuth(bot *plotbot.Bot, webserver plotbot.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:pkdevboxy,項目名稱:plotbot,代碼行數:29,代碼來源:auth.go

示例3: InitPlugin

func (totw *Totw) InitPlugin(bot *plotbot.Bot) {
	plotbot.RegisterStringList("useless techs", []string{
		"http://i.minus.com/ib2bUNs2W1CI1V.gif",
		"http://media.giphy.com/media/anl0wydLNhKus/giphy.gif",
		"http://www.ptc.dcs.edu/Moody/comphistory/cavemanwriting.gif",
		"http://i.imgur.com/VbzhAbd.gif",
		"http://www.patrickcarrion.com/wp-content/uploads/2014/05/mowingdressgif.gif",
		"http://cdn.shopify.com/s/files/1/0243/7593/products/MKSB023_UselessMachine_Animation_grande.gif",
		"http://i.imgur.com/CRuLGek.gif",
		"http://i.imgur.com/EteBF9K.gif",
		"http://www.ohmagif.com/wp-content/uploads/2011/12/useless-invention.gif",
		"http://i3.kym-cdn.com/photos/images/original/000/495/044/9b8.gif",
		"http://uproxx.files.wordpress.com/2012/09/iron.gif",
	})
	plotbot.RegisterStringList("tech adept", []string{
		"you're a real tech adept",
		"what an investigator",
		"such deep search!",
		"a real innovator you are",
		"way to go, I'm impressed",
		"hope it's better than my own code",
		"noted, but are you sure it's good ?",
		"I'll take a look into this one",
		"you're generous!",
		"hurray!",
	})

	totw.bot = bot

	go totw.ScheduleAlerts(bot.Config.GeneralChannel, time.Thursday, 16, 0)

	bot.ListenFor(&plotbot.Conversation{
		HandlerFunc: totw.ChatHandler,
	})
}
開發者ID:cemoulto,項目名稱:plotbot,代碼行數:35,代碼來源:totw.go

示例4: InitPlugin

func (vote *Vote) InitPlugin(bot *plotbot.Bot) {
	vote.bot = bot

	bot.ListenFor(&plotbot.Conversation{
		PublicOnly:  true,
		HandlerFunc: vote.voteHandler,
	})
}
開發者ID:pkdevboxy,項目名稱:plotbot,代碼行數:8,代碼來源:vote.go

示例5: InitPlugin

func (standup *Standup) InitPlugin(bot *plotbot.Bot) {
	standup.bot = bot
	standup.sectionUpdates = make(chan sectionUpdate, 15)

	go standup.manageUpdatesInteraction()

	bot.ListenFor(&plotbot.Conversation{
		HandlerFunc: standup.ChatHandler,
	})
}
開發者ID:pkdevboxy,項目名稱:plotbot,代碼行數:10,代碼來源:standup.go

示例6: InitWebServer

func (webapp *Webapp) InitWebServer(bot *plotbot.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:pkdevboxy,項目名稱:plotbot,代碼行數:17,代碼來源:webapp.go

示例7: InitPlugin

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

	bot.LoadConfig(&conf)

	healthy.urls = conf.HealthCheck.Urls

	bot.ListenFor(&plotbot.Conversation{
		MentionsMeOnly: true,
		ContainsAny:    []string{"health", "healthy?", "health_check"},
		HandlerFunc:    healthy.ChatHandler,
	})
}
開發者ID:pkdevboxy,項目名稱:plotbot,代碼行數:17,代碼來源:healthy.go

示例8: InitPlugin

func (totw *Totw) InitPlugin(bot *plotbot.Bot) {
	plotbot.RegisterStringList("tech adept", []string{
		"you're a real tech adept",
		"what an investigator",
		"such deep search!",
		"a real innovator you are",
		"way to go, I'm impressed",
		"I'll take a look into this one",
		"you're generous!",
		"hurray!",
	})

	totw.bot = bot

	bot.ListenFor(&plotbot.Conversation{
		HandlerFunc: totw.ChatHandler,
	})
}
開發者ID:pkdevboxy,項目名稱:plotbot,代碼行數:18,代碼來源:totw.go

示例9: InitPlugin

func (bugger *Bugger) InitPlugin(bot *plotbot.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.ListenFor(&plotbot.Conversation{
		HandlerFunc: bugger.ChatHandler,
	})

}
開發者ID:pkdevboxy,項目名稱:plotbot,代碼行數:22,代碼來源:bugger.go

示例10: InitWebPlugin

func (tabula *TabulaRasa) InitWebPlugin(bot *plotbot.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:pkdevboxy,項目名稱:plotbot,代碼行數:22,代碼來源:tabularasa.go

示例11: InitPlugin

func (funny *Funny) InitPlugin(bot *plotbot.Bot) {

	plotbot.RegisterStringList("forcePush", []string{
		"http://www.gifcrap.com/g2data/albums/TV/Star%20Wars%20-%20Force%20Push%20-%20Goats%20fall%20over.gif",
		"http://i.imgur.com/ZvZR6Ff.jpg",
		"http://i3.kym-cdn.com/photos/images/original/000/014/538/5FCNWPLR2O3TKTTMGSGJIXFERQTAEY2K.gif",
		"http://i167.photobucket.com/albums/u123/KevinB550/FORCEPUSH/starwarsagain.gif",
		"http://i.imgur.com/dqSIv6j.gif",
		"http://www.gifcrap.com/g2data/albums/TV/Star%20Wars%20-%20Force%20Push%20-%20Gun%20breaks.gif",
		"http://media0.giphy.com/media/qeWa5wV5aeEHC/giphy.gif",
		"http://img40.imageshack.us/img40/2529/obiwan20is20a20jerk.gif",
		"http://img856.imageshack.us/img856/2364/obiwanforcemove.gif",
		"http://img526.imageshack.us/img526/4750/bc6.gif",
		"http://img825.imageshack.us/img825/6373/tumblrluaj77qaoa1qzrlhg.gif",
		"http://img543.imageshack.us/img543/6222/basketballdockingbay101.gif",
		"http://img687.imageshack.us/img687/5711/frap.gif",
		"http://img96.imageshack.us/img96/812/starpigdockingbay101.gif",
		"http://img2.wikia.nocookie.net/__cb20131117184206/halo/images/2/2a/Xt0rt3r.gif",
	})

	plotbot.RegisterStringList("robot jokes", []string{
		"http://timmybeanbrain.files.wordpress.com/2012/05/05242012_02-01.jpg",
		"http://timmybeanbrain.files.wordpress.com/2012/05/05242012_01-01.jpg",
		"http://timmybeanbrain.files.wordpress.com/2012/05/05232012_01-01.jpg",
		"http://timmybeanbrain.files.wordpress.com/2012/05/05017012_01-01.jpg",
		"http://timmybeanbrain.files.wordpress.com/2012/07/07022012_04-01.jpg",
	})

	plotbot.RegisterStringList("dishes", []string{
		"http://stream1.gifsoup.com/view6/4703823/monkey-doing-dishes-o.gif",
		"http://s3-ec.buzzfed.com/static/enhanced/webdr06/2013/6/24/16/anigif_enhanced-buzz-9769-1372104764-13.gif",
		"http://i.imgur.com/WIL27Br.gif",
	})

	bot.ListenFor(&plotbot.Conversation{
		HandlerFunc: funny.ChatHandler,
	})
}
開發者ID:cemoulto,項目名稱:plotbot,代碼行數:38,代碼來源:funny.go

示例12: InitPlugin

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

	dep.bot = bot
	dep.progress = make(chan string, 1000)
	dep.config = &conf.Deployer
	dep.env = os.Getenv("PLOTLY_ENV")

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

	dep.loadInternalAPI()

	go dep.forwardProgress()

	bot.ListenFor(&plotbot.Conversation{
		HandlerFunc:    dep.ChatHandler,
		MentionsMeOnly: true,
	})
}
開發者ID:cemoulto,項目名稱:plotbot,代碼行數:24,代碼來源:deployer.go

示例13: InitWebPlugin

func (hooker *Hooker) InitWebPlugin(bot *plotbot.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_plotbot_repo", hooker.updatedPlotbotRepo)

	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:pkdevboxy,項目名稱:plotbot,代碼行數:24,代碼來源:hooker.go


注:本文中的github.com/plotly/plotbot.Bot類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。