package main import ( "net/http" "github.com/gorilla/mux" ) type levelUpAchieveStatProcessor struct { Achievements []levelUpAchievement } func (p *levelUpAchieveStatProcessor) GetName() string { return "LevelUp Achievements" } func (p *levelUpAchieveStatProcessor) GetStatKeys() []string { return []string{ "levelupachievement-*", } } type levelUpAchievement interface { GetName() string GetText() string // Returns whether the user already has this achievement DoesUserHave(uID string) bool // Processes the message, returns true if the achievement was triggered ProcessMessage(m *Message) bool } func (p *levelUpAchieveStatProcessor) ProcessMessage(m *Message) { type UserLevelUpStats struct { Name string Xp int ChannelStats map[string]int OtherStats map[string]int } var u *User var err error vars := mux.Vars(req) if u, err = getUserInfo(m.User); err != nil { return } p := UserLevelUpStats{Name: u.Name} p.Xp, _ = getUserStat(u.ID, "levelup-xp") p.ChannelStats = getAllLevelUpChannelXp(u.ID) p.OtherStats = getAllNonLevelUpStats(u.ID) } func (p *levelUpAchieveStatProcessor) ProcessAdminMessage(m *Message) {} func (p *levelUpAchieveStatProcessor) ProcessBotMessage(m *Message) {} func (p *levelUpAchieveStatProcessor) ProcessUserMessage(m *Message) {} func (p *levelUpAchieveStatProcessor) ProcessAdminUserMessage(m *Message) {} func (p *levelUpAchieveStatProcessor) ProcessBotUserMessage(m *Message) {} func (p *levelUpAchieveStatProcessor) ProcessChannelMessage(m *Message) { } func (p *levelUpAchieveStatProcessor) ProcessAdminChannelMessage(m *Message) {} func (p *levelUpAchieveStatProcessor) ProcessBotChannelMessage(m *Message) {} /* * Web Site Module */ type levelUpAchieveWebModule struct{} func (wm *levelUpAchieveWebModule) GetName() string { return "LevelUp Achievement Web Module" } func (wm *levelUpAchieveWebModule) GetRoutes() map[string]func(http.ResponseWriter, *http.Request) { ret := make(map[string]func(http.ResponseWriter, *http.Request)) ret["/levelup/achieve"] = wm.handleLevelUpAchieveGeneral return ret } func (wm *levelUpAchieveWebModule) Register() { for k, v := range wm.GetRoutes() { r.HandleFunc(k, v) } } func (wm *levelUpAchieveWebModule) GetMenuEntries() []menuItem { var ret []menuItem ret = append(ret, menuItem{Text: "Achieve GET!", Link: "/levelup/achieve"}) return ret } func (wm *levelUpAchieveWebModule) GetBottomMenuEntries() []menuItem { var ret []menuItem return ret } func (wm *levelUpAchieveWebModule) handleLevelUpAchieveGeneral(w http.ResponseWriter, req *http.Request) { initRequest(w, req) setMenuItemActive("Achieve GET!") }