From b89e82108c6d89c6c2d9dd6c61ce36ff71662e2a Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Fri, 19 Nov 2010 12:05:37 +0100 Subject: [PATCH] new application boobmsg --- scripts/boobmsg | 25 ++++++++++++ weboob/applications/boobmsg/__init__.py | 21 ++++++++++ weboob/applications/boobmsg/boobmsg.py | 53 +++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100755 scripts/boobmsg create mode 100644 weboob/applications/boobmsg/__init__.py create mode 100644 weboob/applications/boobmsg/boobmsg.py diff --git a/scripts/boobmsg b/scripts/boobmsg new file mode 100755 index 0000000000..147249e05a --- /dev/null +++ b/scripts/boobmsg @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai + +# Copyright(C) 2010 Christophe Benz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +from weboob.applications.boobmsg import Boobmsg + + +if __name__ == '__main__': + Boobmsg.run() diff --git a/weboob/applications/boobmsg/__init__.py b/weboob/applications/boobmsg/__init__.py new file mode 100644 index 0000000000..3ea44062ac --- /dev/null +++ b/weboob/applications/boobmsg/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +# Copyright(C) 2010 Christophe Benz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +from .boobmsg import Boobmsg + +__all__ = ['Boobmsg'] diff --git a/weboob/applications/boobmsg/boobmsg.py b/weboob/applications/boobmsg/boobmsg.py new file mode 100644 index 0000000000..122e314176 --- /dev/null +++ b/weboob/applications/boobmsg/boobmsg.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +# Copyright(C) 2010 Christophe Benz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +import sys + +from weboob.capabilities.messages import ICapMessagesPost, Message +from weboob.tools.application.repl import ReplApplication +from weboob.tools.application.formatters.iformatter import IFormatter + + +__all__ = ['Boobmsg'] + + +class Boobmsg(ReplApplication): + APPNAME = 'boobmsg' + VERSION = '0.4' + COPYRIGHT = 'Copyright(C) 2010 Christophe Benz' + CAPS = ICapMessagesPost + + def do_post(self, line): + """ + post TO + + Post a message to the specified receiver. + The content of message is read on stdin. + """ + if not line: + print >>sys.stderr, 'You must give a receiver.' + return + receiver, backend_name = self.parse_id(line.strip()) + names = (backend_name,) if backend_name is not None else None + if self.interactive: + print 'Reading message content from stdin... Type ctrl-D from an empty line to post message.' + content = sys.stdin.read() + message = Message(thread=None, id=None, content=content, receiver=receiver) + self.do('post_message', message, backends=names) + if self.interactive: + print 'Message sucessfully sent.' -- GitLab