Ejemplo n.º 1
0
func Init(ctx context.Context) context.Context {
	handleRE.Longest()
	adminRE.Longest()

	var err error
	state, err = persist.New("factoids.state", &st{
		Factoids: map[string]string{},
		Aliases:  map[string]string{},
		Used:     map[string]time.Time{},
	})
	if err != nil {
		d.F(err.Error())
	}

	s = state.Get().(*st)

	tpl.init()
	path := config.FromContext(ctx).Factoids.HookPath
	http.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
		tpl.render()
		tpl.execute(w)
	})

	return ctx
}
Ejemplo n.º 2
0
func Init(ctx context.Context) context.Context {
	var err error
	state, err = persist.New("rss.state", &seenLinks)
	if err != nil {
		d.F(err.Error())
	}

	seenLinks = *state.Get().(*map[[16]byte]int64)

	r := &rs{
		cfg: config.FromContext(ctx).RSS,
		irc: sirc.FromContext(ctx),
		tpl: tpl.FromContext(ctx),
	}

	go r.pollRSS()
	go r.pollMantis()

	return ctx
}
Ejemplo n.º 3
0
func initIRC(ctx context.Context) context.Context {
	adminRE.Longest()

	var err error
	adminState, err = persist.New("admins.state", &map[string]struct{}{
		"melkor":                       struct{}{},
		"sztanpet.users.quakenet.org":  struct{}{},
		"R1CH.users.quakenet.org":      struct{}{},
		"Jim.users.quakenet.org":       struct{}{},
		"Warchamp7.users.quakenet.org": struct{}{},
		"hwd.users.quakenet.org":       struct{}{},
		"paibox.users.quakenet.org":    struct{}{},
		"ThoNohT.users.quakenet.org":   struct{}{},
		"dodgepong.users.quakenet.org": struct{}{},
		"Sapiens.users.quakenet.org":   struct{}{},
	})
	if err != nil {
		d.F(err.Error())
	}

	admins = *adminState.Get().(*map[string]struct{})

	tcfg := config.FromContext(ctx)
	sirc.DebuggingEnabled = tcfg.Debug.Debug
	cfg := sirc.Config{
		Addr:     tcfg.IRC.Addr,
		Nick:     tcfg.IRC.Nick,
		Password: tcfg.IRC.Password,
		RealName: "http://obscommits.sztanpet.net/",
	}
	c := sirc.Init(cfg, func(c *sirc.IConn, m *irc.Message) bool {
		return handleIRC(ctx, c, m)
	})

	return c.ToContext(ctx)
}
Ejemplo n.º 4
0
func save(path string, data interface{}) {
	_, err := persist.New(path, data)
	if err != nil {
		panic(err.Error())
	}
}