mirror of
https://github.com/42wim/matterbridge.git
synced 2025-02-18 03:29:15 -08:00
Format
This commit is contained in:
parent
729460b1ea
commit
723a426203
@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type soulseekMessage interface{}
|
||||
|
||||
type soulseekMessageResponse interface{}
|
||||
|
||||
const (
|
||||
@ -45,7 +46,6 @@ var ignoreMessageCodes = map[uint32]bool {
|
||||
1003: true,
|
||||
}
|
||||
|
||||
|
||||
// 1: Login
|
||||
type loginMessage struct {
|
||||
Code uint32
|
||||
@ -67,7 +67,6 @@ type loginMessageResponseFailure struct {
|
||||
Reason string
|
||||
}
|
||||
|
||||
|
||||
// 13: Say in chatroom
|
||||
type sayChatroomMessage struct {
|
||||
Code uint32
|
||||
@ -81,7 +80,6 @@ type sayChatroomMessageReceive struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
|
||||
// 14: Join room
|
||||
type joinRoomMessage struct {
|
||||
Code uint32
|
||||
@ -107,7 +105,6 @@ type joinRoomMessageResponse struct {
|
||||
Operators []string
|
||||
}
|
||||
|
||||
|
||||
// 16: User joined room
|
||||
type userJoinedRoomMessage struct {
|
||||
Room string
|
||||
@ -121,14 +118,12 @@ type userJoinedRoomMessage struct {
|
||||
CountryCode string
|
||||
}
|
||||
|
||||
|
||||
// 16: User left room
|
||||
type userLeftRoomMessage struct {
|
||||
Room string
|
||||
Username string
|
||||
}
|
||||
|
||||
|
||||
// 22: Private message (sometimes used by server to tell us errors)
|
||||
type privateMessageReceive struct {
|
||||
ID uint32
|
||||
@ -138,11 +133,9 @@ type privateMessageReceive struct {
|
||||
NewMessage bool
|
||||
}
|
||||
|
||||
|
||||
// 41: Kicked from server (relogged)
|
||||
type kickedMessageResponse struct{}
|
||||
|
||||
|
||||
// 142: Change password
|
||||
type changePasswordMessage struct {
|
||||
Code uint32
|
||||
@ -153,7 +146,6 @@ type changePasswordMessageResponse struct {
|
||||
Password string
|
||||
}
|
||||
|
||||
|
||||
func packMessage(message soulseekMessage) ([]byte, error) {
|
||||
buf := &bytes.Buffer{}
|
||||
var length uint32 = 0
|
||||
|
@ -51,7 +51,7 @@ func sliceEqual(s []string) bool {
|
||||
if len(s) <= 1 {
|
||||
return true
|
||||
}
|
||||
for _, x := range(s) {
|
||||
for _, x := range s {
|
||||
if x != s[0] {
|
||||
return false
|
||||
}
|
||||
@ -69,7 +69,7 @@ func (b *Bsoulseek) sendMessages() {
|
||||
msg, is_say := message.(sayChatroomMessage)
|
||||
if is_say {
|
||||
// can't send 5 of the same message in a row or we get banned
|
||||
if (sliceEqual(append(lastFourChatMessages, msg.Message))) {
|
||||
if sliceEqual(append(lastFourChatMessages, msg.Message)) {
|
||||
b.Log.Warnf("Dropping message: %s", msg.Message)
|
||||
continue
|
||||
}
|
||||
@ -191,7 +191,6 @@ func (b *Bsoulseek) Connect() error {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
func (b *Bsoulseek) JoinChannel(channel config.ChannelInfo) error {
|
||||
b.messagesToSend <- makeJoinRoomMessage(channel.Name)
|
||||
select {
|
||||
@ -203,7 +202,6 @@ func (b *Bsoulseek) JoinChannel(channel config.ChannelInfo) error {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (b *Bsoulseek) Send(msg config.Message) (string, error) {
|
||||
// Only process text messages
|
||||
b.Log.Debugf("=> Received local message %v", msg)
|
||||
@ -214,7 +212,6 @@ func (b *Bsoulseek) Send(msg config.Message) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
||||
func (b *Bsoulseek) doDisconnect() error {
|
||||
b.disconnect <- true
|
||||
close(b.messagesToSend)
|
||||
@ -224,7 +221,6 @@ func (b *Bsoulseek) doDisconnect() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (b *Bsoulseek) Disconnect() error {
|
||||
b.doDisconnect()
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user