Skip to content
This repository has been archived by the owner on Jan 20, 2021. It is now read-only.

Index out of range on dj.conf.General.CommandPrefix #50

Closed
Kamori opened this issue Mar 21, 2015 · 9 comments
Closed

Index out of range on dj.conf.General.CommandPrefix #50

Kamori opened this issue Mar 21, 2015 · 9 comments
Labels

Comments

@Kamori
Copy link

Kamori commented Mar 21, 2015

I know this might be a bad bug report, but strangely today I was no longer able start mumbleDJ due to Index Out of Range on

https://github.com/matthieugrieger/mumbledj/blob/master/main.go#L99

panic: runtime error: index out of range

goroutine 5 [running]:
main.(*mumbledj).OnTextMessage(0xb833a0, 0xc20800ed90)
        /opt/djmumble/mumbledj/main.go:99 +0x7e
main.*mumbledj.OnTextMessage·fm(0xc20800ed90)
        /opt/djmumble/mumbledj/main.go:196 +0x31
github.com/layeh/gumble/gumbleutil.Listener.OnTextMessage(0xc208028b10, 0xc208028b20, 0xc208028b30, 0xc208028b40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /opt/djmumble/mumbledj/.vendor/src/github.com/layeh/gumble/gumbleutil/listener.go:44 +0x37
github.com/layeh/gumble/gumbleutil.(*Listener).OnTextMessage(0xc20802e370, 0xc20800ed90)
        <autogenerated>:3 +0xaa
github.com/layeh/gumble/gumble.eventMultiplexer.OnTextMessage(0xc20803aff0, 0xc20803b020, 0xc20800ed90)
        /opt/djmumble/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/eventmultiplexer.go:62 +0x57
github.com/layeh/gumble/gumble.handleTextMessage(0xc208066630, 0xc2080c6000, 0xb7, 0xb7, 0x0, 0x0)
        /opt/djmumble/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/handlers.go:589 +0x8f8
github.com/layeh/gumble/gumble.(*Client).readRoutine(0xc208066630)
        /opt/djmumble/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/client.go:182 +0x1cf
created by github.com/layeh/gumble/gumble.(*Client).Connect
        /opt/djmumble/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/client.go:116 +0x5dc

goroutine 1 [chan receive]:
main.main()
        /opt/djmumble/mumbledj/main.go:206 +0xb7b

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2232 +0x1

goroutine 6 [select]:
github.com/layeh/gumble/gumble.(*Client).pingRoutine(0xc208066630)
        /opt/djmumble/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/client.go:159 +0x2dc
created by github.com/layeh/gumble/gumble.(*Client).Connect
        /opt/djmumble/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/client.go:117 +0x5f9

Making the following code changes I was able to fix it for myself

    // OnTextMessage event. Checks for command prefix, and calls parseCommand if it exists. Ignores
    // the incoming message otherwise.
    func (dj *mumbledj) OnTextMessage(e *gumble.TextMessageEvent) {
            plainMessage := gumbleutil.PlainText(&e.TextMessage)
            if len(plainMessage) >= 2 {
                    if string(plainMessage[0]) == dj.conf.General.CommandPrefix {
                            parseCommand(e.Sender, e.Sender.Name, plainMessage[1:])
                    }
            }
    }
@matthieugrieger
Copy link
Owner

Strange, I've never had this issue. I will test it out. Thanks!

@Kamori
Copy link
Author

Kamori commented Mar 21, 2015

Thank you, it would only occur when this was called

    dj.conf.General.CommandPrefix[0]

And config

    # Command prefix
    # DEFAULT VALUE: "!"
    CommandPrefix = "!"

@matthieugrieger
Copy link
Owner

Okay, so I just tested it on a clean Go install. I don't seem to be having the same problem that you are having. A few questions:

  1. Are you running the latest version of MumbleDJ?
  2. Does the bot crash immediately on startup? Or is it just when you put in chat messages?
  3. Was this installation working fine previously?

I'm not quite sure why you're experiencing this issue.

@Kamori
Copy link
Author

Kamori commented Mar 21, 2015

  1. March 7, 2015 -- v2.6.6

  2. Crashed immediately
  3. It was working previously only modifications done were to the config file (which I tested with a default config too)

@matthieugrieger
Copy link
Owner

That's very strange.. My friends were using the bot last night and had no issues whatsoever.

What I would suggest if you haven't done it already is to start with a fresh MumbleDJ installation. Try deleting ~/.mumbledj and the directory you have been building the executable from.

@hamilton5
Copy link

anytime your config changes ... its hard to merge current settings with new ones that get added in. I must say tho, it's running pretty solid now over two weeks, thanks for mumbledj

@matthieugrieger
Copy link
Owner

Yeah, I've realized that the way the config works is a bit cumbersome. One
of the things I'd like to improve the most is the configuration system. I
agree that it is hard to merge your existing settings with the new config
files.

I'll try to work out a better solution at some point (hopefully) soon.
On Mar 23, 2015 5:47 AM, "HaMiLToN5" notifications@github.com wrote:

anytime your config changes ... its hard to merge current settings with
new ones that get added in. I must say tho, it's running pretty solid now
over two weeks, thanks for mumbledj


Reply to this email directly or view it on GitHub
#50 (comment)
.

@matthieugrieger
Copy link
Owner

@Kamori: Are you still having issues with this?

@dylanetaft
Copy link
Contributor

Just submitted a pull request for this. It's a race condition so it's pretty random.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants