def mail_notify(self, inbox_count):
"""
If inbox_count is unchanged from last update - exit the function.
If new inbox_count is smaller - user read the message
somewhere else (browser, phone app, etc).
"""
notification_config = self.config.get('notifications')
local_inbox_count = self.local_data.get('inbox_count', 0)
if inbox_count == local_inbox_count:
return
elif inbox_count < local_inbox_count:
self.INDICATOR.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
return
self.INDICATOR.set_status(AppIndicator3.IndicatorStatus.ATTENTION)
if not notification_config:
return
if not self.services['notification']:
self.services['notification'] = Notify.init(self.APPINDICATOR_ID)
if notification_config == 1:
message_data = self.request.get_last_message()
header = "reddit mail from <b>{author}</b>".format(author=message_data['author'])
body = message_data['body']
else:
header = "You have a new reddit mail"
body = ''
Notify.Notification.new(
header,
body,
self.ICONS['main']
).show()
评论列表
文章目录