Note that there are some explanatory texts on larger screens.

plurals
  1. POIRC function dilemma
    text
    copied!<p>[EDIT] Sorry about the title being off. I was thinking of a different problem I was having, and accidentally crossed the two.</p> <p>Hi everyone, I'm writing my IRC bot skeleton in Python currently.</p> <p>To explain a couple things before I ask my question, I am writing a IRC bot complete with a plug-in system that will receive signals (i.e. when a message is received, a person was seen joining a channel, ...), and to call these functions contained in the plug-in, I will be using a helper method, i.e. if we saw a message, call <code>sawMessage</code>. <code>sawMessage</code> will locate which plug-ins want to handle messages, using a <code>PluginManager</code> class, etc. I have the whole system thought out.</p> <p>I also have a function for each IRC action, i.e. "doJoin", "doPart", etc. so that plug-ins can call these without me exposing my socket connection to the plug-ins directly. -- Should these functions automatically call the appropriate <code>sawMessage</code>, <code>sawJoin</code>, etc. ? Or should it be up to the plug-in to call <code>sawMessage</code> after calling <code>doMessage</code>? The reason I am asking is because if <code>doMessage</code> calls <code>sawMessage</code>, and <code>sawMessage</code> processes something that calls <code>doMessage</code>, it can end up recursing a lot before unwinding the stack.</p> <p>The drawbacks of making the plug-in responsible for calling <code>sawMessage</code> to notify the other plug-ins is that the plug-in would have a choice of NOT notifying the other plug-ins, and also that if the plug-in DOES call the <code>sawMessage</code> function, the recursion issue could pop right back up.</p> <p>I'm not sure how to resolve this. It seems like good practice to make <code>doMessage</code> automatically call <code>sawMessage</code> to notify other plug-ins, but there is always the possibility of a stack overflow due to recursion if the plug-in is not designed properly (i.e. not to respond to it's own messages), but if the plug-in has to call <code>sawMessage</code> anyway, the same issue is there.</p> <p>Got any thoughts/opinions on this? I know it's not a straight-out question/answer, but I can't decide what to do with this. Ordinarily, if I was just writing a small bot for my own usage, I wouldn't care about a possible recursion problem. However, I am writing this for the purpose of distribution (I want this to be the next HUGE bot, just like every other IRC bot developer :D ) and I want it made properly.</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload