Writing an IRC bot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Writing an IRC bot

kilon.alios

" I was considering using ChromiaXXX as a prefix instead.

The problem with xxxUser is that right now I manage two "User" concepts: what NickServ understands as a user, and what Chromia understands as a User, both of them different from an "IRC User" understood as someone or something who is connected to IRC. That´s what I meant by not enough meaning"


Make a User master class, subclass for IRC and Chromia. Dont use long names for what you can subclass, dont use long names for what you can document or add a class comment about. 

" I see. I was thinking about how less classes make a system simpler and that I should remove it because the functionality is identical to that of a Dictionary. But as you point out, the dilemma can also be solved by adding new behaviour :) "


Less classes mean more methods. Nope definitely not good. Protocols tend to fix the mess of having too many methods in a class (see Morph class and scream in horror) but I prefer more classes and less methods. This way its more clear what you trying to do with the code. Of course still you need class comments but of course you already know that ;) 





 

> - IRCConfiguration could be replaced by a dictionary since it´s nothing more
> than a bunch of data. But the, on the other hand, it could encapsulate
> validation on the settings to say something.

I'm not sure what would be the gain of transforming a proper class
into a dictionary. We usually do the opposite : creating classes out
of collection usage. I would keep the class and give it a
responsibility.


 
> - Is PetitParser overkill for the time of parsing required? Are regular
> expressions a better fit for this task?

I don't know what parsing is required. But if it works, I would keep
it the way it is.

There are two scenarios, one is parsing incoming messages from the server (I haven't considered DCC yet), which are in "IRC message format", documented in RFCs. I built the parser for it by translating parts of the BNF grammar into PetitParser.

The other one is parsing the message that a user types in the client as a command to to the bot, for example "!sayto #pharo Hello, my name is Chromia". Right now, I do that using regular expressions.

 
> - Do I keep the Glamour browsers? I´m rather partial to them :D

Glamour is really great to write interfaces and I really like it. Now,
if you develop a browser on top of glamour, you also need the moldable
glamour debugger.

More stuff to learn! \o/


Cheers,
Sergi

12