hexchat / hexchat

GTK+ IRC client
https://hexchat.github.io
GNU General Public License v2.0
3.07k stars 535 forks source link

Lua plugins can cause interference with eachother #2260

Open SoniEx2 opened 5 years ago

SoniEx2 commented 5 years ago

a.lua

hexchat.register("A", "A", "1.0.0")
hexchat.hook_command("a", function(word)
hexchat.command(word[2])
hexchat.print("hello")
end)

b.lua

hexchat.register("B", "B", "1.0.0")
hexchat.hook_command("B", function()
hexchat.set_context(hexchat.find_context(nil, "#hexchat"))
end)

If you "/a b", it prints "hello" in #hexchat, not in the current context as it should.

TingPing commented 5 years ago

I'm not sure if that is undesirable behavior. How does C behave?

SoniEx2 commented 5 years ago

C plugins don't give eachother interference - you get "hello" where you did "/a b", not where /b set the plugin context to.

Hmm, looking at the code, you'll probably need to use a dummy handle (hexchat_plugingui_register("lua dummy", ...) or something) between lua script start and hexchat.register()... but that should fix the interference issues?

TingPing commented 5 years ago

They already use dummy handles, maybe only for pluginpref though?

SoniEx2 commented 5 years ago

Hmm...

How do you move hooks across handles?