Most people in #GMG on slashnet remember Pointything, the helpful IRC bot who worked really well but had too many bugs to be useful. Some might also briefly remember Addict, his Soldat server connected brother who.
Well unfortunately for everyone I’ve decided to create the 5th version of Pointything. However, there’s one big change. Instead of PHP, I’m writing him in python. One feature I wanted in Pointything was to be able to dynamically reload his own code to fix bugs on the fly. This briefly worked with PHP’s runkit module until something broke it, causing a segfault on every reload. Python has code reloading built right in to it (just re-import a module), so thats one big feature right away.
A second problem with Pointything’s PHP code was that I had to invent my own event system (modeled after Qt) to be able to queue up connection data and flood-prevention timers, use a trivia game with a timer, and to easily connect signals to slots. Remarkably, that worked really well. With Python, passing around callbacks is infinitely easier. Also, I can use PyQt or any other library for an event queue. Now that problem’s solved too.
The third big feature I really wanted in Pointything was to not make him dependent on a certain input stream. Prior to Pointything4, the IRC parsing was right in Pointything’s inheritance hiearchy. It made connecting to him over telnet to do secret admin commands a little hard to implement. With Pointything4 and my Qt-inspired library, it was a bit easier but still pretty hacky. I basically had Pointything connect to a “parseCommand” event from some input object. I managed to write my own scripting language in him too for input, which was tacked on near the end of his PHP life.
I had all these features in Pointything but the code was incredibly complex. I thought about making it all a bit more modularized, but if I was going to do that, I wanted the modules to be able to be reloaded. Runkit wasn’t working anymore, so eventually Pointything faded away.
But now I’m writing him in Python. Suddenly, that modularity feature is very possible.
Right now, this code:
# -*- coding: utf-8 -*-
import Pointything
if __name__ == “__main__”:
pthang = Pointything.Pointything()
pthang.extendWith(Pointything.ExtensionControl())
print pthang.do(”concat”,”Result of loading StringTransform: “,pthang.do(”loadModule”,”StringTransform”))
print pthang.do(”concat”,”Extensions: “,pthang.do(”listExtensions”))
print pthang.do(”concat”,”Functions: “, pthang.do(”listFunctions”))
print pthang.do(”concat”, “Hello”,” “).do(”concat”, “World!”,” “).do(”concat”,”how”,” “).do(”concat”,”are”, ” “).do(”concat”,”you”)
print pthang.do(”concat”, “Reversed ‘hello’:”,” “,pthang.do(”reverse”, “hello”))
out = pthang.do(”concat”, “Ho”, “dy”)
out = pthang.do(”reverse”, out)
print pthang.do(”concat”, “Reversed howdy bits:”, ” “, out)
Does this:
Result of loading StringTransform: Loading complete. Found extensions: ['strings']
Extensions: extensionControl strings
Functions: loadExtension listFunctions unloadExtension loadModule listExtensions concat reverse
Hello World! how are you
Reversed ‘hello’: olleh
Reversed howdy bits: dyHo
He is currently up on GitHub.
All this work for a simple arbitrary point counter. Sheesh.