error messages when backend is not found or if it does not implement
ICapMessagesReply
This commit is contained in:
parent
e402c49fab
commit
0c71eb643d
1 changed files with 10 additions and 15 deletions
|
|
@ -29,7 +29,7 @@ import time
|
|||
import re
|
||||
import sys
|
||||
|
||||
from weboob.capabilities.messages import ICapMessages
|
||||
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply
|
||||
from weboob.tools.application import ConsoleApplication
|
||||
from weboob.tools.misc import html2text
|
||||
|
||||
|
|
@ -77,24 +77,19 @@ class Monboob(ConsoleApplication):
|
|||
content = content.split(u'\n-- \n')[0]
|
||||
|
||||
bname, id = reply_to.split('.', 1)
|
||||
backend = self.weboob.backends[bname]
|
||||
try:
|
||||
backend = self.weboob.backends[bname]
|
||||
except KeyError:
|
||||
print >>sys.stderr, 'Backend %s not found' % bname
|
||||
return 1
|
||||
|
||||
if not backend.has_caps(ICapMessagesReply):
|
||||
print >>sys.stderr, 'The backend %s does not implement ICapMessagesReply' % bname
|
||||
return 1
|
||||
|
||||
thread_id, msg_id = id.rsplit('.', 1)
|
||||
backend.post_reply(thread_id, msg_id, title, content)
|
||||
|
||||
MAIL_REGEXP = re.compile('(.*) <(.*)@(.*)>')
|
||||
def get_mail(self, text):
|
||||
if not text:
|
||||
return None
|
||||
|
||||
m = self.MAIL_REGEXP.match(text)
|
||||
if not m:
|
||||
to = text.split('@')[0]
|
||||
else:
|
||||
to = m.group(2)
|
||||
|
||||
return to
|
||||
|
||||
@ConsoleApplication.command("run daemon")
|
||||
def command_run(self):
|
||||
self.weboob.repeat(self.config.get('interval'), self.process)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue