Skip to content

Commit

Permalink
Add Channel switching
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian Brune authored and Maximilian Brune committed Sep 4, 2021
1 parent db5b99c commit be20f1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 12 additions & 2 deletions gomble/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ type UserState struct {

var BotUserState UserState

func SwitchChannel(channelid uint32) {
pck := mumbleproto.UserState{
ChannelId: &channelid,
}
logger.Infof("Switching to Channel %d\n", channelid)
if err := writeProto(&pck); err != nil {
logger.Errorf("Error while switching channel: %s", err.Error())
}
}

// send Message to the user
func SendMessageToUser(msg string, userid uint32) {
pck := mumbleproto.TextMessage{
Expand All @@ -22,7 +32,7 @@ func SendMessageToUser(msg string, userid uint32) {
}
logger.Infof("Sending Message to user with session-ID: %d\n", userid)
if err := writeProto(&pck); err != nil {
panic(err.Error())
logger.Errorf("Error while sending Message to User: %s", err.Error())
}
}

Expand All @@ -37,6 +47,6 @@ func SendMessageToChannel(msg string, channelid uint32) {
}
logger.Infof("Sending Message to Channel %d\n", channelid)
if err := writeProto(&pck); err != nil {
panic(err.Error())
logger.Errorf("Error while sending Message to Channel: %s", err.Error())
}
}
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ func OnPrivateMessageReceived(e gomble.PrivateMessageReceivedEvent) {
}

func OnChannelMessageReceived(e gomble.ChannelMessageReceivedEvent) {
// set current channel
//gomble.SwitchChannel(e.Channel) TODO
if strings.HasPrefix(e.Message, "#play ") {
logger.Debugf(e.Message + "\n")
yt, err := gomble.LoadTrack(e.Message)
Expand Down

0 comments on commit be20f1c

Please sign in to comment.