Playing with arrays of arrays and other fun.

Currently, Harlie in her current state does not run. I'm completely confused by this, and I'm blaming a lack of sleep. This is also why the git log is full of stupid crap. Whilst trying to play with the new commands and privileges, I forgot to close the buffer that had the file. When I later edited it (after merging the two branches, which went fine), it stomped all over the changes and I got horribly, horribly lost.

Anyway, enough of me being stupid, and on to the new feature (which doesn't work.):
I extended the privileges array a little to include the function that would be run, so that it now looks like this:

our @commands(
# [command, function, priv_level]
[quit, &Harlie::Commands::quit, 10],
[part, &Harlie::Commands::part, 10],
[join, &Harlie::Commands::join, 10],
[nick, &Harlie::Commands::nick, 10],
);

This, when I get it working, will replace that horrible if-elsif-else tree that I felt dirty putting together.
This means two big things:

  1. When new admin commands are added (Ones for loading/unloading modules spring to mind), they can be added easily and without adding more hair to the commands file.
  2. Plugins can easily add their own commands. For example, the dice-script that I'm working on for RPG channels that will add the command !dice.

Upon receiving a command, the following happens:

  1. The command prefix ("!") is removed
  2. The array is searched to find a matching command
  3. If the command is found in the list, the user's privilege level is checked.
  4. If the user has the appropriate privilege level (or the required level is set to 0 (e.g. Anyone can run it.)), the function named in the array is run.

Things that are on my TODO list are the plugin code and all the related gubbins that make them tick. However, that will have to wait until I'm more awake, considering the huge cockup that today was.

Another issue that I'm concerned with is multi-threading. I'm a little worried that any processing-intensive code, or long-running operations will freeze Harlie to the point that she isn't responsive to other commands or stops working on IRC. However, the state of threads in perl is a little confusing. I tried compiling perl with ithreads, but that just made Harlie barf (and this was when she actually ran...), so that doesn't seem to be a valid option.

I may be worrying a little too much, and she might handle it just fine. However, I will be running a few tests when she's functional again. This will, of course, require me to be functioning again, though.

Adverts