Export command to a contact (with video)
I have made a small plugin for fun which export the input/outputs of an Unix command to a contact. The principle is really simple: you enter a command (so far it's not implemented in the frontends, so you'll have to directly use the D-Bus API, throught e.g. D-Feet or qdbus), then the contacts allowed to communicate with it, with options if necessary, and voilà !
There are 2 mains advantages by doing this:
the first one is that you can give access to an interpreter to any of your contacts (I'm doing this with FTP in the video, I have also made tests with bc, ipython or zsh), without using heavy tools like ssh which need to create an access account, a client, an opened port, etc. Of course, it's not elaborated, it's not a terminal, but it can help out. The escape sequences (what bring colors and others things in your interpreter) are not managed yet, and it can scramble your output (I had the case with ipython). I'm thinking about catching them, and convert to color with XHTML-IM (well, a first step would be that SàT manage XHTML-IM :p ).
the second one is to help to write bots really quickly: you just have to make a script with read stdin and react to it. You can make a bot in a couple of minutes with any scripting language (sh, Python, Ruby, etc) or others. And you can directly debug it from a terminal, without the need of an XMPP server to test it. To show you how easy it is, I have made a little test in Python, here what it looks like:
#-*- coding: utf-8 -*-
def out(self, msg):
sys.stdout.write((u"%s\n" % msg).encode('utf-8'))
_input = raw_input().decode('utf-8','ignore')
args = _input[1:].split()
getattr(self, "cmd_%s" % args.encode('ascii').lower())(args[1:])
except (IndexError, AttributeError, UnicodeEncodeError):
def cmd_salut(self, args):
self.out(u"à Toi !")
if __name__ == "__main__":
bot = QuickBot()
The contact just have to enter !command [arguments] to make it do something (here !salut). To add a new command, you just have to create a new method named cmd_my_command, e.g. cmd_toto will add the command !toto. Easy isn't it ?
I have made a short video to show you this, it's in french but easy to understand even without sound, where I export a FTP server.
See you soon
As usual, to watch the video you can use a recent browser (the last Firefox/Iceweasel for example).
You can also use VLC (version >=1.1 only), by using the "Media/Open Netword Stream" menu and by entering this URL: http://www.goffi.org/videos/pr%c3%a9sentation_S%c3%a0T_6_export_commande.webm
Last but not least, you can use mplayer:: mplayer "http://www.goffi.org/videos/pr%c3%a9sentation_S%c3%a0T_6_export_commande.webm"
this video is licenced under Creative Common BY-SA