Browse Source

Add user activity

master
Gregory Rudolph 3 years ago
parent
commit
ab0455cf5b
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 13
      config.go
  2. 4
      discordMessage.go
  3. 1
      types.go

13
config.go

@ -59,6 +59,7 @@ func saveConfig() { @@ -59,6 +59,7 @@ func saveConfig() {
}
func adminInteraction(s *discordgo.Session, m string) {
defer log.PanicSafe()
admin, _ := s.GuildMember(config.GuildID, m)
counter, ok := config.Stats[admin.User.ID]
if !ok {
@ -69,6 +70,18 @@ func adminInteraction(s *discordgo.Session, m string) { @@ -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() {
time.Sleep(time.Until(config.BumpTime.Add(2 * time.Hour)))
dg.ChannelMessageSend(config.AdminChannel, "!d bump is ready")

4
discordMessage.go

@ -29,12 +29,16 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { @@ -29,12 +29,16 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
if m.ChannelID != config.AdminChannel {
lastActiveChan = m.ChannelID
lastActiveTime = time.Now()
if len(m.Attachments) > 0 {
activeInteraction(s, m.Author.ID)
}
}
if strings.HasPrefix(m.Content, "!d bump") {
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))
return
}
activeInteraction(s, m.Author.ID)
config.LastBumper = m.Author.ID
go bumpTimer(s)
return

1
types.go

@ -36,6 +36,7 @@ type Config struct { @@ -36,6 +36,7 @@ type Config struct {
BumpTime time.Time
LastBumper string
Stats map[string]int
Activity map[string]int
Unverified map[string]time.Time
Verifications map[string]Verification
Probations map[string]time.Time

Loading…
Cancel
Save