Scripts and modules/libraries

Wouter de Geus <[email protected]> Wed, 31 Mar 2010 16:51:23 +0200
Newsgroups gmane.network.irc.irssi.user
Message-ID <[email protected]>
Hej folks,

I'm trying to write an Irssi script that uses a few external modules/libraries,
for instance XML::LibXML and a little helper module that I wrote myself.

I'm wondering if you guys can give me some advise on how to handle these modules.
My first problem was that my helper module needed to use the Irssi::input_add and 
Irssi::settings_* functions, which Irssi didn't like.

That is, Irssi said: 
 critical perl_settings_add: assertion `script != NULL' failed
and 
 critical perl_input_add: assertion `script != NULL' failed

Apparently Irssi tries to find the corresponding script name (in src/perl/perl-sources.c), which
doesn't work out for my helper module and fails the assertion.

This I could work around by introducing a wrapper function in the namespace of the script.
Ugly perhaps, but it works.

However, my other 'problem' is that reloading the script won't reload the module.
No huge deal since it doesn't get unloaded either, but this way one has to restart irssi (or use /upgrade for that matter)
in order to reload that module. I probably could introduce another ugly hack involving undef-ing
everything I find in the namespace of that module..... but I prefer something cleaner if possible :-p

If anyone knows of a cleaner solution (that doesn't involve including my entire helper module in the script), I'm all ears :)

Thanks for reading.

Wouter.