Alex Elliott
The internet home of a prospective software engineer
This is my personal blog where I discuss projects that I'm currently working on, work I've recently completed, or write about any topic which has caught my interest in the world of Computing from my studies or from my personal research.
zBot No More
December 13th, 2008
The title here is more sensational than it needs to be, I’m not discontinuing the zbot 2.0 project – rather, I’ve just decided that if I want to release it publicly, then I would like a more generic parent name for the software. The instance of the bot in irc.zymic.com will likely retain the name.
So, what’s the new name for the software? Well, that’s possibly still in flux, but for the moment I’ve decided I might go with polymer. A slightly nerdy nod to the fact I want to make this release inherently extensible, as much as is needed.
Polymerisation
Of course, with a name like that I really should elaborate on just why it’s going to be more modular and easily extensible than the previous bot.
There was nothing really wrong with the implementation before, and much of it has been kept constant in the new implementation. The most notable changes are in the format used to write modules, which has been simplified somewhat – and the fact that module interaction will be made possible allowing modules to reuse functionality included in a module that is already loaded into the bot.
My current WIP draft for module layout is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | <?php // module description up here? // // that would make sense. class mod_example { // any local variables required private $localvar; private $othervar; /// Core and required methods: // init, performs any initialisation required public function init() { // initialisation stuff... for example: $this->loadConfig(); // <-- (re)loads configuration in {confdir}/{name}.conf // the triggers and hooks registerTrigger('ping','respond'); registerHook('passive'); } // a rehash method which handles a complete config reload public function rehash() { // rejig internals in case our config has changed $this->loadConfig(); // <-- like this again perhaps? } /// about() and help() will probably make an appearance though since some are /// internal they need not include them. /// Trigger/Hook implementation // Here's a trigger, triggered of course by a !ping command. public function respond() { // note the lack of any arguments, instead the information will automatically // be made available through methods/variables contained within the base // class. This simplifies format, and allows us to make triggers and hooks // constant. $target = $this->state->target; $nick = $this->state->caller; // module intercommunication: if( is_object($_irc) ) $_irc->msg($target,$nick.', pong'); } // And here's a hook, called on every new packet public function passive() { // do stuff } /// And as always, you can declare internal functions for personal use. private function helper($arg1,$arg2) { // do something helpful } } ?> |
This format may undergo changes as I work on it, but it’s likely to look something like the above when I’m done.
Any suggestions/comments are very welcome, since this is going to be the interface anyone who wants to write modules will be using, so it’s important that it’s suitably intuitive.
One Response to “zBot No More”
Leave a Reply
Search
Recent Articles
- New Lexing Parsers and What They Mean for Expression Editor
- Back to Work
- Expression Editor Update (2)
- Expression Editor Update
- A New Project
My Projects
- Expression EditorGraphical Regular Expression Editing Tool
- My Pastebin – PasteSite.ComMy Easy Usable NoPaste/Pastebin Application
Blogroll
- Binary VisionThe Technology Musings of Ed Cradock
- Tim Davies sans vowelsThe Blog of Tim Davies
Other Sites
- HideMyAss – Free Proxy and Privacy ToolsHide My Ass! Free Proxy and Privacy Tools – Surf The Web Anonymously
- Iam-andy – Design PortfolioThe Design Portfolio of Andy Mallaby
- Zymic – Free Webhosting and MoreFree Web Hosting, Free Templates, Free Tutorials and more! Zymic Webmaster Resources
Archives
- February 2012 (1)
- July 2010 (1)
- January 2010 (1)
- December 2009 (2)
- November 2009 (1)
- February 2009 (1)
- January 2009 (1)
- December 2008 (1)
- November 2008 (5)
Categories
- arbutus (1)
- c++ (5)
- general (4)
- musing (1)
- php (5)
- polymer (4)
- zbot (3)
- projects (12)
- expressioneditor (5)
- qt (5)
- regular expressions (4)
- web (5)
June 28th, 2010 at 10:52 am
Congratulations! You have just won a new blog reader
.. really nice article, Mike.