IRC Bot

To keep things brief, I’m trying to write an IRC bot that responds to channel events with the Ethernet shield. I have had much experience messing around with the raw IRC protocol, as I tweaked an IRC bot out of pure bash.

However, translating the string parsing code (which I have taken for granted in bash) to Arduino code is highly painful, even with the WString Library.

For brevity, I have only included the main parsing code. b is the Client object, and I have the << streaming in place.

void ircParse(String ircLine)
{
  static int ep;
  if(ircLine.startsWith("PING")){ircLine.replace('I','O'); b<<ircLine<<"\n\r";}}
  else if(ircLine.startsWith("ERROR")){Serial<<ircLine;}
  else
  {
    temp=ircLine.substring(0,ircLine.indexOf(' ')); ep=temp.indexOf('!');
    if(ep<0)
    {
      //ircLine.substring((server.length()+2),(ircLine.length()-1))<<"\n";
    }
    else
    {
      extnick=ircLine.substring(1,ep); temp=ircLine.substring(ircLine.indexOf(' '));
      // main code
      extnick="";
    }
  }
}

As you can see, it starts to get out of hand even without the second layer of parsing (JOINs PARTs QUITs MODEs etc). The code hangs after about 10 minutes of running. (Not to mention the Wiznet chip gets really hot)

I know it is highly demanding of an Arduino to handle a full Regex library, so I wonder if there are other solutions. I am very determined not to have a computer running alongside this setup as my electricity bills for the past month have shot through the roof :C

Thanks for any help in advance

I am very determined not to have a computer running alongside this setup as my electricity bills for the past month have shot through the roof

When you say "shot through the roof" - what do you mean?

I currently run 3 computers 24/7 at my house; this is in addition to two HVAC units, washer/dryer, water heater, oven, microwave, TV, etc, etc - tons of junk in a 4 bdrm, approx 2000 sf house.

My electric bill is currently running about $175 a month; not the greatest, but not the worst, either (and much better since I got new insulation, windows, and doors last year!).

Of that amount, I would say on $15.00 per month is due to the computers; any time I have added another machine running 24/7 on my network, I only saw my bill go up by $5.00 or so - I don't consider that a "jump" (just one less meal at Jack in the Box!).

To address your problem, though, you might have to cave into using a real computer of some sort for this parsing, or try to find a custom, small-scale parser that is more efficient than your current code (I would reccommend a recursive routine, but I don't think the stack in the Arduino would be able to handle too many iterations).

Have you looked into an embedded SoC (system-on-chip) solution, like a GuruPlug? Or something like an embeddedable PC (mini-ITX or otherwise), or even something like a BeagleBoard?

None of these options are cheap (although for what you get for $100 on the GuruPlug, darn tempting!) - but they may fit the bill...

The only things that are permanently left on in my house are the fridge and a DVD recorder (no air-conditioning), and the mere addition of my router/computer was enough for my parents to complain. Oh well.

I suppose this stops being a software problem...

I have looked at "small computers" (embedded PCs?) like the Mac Mini and it turns out I might as well use my wrecked up Dell (which I have been using until my parents started talking about the bill). Perhaps there would be a way to resurrect it such that it consumes less electricity?

The BeagleBoard and GuruPlug (also, the SheevaPlug) sure look tempting and able to get the job done, but I really wouldn't want to order anything of that sort unless I'm really desperate. I could settle for a Parallax Propeller but then I would have to learn Spin :stuck_out_tongue:

Thanks for the suggestions!