I´ve been writing a bot for a while now, with the purpose of learning proper Smalltalk and OOP idioms/techniques (I´ve been using C-ish languages for a long time now, and I´m trying to cure myself :D). I must say that the process has been quite enlightening so far, I never really understood OOP until now.
So far I have a bot that works fine for my needs, but I´d like to contribute back, so I´ll just list some thoughts and you can comment on them. All constructive criticism and pointers on how to do them are welcome!
I´m writing in on Pharo 3. I want to split the code I currently have in 3 parts: - part 1: a couple of classes IRCClient/ZdcSecureIRCClient mirroring POP3Client/ZdcSecurePOP3Client, with the intention of contributing them back to Pharo
- part 2: an IRCBot framework, which I´ll likely name 'Chromia', to be released under MIT license too - part 3: my own bot using that framework, which would add all the extras like games Does that sound reasonable?
At this point my code is quite messy, so I´m deciding whether to put it on SThub or not yet. I´m depending on http://smalltalkhub.com/#!/~PharoExtras/JSON for reading some JSON file from a website.
Though it´s not high on my priority list, I wouldn´t mind making it as portable to other dialects as possible, too. Cheers, Sergi |
Im my opinion... messy or not, all code should be shared! :)
2013/12/18 Sergi Reyner <[hidden email]>
Bernat Romagosa. |
In reply to this post by Sergi Reyner
An IRC bot is basically an REPL interface over a socket. It's a fun
project to implement with Smalltalk. I made a couple of bots circa 2000 (IRC was still a thing) with Perl. If you implement the IRC bot that doesn't integrate as an extension to an existing IRC client, you'll end up implementing an IRC client itself, which you will be able to use by your bot or yourself. :) Regards! Esteban A. Maringolo |
I created also a IRC bot with python. I was surpised how simple the irc protocol really is. But my robot was very basic.
I agree with Bernat, messy code is much more preferable than no code at all.
Sergi your plan sounds fine to me. I think it would be a good idea to announce new pharo builds via a bot to #pharo. This is a common practice for all channels. #emacs has an excellent bot that even allow you to search through documentation. So much potential :) |
In reply to this post by Bernat Romagosa
2013/12/18 Bernat Romagosa <[hidden email]>
There it goes! Cheers,
Sergi |
In reply to this post by Sergi Reyner
Sergi Reyner wrote:
Hi Sergi. Sounds like a great project. I agree with others. Don't worry if its messy.You can learn a lot from interested parties who might comment / correct come of the mess. I would say just ensure that it is packaged to load cleanly on a fresh image. Now not that I follow my own advice, but Release Early, Release Often [1] can be good advice. . [1] http://www.catb.org/esr/writings/homesteading/cathedral-bazaar/ar01s04.html cheers -ben |
2013/12/18 <[hidden email]> Yes, as I mention on the description, I´m wrapping my head around Metacello trying to put together a decent ConfigurationOfChromia.
Cheers, Sergi |
Sergi, you're too harsh on your code, I'm looking at it and it's nice! :) 2013/12/18 Sergi Reyner <[hidden email]>
Bernat Romagosa. |
2013/12/18 Bernat Romagosa <[hidden email]>
Yeah, I do that sometimes... but I can feel that it´s not as clean as it could be. More small pieces!! :) |
In reply to this post by Sergi Reyner
2013/12/18 Sergi Reyner <[hidden email]>
I´ve almost finished writing it. I just need some code to load the minimum amount of code required to use PPCompositeParser and GLMTabulator. |
2013/12/18 Sergi Reyner <[hidden email]>
Gofer it smalltalkhubUser: 'SergiReyner' project: 'Chromia';
package: 'ConfigurationOfChromia'; load. (Smalltalk at: #ConfigurationOfChromia) perform: #load. Cheers, Sergi |
In reply to this post by Sergi Reyner
Hi sergi
publish you code! It sound exciting. Stef
Super! Keep going reading and coding. Did you read Smalltalk by example.
|
In reply to this post by Sergi Reyner
On 18 Dec 2013, at 18:11, Sergi Reyner <[hidden email]> wrote:
Stef
|
In reply to this post by Sergi Reyner
what would be fun is to see if we can build a little tutorial that show to newbies how to write a simple IRC bot.
Would you be interested to work on that? Because I would love that my son is able to build one with Pharo. Stef
|
2013/12/19 Stéphane Ducasse <[hidden email]>
You mean how to write a bot with Chromia?
I would like to at least make the code a bit more modular/less network-centric first. That said, I will see if I can find time to write something that resembles a tutorial these holidays.
Cheers, Sergi |
On Thu, Dec 19, 2013 at 10:37 AM, Sergi Reyner <[hidden email]> wrote: You mean how to write a bot with Chromia? If you do it with Chromia, many details (such as network stuffs I guess) won't be shown. But this gives you the possibility to implement a great bot. If you do it without Chromia, you can show all the details so that the reader learns a lot of Pharo. Both are fine I would say. If you decide to write a tutorial, we could integrate it in the next book: https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/lastSuccessfulBuild/artifact/ -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill |
2013/12/19 Damien Cassou <[hidden email]>
That´s precisely why I asked, and why I said that first I´d like to modularise it as I mentioned in my original mail. That way I can first explain how the framework is built, so I can transmit the benefits of building it this way instead of mashing it up all together (which is how I began :D).
Then I can explain how to use that framework to write your own bot, which again makes the benefits stand out. At the moment I´m going over some decisions that I feel can be improved. From the top of my head:
- Class names are awfully chosen. Besides almost every one of them having IRC as a "namespace" prefix, some like IRCUser don´t convey enough meaning. - 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.
- Is PetitParser overkill for the time of parsing required? Are regular expressions a better fit for this task? - Do I keep the Glamour browsers? I´m rather partial to them :D
Oh. Wow. Cheers, Sergi |
On Thu, Dec 19, 2013 at 11:07 AM, Sergi Reyner <[hidden email]> wrote:
> - Class names are awfully chosen. Besides almost every one of them having > IRC as a "namespace" prefix, some like IRCUser don´t convey enough meaning. having a prefix is a common pattern. I don't see the problem of IRCUser as a name. > - 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. > - 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. -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill |
2013/12/19 Damien Cassou <[hidden email]>
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
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 :)
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.
More stuff to learn! \o/ Cheers, Sergi |
In reply to this post by Sergi Reyner
On 19 Dec 2013, at 10:37, Sergi Reyner <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |