mirror of https://github.com/hak5/scuzzy.git
master
parent
97a8b3f430
commit
ba53353265
|
@ -67,6 +67,8 @@ func (c *Commands) RegisterHandlers() {
|
|||
c.RegisterCommand("saveconfig", "Save Configuration to Disk", true, c.handleSaveConfig)
|
||||
c.RegisterCommand("reloadconfig", "Reload Configuration", true, c.handleReloadConfig)
|
||||
c.RegisterCommand("addrole", "Add a joinable role", true, c.handleAddCustomRole)
|
||||
c.RegisterCommand("enforcement", "Configure Overwatch enforcement", true, c.handleSetOverwatchEnforcement)
|
||||
c.RegisterCommand("wordfilter", "Configure Overwatch word filtering", true, c.handleSetWordFilter)
|
||||
}
|
||||
|
||||
func (c *Commands) ProcessCommand(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (c *Commands) handleSetOverwatchEnforcement(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||
args := strings.Split(m.Content, " ")
|
||||
|
||||
if len(args) != 2 {
|
||||
return errors.New("Invalid arguments supplied. Usage: " + c.Config.CommandKey + "enforcement [on/off]")
|
||||
}
|
||||
|
||||
mode := strings.ToLower(args[1])
|
||||
|
||||
if mode == "on" {
|
||||
c.Config.EnforceMode = true
|
||||
} else {
|
||||
c.Config.EnforceMode = false
|
||||
}
|
||||
|
||||
err := c.handleSaveConfig(s, m)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Commands) handleSetWordFilter(s *discordgo.Session, m *discordgo.MessageCreate) error {
|
||||
args := strings.Split(m.Content, " ")
|
||||
|
||||
if len(args) != 2 {
|
||||
return errors.New("Invalid arguments supplied. Usage: " + c.Config.CommandKey + "wordfilter [on/off]")
|
||||
}
|
||||
|
||||
mode := strings.ToLower(args[1])
|
||||
|
||||
if mode == "on" {
|
||||
c.Config.FilterLanguage = true
|
||||
} else {
|
||||
c.Config.FilterLanguage = false
|
||||
}
|
||||
|
||||
err := c.handleSaveConfig(s, m)
|
||||
|
||||
return err
|
||||
}
|
|
@ -28,6 +28,7 @@ type ServerStat struct {
|
|||
|
||||
type Overwatch struct {
|
||||
TotalMessages uint64
|
||||
TotalJoins uint64
|
||||
UserMessages map[string]*UserMessageStat
|
||||
ServerStats ServerStat
|
||||
Commands *commands.Commands
|
||||
|
@ -37,6 +38,8 @@ type Overwatch struct {
|
|||
func (o *Overwatch) ProcessMessage(s *discordgo.Session, m interface{}) {
|
||||
switch m.(type) {
|
||||
case *discordgo.MessageCreate:
|
||||
o.TotalMessages++
|
||||
|
||||
err := o.handleUserStat(s, m.(*discordgo.MessageCreate))
|
||||
if err != nil {
|
||||
log.Printf("[!] Error handling Overwatch user stat: %s\n", err.Error())
|
||||
|
@ -48,6 +51,8 @@ func (o *Overwatch) ProcessMessage(s *discordgo.Session, m interface{}) {
|
|||
}
|
||||
break
|
||||
case *discordgo.GuildMemberAdd:
|
||||
o.TotalJoins++
|
||||
|
||||
err := o.handleServerJoin(s, m.(*discordgo.GuildMemberAdd))
|
||||
if err != nil {
|
||||
log.Printf("[!] Error handling Overwatch server join: %s\n", err.Error())
|
||||
|
|
Loading…
Reference in New Issue