add -e option to skip empty messages
This commit is contained in:
parent
37bab806b2
commit
9fc1b5b459
1 changed files with 5 additions and 0 deletions
|
|
@ -35,6 +35,9 @@ class Boobmsg(ReplApplication):
|
||||||
COPYRIGHT = 'Copyright(C) 2010 Christophe Benz'
|
COPYRIGHT = 'Copyright(C) 2010 Christophe Benz'
|
||||||
CAPS = ICapMessages
|
CAPS = ICapMessages
|
||||||
|
|
||||||
|
def add_application_options(self, group):
|
||||||
|
group.add_option('-e', '--skip-empty', action='store_true', help='Don\'t send messages with an empty body.')
|
||||||
|
|
||||||
def do_status(self, line):
|
def do_status(self, line):
|
||||||
"""
|
"""
|
||||||
status
|
status
|
||||||
|
|
@ -79,6 +82,8 @@ class Boobmsg(ReplApplication):
|
||||||
if self.interactive:
|
if self.interactive:
|
||||||
print 'Reading message content from stdin... Type ctrl-D from an empty line to post message.'
|
print 'Reading message content from stdin... Type ctrl-D from an empty line to post message.'
|
||||||
content = sys.stdin.read()
|
content = sys.stdin.read()
|
||||||
|
if self.options.skip_empty and not content.strip():
|
||||||
|
return
|
||||||
message = Message(thread=None, id=None, content=content, receiver=receiver)
|
message = Message(thread=None, id=None, content=content, receiver=receiver)
|
||||||
try:
|
try:
|
||||||
self.do('post_message', message, backends=names).wait()
|
self.do('post_message', message, backends=names).wait()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue