Check for changed post id

merge-requests/21/head
Bob Mottram 2021-03-16 16:17:43 +00:00
parent 29e3fcf8d0
commit 9b79523262
1 changed files with 19 additions and 14 deletions

View File

@ -788,6 +788,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
currRepliesIndex = 0 currRepliesIndex = 0
currSentIndex = 0 currSentIndex = 0
newRepliesExist = False newRepliesExist = False
currPostId = ''
while (1): while (1):
session = createSession(proxyType) session = createSession(proxyType)
notifyJson = None notifyJson = None
@ -795,7 +796,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
getSpeakerFromServer(baseDir, session, nickname, password, getSpeakerFromServer(baseDir, session, nickname, password,
domain, port, httpPrefix, True, __version__) domain, port, httpPrefix, True, __version__)
if speakerJson: if speakerJson:
if speakerJson.get('notify'): if speakerJson.get('notify') and speakerJson.get('id'):
notifyJson = speakerJson['notify'] notifyJson = speakerJson['notify']
title = 'Epicyon' title = 'Epicyon'
if speakerJson['notify'].get('title'): if speakerJson['notify'].get('title'):
@ -810,21 +811,23 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
soundsDir = 'theme/default/sounds' soundsDir = 'theme/default/sounds'
if speakerJson['notify'].get('direct'): if speakerJson['notify'].get('direct'):
if speakerJson['notify']['direct'] is True: if speakerJson['notify']['direct'] is True:
if notificationSounds: if currPostId != speakerJson['id']:
_playNotificationSound(soundsDir + '/' + if notificationSounds:
dmSoundFilename, player) _playNotificationSound(soundsDir + '/' +
_desktopNotification(notificationType, title, dmSoundFilename, player)
'New direct message ' + _desktopNotification(notificationType, title,
actor + '/dm') 'New direct message ' +
actor + '/dm')
elif speakerJson['notify'].get('replyToYou'): elif speakerJson['notify'].get('replyToYou'):
if speakerJson['notify']['replyToYou'] is True: if speakerJson['notify']['replyToYou'] is True:
if notificationSounds: if currPostId != speakerJson['id']:
_playNotificationSound(soundsDir + '/' + if notificationSounds:
replySoundFilename, _playNotificationSound(soundsDir + '/' +
player) replySoundFilename,
_desktopNotification(notificationType, title, player)
'New reply ' + _desktopNotification(notificationType, title,
actor + '/tlreplies') 'New reply ' +
actor + '/tlreplies')
elif speakerJson['notify']['calendar'] != prevCalendar: elif speakerJson['notify']['calendar'] != prevCalendar:
if speakerJson['notify']['calendar'] is True: if speakerJson['notify']['calendar'] is True:
if notificationSounds: if notificationSounds:
@ -926,6 +929,8 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
print('') print('')
prevSay = speakerJson['say'] prevSay = speakerJson['say']
if speakerJson.get('id'):
currPostId = speakerJson['id']
# wait for a while, or until a key is pressed # wait for a while, or until a key is pressed
if noKeyPress: if noKeyPress: