Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main

main
Bob Mottram 2021-03-09 22:25:58 +00:00
commit 64c98eb7a4
2 changed files with 32 additions and 21 deletions

View File

@ -11,6 +11,7 @@ import html
import time import time
import sys import sys
import select import select
from utils import getFullDomain
from session import createSession from session import createSession
from speaker import getSpeakerFromServer from speaker import getSpeakerFromServer
from speaker import getSpeakerPitch from speaker import getSpeakerPitch
@ -117,6 +118,8 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
print('Running desktop notifications for ' + nickname + '@' + domain) print('Running desktop notifications for ' + nickname + '@' + domain)
print('/q or /quit to exit') print('/q or /quit to exit')
domainFull = getFullDomain(domain, port)
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
prevSay = '' prevSay = ''
prevDM = False prevDM = False
prevReply = False prevReply = False
@ -132,7 +135,6 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
shareSoundFilename = 'share.ogg' shareSoundFilename = 'share.ogg'
player = 'ffplay' player = 'ffplay'
notificationType = 'notify-send' notificationType = 'notify-send'
instanceTitle = 'Epicyon'
while (1): while (1):
session = createSession(proxyType) session = createSession(proxyType)
speakerJson = \ speakerJson = \
@ -140,6 +142,9 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
domain, port, httpPrefix, True, __version__) domain, port, httpPrefix, True, __version__)
if speakerJson: if speakerJson:
if speakerJson.get('notify'): if speakerJson.get('notify'):
title = 'Epicyon'
if speakerJson['notify'].get('title'):
title = speakerJson['notify']['title']
soundsDir = 'theme/default/sounds' soundsDir = 'theme/default/sounds'
if speakerJson['notify'].get('theme'): if speakerJson['notify'].get('theme'):
soundsDir = \ soundsDir = \
@ -152,47 +157,53 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
dmSoundFilename, player) dmSoundFilename, player)
_desktopNotification(notificationType, _desktopNotification(notificationType,
instanceTitle, title,
'New direct message') 'New direct message ' +
actor + '/dm')
elif replySoundFilename: elif replySoundFilename:
if speakerJson['notify']['reply'] and \ if speakerJson['notify']['reply'] and \
speakerJson['notify']['reply'] != prevReply: speakerJson['notify']['reply'] != prevReply:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
replySoundFilename, player) replySoundFilename, player)
_desktopNotification(notificationType, _desktopNotification(notificationType,
instanceTitle, title,
'New reply') 'New reply ' +
actor + '/tlreplies')
elif calendarSoundFilename: elif calendarSoundFilename:
if speakerJson['notify']['calendar'] and \ if speakerJson['notify']['calendar'] and \
speakerJson['notify']['calendar'] != prevCalendar: speakerJson['notify']['calendar'] != prevCalendar:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
calendarSoundFilename, player) calendarSoundFilename, player)
_desktopNotification(notificationType, _desktopNotification(notificationType,
instanceTitle, title,
'New calendar event') 'New calendar event ' +
actor + '/calendar')
elif followSoundFilename: elif followSoundFilename:
if speakerJson['notify']['followRequests'] and \ if speakerJson['notify']['followRequests'] and \
speakerJson['notify']['followRequests'] != prevFollow: speakerJson['notify']['followRequests'] != prevFollow:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
followSoundFilename, player) followSoundFilename, player)
_desktopNotification(notificationType, _desktopNotification(notificationType,
instanceTitle, title,
'New follow request') 'New follow request ' +
actor + '/followers#buttonheader')
elif likeSoundFilename: elif likeSoundFilename:
if speakerJson['notify']['likedBy'] != prevLike: if speakerJson['notify']['likedBy'] != prevLike:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
likeSoundFilename, player) likeSoundFilename, player)
_desktopNotification(notificationType, _desktopNotification(notificationType,
instanceTitle, title,
'New like') 'New like ' +
speakerJson['notify']['likedBy'])
elif shareSoundFilename: elif shareSoundFilename:
if speakerJson['notify']['share'] and \ if speakerJson['notify']['share'] and \
speakerJson['notify']['share'] != prevShare: speakerJson['notify']['share'] != prevShare:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
shareSoundFilename, player) shareSoundFilename, player)
_desktopNotification(notificationType, _desktopNotification(notificationType,
instanceTitle, title,
'New shared item') 'New shared item ' +
actor + '/shares')
prevDM = speakerJson['notify']['dm'] prevDM = speakerJson['notify']['dm']
prevReply = speakerJson['notify']['reply'] prevReply = speakerJson['notify']['reply']

View File

@ -12,8 +12,6 @@ import random
import urllib.parse import urllib.parse
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from session import getJson from session import getJson
from utils import isDM
from utils import isReply
from utils import camelCaseSplit from utils import camelCaseSplit
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -449,10 +447,6 @@ def _postToSpeakerJson(baseDir: str, httpPrefix: str,
if postJsonObject['object'].get('id'): if postJsonObject['object'].get('id'):
postId = postJsonObject['object']['id'] postId = postJsonObject['object']['id']
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
postDM = isDM(postJsonObject)
postReply = isReply(postJsonObject, actor)
followRequestsExist = False followRequestsExist = False
accountsDir = baseDir + '/accounts/' + nickname + '@' + domainFull accountsDir = baseDir + '/accounts/' + nickname + '@' + domainFull
approveFollowsFilename = accountsDir + '/followrequests.txt' approveFollowsFilename = accountsDir + '/followrequests.txt'
@ -461,13 +455,19 @@ def _postToSpeakerJson(baseDir: str, httpPrefix: str,
follows = fp.readlines() follows = fp.readlines()
if len(follows) > 0: if len(follows) > 0:
followRequestsExist = True followRequestsExist = True
postDM = False
dmFilename = accountsDir + '/.newDM'
if os.path.isfile(dmFilename):
postDM = True
postReply = False
replyFilename = accountsDir + '/.newReply'
if os.path.isfile(replyFilename):
postReply = True
likedBy = '' likedBy = ''
likeFilename = accountsDir + '/.newLike' likeFilename = accountsDir + '/.newLike'
if os.path.isfile(likeFilename): if os.path.isfile(likeFilename):
with open(likeFilename, 'r') as fp: with open(likeFilename, 'r') as fp:
likedBy = fp.read() likedBy = fp.read()
if '##sent##' in likedBy:
likedBy = ''
calendarFilename = accountsDir + '/.newCalendar' calendarFilename = accountsDir + '/.newCalendar'
postCal = os.path.isfile(calendarFilename) postCal = os.path.isfile(calendarFilename)
shareFilename = accountsDir + '/.newShare' shareFilename = accountsDir + '/.newShare'