Skip to content
Snippets Groups Projects
Commit 9f389246 authored by Ophestra's avatar Ophestra
Browse files

add some debug messages

parent e4ecaec1
Branches
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ type configPayload struct {
}
func init() {
flag.StringVar(&configPath, "-t", "server.conf", "Specify configuration file location.")
flag.StringVar(&configPath, "c", "server.conf", "Specify configuration file location.")
}
func parse() {
......
......@@ -16,26 +16,31 @@ var allowedChannels map[string]bool
func handleChatInitiate(context *multiplexer.Context) {
// Lookup channel in allowed map
if context.Channel == nil || !allowedChannels[context.Channel.ID] {
log.Debug("Chat initiate skipped on irrelevant channel.")
return
}
// Get event
var event *discordgo.VoiceStateUpdate
if e, ok := context.Event.(*discordgo.VoiceStateUpdate); !ok {
log.Debug("Chat initiate skipped on incorrect event.")
return
} else {
event = e
}
if event.VoiceState != nil {
if event.VoiceState.ChannelID == "" {
log.Debug("Chat initiate skipped on empty channel ID.")
return
}
} else {
log.Debug("Chat initiate skipped on nil voice state.")
return
}
// Lookup already existing channel
if instancesUser[event.UserID] != nil {
log.Debug("Chat initiate skipped on existing channel owner.")
return
}
......@@ -53,12 +58,14 @@ func handleChatInitiate(context *multiplexer.Context) {
member = u
}
if member == nil {
log.Debug("Chat initiate skipped on nil member.")
return
}
// Create new instance
instance := newInstance(member)
if instance == nil {
log.Debug("Chat initiate skipped on nil instance.")
return
}
......
......@@ -63,11 +63,13 @@ func newInstance(member *discordgo.Member) *chatInstance {
func setupInstance(member *discordgo.Member) *chatInstance {
channelID := guildMap[member.GuildID]
if channelID == "" {
log.Debug("Instance setup skipped on empty channel ID.")
return nil
}
parentID := categoryMap[channelID]
if parentID == "" {
log.Debug("Instance setup skipped on emptu parent ID.")
return nil
}
......
......@@ -12,14 +12,27 @@ import (
"syscall"
)
var session *discordgo.Session
var m = multiplexer.New()
var system = multiplexer.NewCategory("System", "System-related utilities.")
var (
session *discordgo.Session
m = multiplexer.New()
system = multiplexer.NewCategory("System", "System-related utilities.")
verbose bool
)
func init() {
flag.BoolVar(&verbose, "v", false, "Start up with debug logging.")
}
func main() {
flag.Parse()
parse()
if verbose {
log.SetLevel(logrus.DebugLevel)
} else {
log.SetLevel(logrus.InfoLevel)
}
// Set discordgo log handler
discordgo.Logger = func(msgL, _ int, format string, a ...interface{}) {
var level logrus.Level
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment