Example #1
0
File: slack.go Project: thuvh/hal
// New returns an initialized adapter
func New(r *hal.Robot) (hal.Adapter, error) {
	c := &config{}
	env.MustProcess(c)
	channels := strings.Split(c.Channels, ",")
	a := &adapter{
		token:          c.Token,
		team:           c.Team,
		channels:       channels,
		channelMode:    c.ChannelMode,
		mode:           c.Mode,
		botname:        c.Botname,
		iconEmoji:      c.IconEmoji,
		ircEnabled:     c.IrcEnabled,
		ircPassword:    c.IrcPassword,
		responseMethod: c.ResponseMethod,
	}
	spew.Dump(c)
	hal.Logger.Debugf("%v", os.Getenv("HAL_SLACK_CHANNEL_MODE"))
	hal.Logger.Debugf("channel mode: %v", a.channelMode)
	// if a.channelMode == "" {
	// a.channelMode = "whitelist"
	// }
	a.SetRobot(r)
	return a, nil
}
Example #2
0
File: redis.go Project: thuvh/hal
// New returns an new initialized store
func New(robot *hal.Robot) (hal.Store, error) {
	c := &config{}
	env.MustProcess(c)
	s := &store{
		config: c,
	}
	s.SetRobot(robot)
	return s, nil
}
Example #3
0
// New returns an initialized adapter
func New(robot *hal.Robot) (hal.Adapter, error) {
	c := &config{}
	env.MustProcess(c)

	a := &adapter{
		user:     c.User,
		password: c.Password,
		resource: c.Resource,
		rooms:    func() []string { return strings.Split(c.Rooms, ",") }(),
	}
	a.SetRobot(robot)
	return a, nil
}
Example #4
0
// New returns an initialized adapter
func New(robot *hal.Robot) (hal.Adapter, error) {
	c := &config{}
	env.MustProcess(c)

	a := &adapter{
		server:    c.Server,
		port:      c.Port,
		password:  c.Password,
		channel:   strings.ToLower(c.Channel),
		speakChan: make(chan ttsRequest),
	}

	a.SetRobot(robot)
	return a, nil
}
Example #5
0
// New returns an initialized adapter
func New(robot *hal.Robot) (hal.Adapter, error) {
	c := &config{}
	env.MustProcess(c)

	a := &adapter{
		user:     c.User,
		nick:     c.Nick,
		password: c.Password,
		server:   c.Server,
		port:     c.Port,
		channels: func() []string { return strings.Split(c.Channels, ",") }(),
		useTLS:   c.UseTLS,
	}
	// Set the robot name to the IRC nick so respond commands will work
	a.SetRobot(robot)
	a.Robot.SetName(a.nick)
	return a, nil
}
Example #6
0
File: auth.go Project: thuvh/hal
// NewAuth returns a pointer to an initialized Auth
func NewAuth(r *Robot) *Auth {
	a := &Auth{robot: r}

	c := &authConfig{}
	env.MustProcess(c)

	if c.Enabled {
		if c.Admins != "" {
			a.admins = strings.Split(c.Admins, ",")
		}

		r.Handle(
			addUserRoleHandler,
			removeUserRoleHandler,
			listUserRolesHandler,
			listAdminsHandler,
		)
	}

	return a
}
Example #7
0
func newConfig() *Config {
	c := &Config{}
	env.MustProcess(c)
	return c
}