예제 #1
0
파일: auth.go 프로젝트: Skarlso/slick
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)
}
예제 #2
0
파일: totw.go 프로젝트: Skarlso/slick
func (totw *Totw) InitPlugin(bot *slick.Bot) {
	slick.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",
	})
	slick.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.Listen(&slick.Listener{
		MessageHandlerFunc: totw.ChatHandler,
	})
}
예제 #3
0
파일: vote.go 프로젝트: Skarlso/slick
func (vote *Vote) InitPlugin(bot *slick.Bot) {
	vote.bot = bot

	bot.Listen(&slick.Listener{
		PublicOnly:         true,
		MessageHandlerFunc: vote.voteHandler,
	})
}
예제 #4
0
파일: vote.go 프로젝트: plotly/slick
func (vote *Vote) InitPlugin(bot *slick.Bot) {
	vote.bot = bot

	bot.ListenFor(&slick.Conversation{
		PublicOnly:  true,
		HandlerFunc: vote.voteHandler,
	})
}
예제 #5
0
파일: standup.go 프로젝트: plotly/slick
func (standup *Standup) InitPlugin(bot *slick.Bot) {
	standup.bot = bot
	standup.sectionUpdates = make(chan sectionUpdate, 15)

	go standup.manageUpdatesInteraction()

	bot.ListenFor(&slick.Conversation{
		HandlerFunc: standup.ChatHandler,
	})
}
예제 #6
0
파일: plotberry.go 프로젝트: plotly/slick
func (plotberry *PlotBerry) InitPlugin(bot *slick.Bot) {

	plotberry.bot = bot
	plotberry.celebrated = true
	plotberry.pingTime = 10 * time.Second
	plotberry.totalUsers = 100001

	statchan := make(chan TotalUsers, 100)

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

	bot.ListenFor(&slick.Conversation{
		HandlerFunc: plotberry.ChatHandler,
	})
}
예제 #7
0
파일: healthy.go 프로젝트: plotly/slick
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,
	})
}
예제 #8
0
파일: webapp.go 프로젝트: plotly/slick
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
}
예제 #9
0
파일: wicked.go 프로젝트: plotly/slick
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,
	})
}
예제 #10
0
파일: bugger.go 프로젝트: Skarlso/slick
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,
	})

}
예제 #11
0
파일: tabularasa.go 프로젝트: plotly/slick
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()

	})

}
예제 #12
0
파일: plugin.go 프로젝트: errows/slick
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()
}
예제 #13
0
파일: funny.go 프로젝트: Skarlso/slick
func (funny *Funny) InitPlugin(bot *slick.Bot) {

	slick.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",
	})

	slick.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",
	})

	slick.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.Listen(&slick.Listener{
		MessageHandlerFunc: funny.ChatHandler,
	})
}
예제 #14
0
파일: meeting.go 프로젝트: errows/slick
func NewMeeting(id string, user *slack.User, goal string, bot *slick.Bot, channel *slick.Channel, uuidNow time.Time) *Meeting {
	meeting := &Meeting{}
	meeting.ID = id
	meeting.Channel = channel.Name
	meeting.ChannelID = channel.ID
	meeting.Goal = strings.TrimSpace(goal)
	meeting.StartTime = uuidNow
	meeting.Decisions = []*Decision{}
	meeting.Refs = []*Reference{}
	meeting.Logs = []*Message{}
	meeting.Participants = []*User{}
	meeting.sendToRoom = func(msg string) {
		bot.SendToChannel(meeting.ChannelID, msg)
	}
	meeting.setTopic = func(topic string) {
		// TODO: set a topic with Slack.
		//hipchatv2.SetTopic(bot.Config.HipchatApiToken, roomID, topic)
	}

	newUser := meeting.ImportUser(user)
	meeting.CreatedBy = newUser

	return meeting
}
예제 #15
0
파일: deployer.go 프로젝트: plotly/slick
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,
	})
}
예제 #16
0
파일: hooker.go 프로젝트: plotly/slick
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
		}

	})
}
예제 #17
0
파일: faceoff.go 프로젝트: errows/slick
func (p *Faceoff) InitPlugin(bot *slick.Bot) {
	p.bot = bot

	faceoffRE := regexp.MustCompile("^!face[ _-]?off")
	bot.Listen(&slick.Listener{
		PublicOnly:     true,
		Matches:        faceoffRE,
		ListenForEdits: true,
		MessageHandlerFunc: func(listen *slick.Listener, msg *slick.Message) {
			// Launch a new game

			g := &Game{
				Faceoff:         p,
				OriginalMessage: msg,
				Channel:         msg.FromChannel,
				Started:         time.Now(),
			}
			msg.Reply("Ok, are you ready ?")
			go func() {
				g.Launch()
			}()
		},
	})

	bot.Listen(&slick.Listener{
		PrivateOnly: true,
		Matches:     faceoffRE,
		MessageHandlerFunc: func(listen *slick.Listener, msg *slick.Message) {
			user := p.users[msg.FromUser.ID]
			if user == nil {
				return
			}
			msg.Reply("Your !faceoff scores:\n`" + user.ScoreLine() + "`")
		},
	})

	bot.Listen(&slick.Listener{
		PrivateOnly: true,
		Matches:     faceoffRE,
		EventHandlerFunc: func(listen *slick.Listener, ev interface{}) {
			if _, ok := ev.(*slack.HelloEvent); ok {
				log.Println("faceoff: loading data")
				_ = p.bot.GetDBKey(faceoffKey, &p.users)

				// on HELLO, once the bot has updated all its Users..
				p.updateUsersFromSlack()
				log.Printf("faceoff: got %d profiles\n", len(p.users))
				p.flushData()
			}
		},
	})
}