Add user activity
This commit is contained in:
13
config.go
13
config.go
@ -59,6 +59,7 @@ func saveConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func adminInteraction(s *discordgo.Session, m string) {
|
func adminInteraction(s *discordgo.Session, m string) {
|
||||||
|
defer log.PanicSafe()
|
||||||
admin, _ := s.GuildMember(config.GuildID, m)
|
admin, _ := s.GuildMember(config.GuildID, m)
|
||||||
counter, ok := config.Stats[admin.User.ID]
|
counter, ok := config.Stats[admin.User.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -69,6 +70,18 @@ func adminInteraction(s *discordgo.Session, m string) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func activeInteraction(s *discordgo.Session, m string) {
|
||||||
|
defer log.PanicSafe()
|
||||||
|
user, _ := s.GuildMember(config.GuildID, m)
|
||||||
|
counter, ok := config.Stats[user.User.ID]
|
||||||
|
if !ok {
|
||||||
|
config.Activity[user.User.ID] = 1
|
||||||
|
} else {
|
||||||
|
config.Activity[user.User.ID] = counter + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func rebootBump() {
|
func rebootBump() {
|
||||||
time.Sleep(time.Until(config.BumpTime.Add(2 * time.Hour)))
|
time.Sleep(time.Until(config.BumpTime.Add(2 * time.Hour)))
|
||||||
dg.ChannelMessageSend(config.AdminChannel, "!d bump is ready")
|
dg.ChannelMessageSend(config.AdminChannel, "!d bump is ready")
|
||||||
|
|||||||
@ -29,12 +29,16 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
if m.ChannelID != config.AdminChannel {
|
if m.ChannelID != config.AdminChannel {
|
||||||
lastActiveChan = m.ChannelID
|
lastActiveChan = m.ChannelID
|
||||||
lastActiveTime = time.Now()
|
lastActiveTime = time.Now()
|
||||||
|
if len(m.Attachments) > 0 {
|
||||||
|
activeInteraction(s, m.Author.ID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(m.Content, "!d bump") {
|
if strings.HasPrefix(m.Content, "!d bump") {
|
||||||
if time.Since(config.BumpTime) < 2*time.Hour {
|
if time.Since(config.BumpTime) < 2*time.Hour {
|
||||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Sorry, <@%+v> already claimed the bump. Better luck next time!", config.LastBumper))
|
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Sorry, <@%+v> already claimed the bump. Better luck next time!", config.LastBumper))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
activeInteraction(s, m.Author.ID)
|
||||||
config.LastBumper = m.Author.ID
|
config.LastBumper = m.Author.ID
|
||||||
go bumpTimer(s)
|
go bumpTimer(s)
|
||||||
return
|
return
|
||||||
|
|||||||
1
types.go
1
types.go
@ -36,6 +36,7 @@ type Config struct {
|
|||||||
BumpTime time.Time
|
BumpTime time.Time
|
||||||
LastBumper string
|
LastBumper string
|
||||||
Stats map[string]int
|
Stats map[string]int
|
||||||
|
Activity map[string]int
|
||||||
Unverified map[string]time.Time
|
Unverified map[string]time.Time
|
||||||
Verifications map[string]Verification
|
Verifications map[string]Verification
|
||||||
Probations map[string]time.Time
|
Probations map[string]time.Time
|
||||||
|
|||||||
Reference in New Issue
Block a user