More consistent terminology

merge-requests/30/head
Bob Mottram 2021-03-17 10:04:49 +00:00
parent ac01184e53
commit dfdc694cfe
3 changed files with 238 additions and 235 deletions

View File

@ -422,7 +422,7 @@ Or if you have picospeaker installed:
The desktop client has a few commands, which may be more convenient than the web interface for some purposes: The desktop client has a few commands, which may be more convenient than the web interface for some purposes:
``` bash ``` bash
quit Exit from the notification client quit Exit from the desktop client
mute Turn off the screen reader mute Turn off the screen reader
speak Turn on the screen reader speak Turn on the screen reader
sounds on Turn on notification sounds sounds on Turn on notification sounds

View File

@ -1,4 +1,4 @@
__filename__ = "notifications_client.py" __filename__ = "desktop_client.py"
__author__ = "Bob Mottram" __author__ = "Bob Mottram"
__license__ = "AGPL3+" __license__ = "AGPL3+"
__version__ = "1.2.0" __version__ = "1.2.0"
@ -45,7 +45,7 @@ def _desktopHelp() -> None:
print(indent + 'Commands:') print(indent + 'Commands:')
print('') print('')
print(indent + 'quit ' + print(indent + 'quit ' +
'Exit from the notification client') 'Exit from the desktop client')
print(indent + 'show dm|sent|inbox|replies ' + print(indent + 'show dm|sent|inbox|replies ' +
'Show a timeline') 'Show a timeline')
print(indent + 'mute ' + print(indent + 'mute ' +
@ -85,13 +85,13 @@ def _desktopHelp() -> None:
print('') print('')
def _clearScreen() -> None: def _desktopClearScreen() -> None:
"""Clears the screen """Clears the screen
""" """
os.system('cls' if os.name == 'nt' else 'clear') os.system('cls' if os.name == 'nt' else 'clear')
def _showDesktopBanner() -> None: def _desktopShowBanner() -> None:
"""Shows the banner at the top """Shows the banner at the top
""" """
bannerFilename = 'banner.txt' bannerFilename = 'banner.txt'
@ -106,9 +106,9 @@ def _showDesktopBanner() -> None:
print(banner + '\n') print(banner + '\n')
def _waitForKeypress(timeout: int, debug: bool) -> str: def _desktopWaitForCmd(timeout: int, debug: bool) -> str:
"""Waits for a keypress with a timeout """Waits for a command to be entered with a timeout
Returns the key pressed, or None on timeout Returns the command, or None on timeout
""" """
i, o, e = select.select([sys.stdin], [], [], timeout) i, o, e = select.select([sys.stdin], [], [], timeout)
@ -224,14 +224,14 @@ def _sayCommand(content: str, sayStr: str, screenreader: str,
systemLanguage, espeak) systemLanguage, espeak)
def _notificationReplyToPost(session, postId: str, def _desktopReplyToPost(session, postId: str,
baseDir: str, nickname: str, password: str, baseDir: str, nickname: str, password: str,
domain: str, port: int, httpPrefix: str, domain: str, port: int, httpPrefix: str,
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
debug: bool, subject: str, debug: bool, subject: str,
screenreader: str, systemLanguage: str, screenreader: str, systemLanguage: str,
espeak) -> None: espeak) -> None:
"""Use the notification client to send a reply to the most recent post """Use the desktop client to send a reply to the most recent post
""" """
if '://' not in postId: if '://' not in postId:
return return
@ -288,14 +288,14 @@ def _notificationReplyToPost(session, postId: str,
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
def _notificationNewPost(session, def _desktopNewPost(session,
baseDir: str, nickname: str, password: str, baseDir: str, nickname: str, password: str,
domain: str, port: int, httpPrefix: str, domain: str, port: int, httpPrefix: str,
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
debug: bool, debug: bool,
screenreader: str, systemLanguage: str, screenreader: str, systemLanguage: str,
espeak) -> None: espeak) -> None:
"""Use the notification client to create a new post """Use the desktop client to create a new post
""" """
sayStr = 'Create new post' sayStr = 'Create new post'
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
@ -448,7 +448,7 @@ def _readLocalBoxPost(boxName: str, index: int,
return speakerJson return speakerJson
def _showLocalBox(notifyJson: {}, boxName: str, def _desktopShowBox(notifyJson: {}, boxName: str,
screenreader: str, systemLanguage: str, espeak, screenreader: str, systemLanguage: str, espeak,
startPostIndex=0, noOfPosts=10, startPostIndex=0, noOfPosts=10,
newReplies=False, newReplies=False,
@ -472,8 +472,8 @@ def _showLocalBox(notifyJson: {}, boxName: str,
index.append(f) index.append(f)
# title # title
_clearScreen() _desktopClearScreen()
_showDesktopBanner() _desktopShowBanner()
notificationIcons = '' notificationIcons = ''
if notifyJson: if notifyJson:
@ -590,14 +590,14 @@ def _showLocalBox(notifyJson: {}, boxName: str,
return True return True
def _notificationNewDM(session, toHandle: str, def _desktopNewDM(session, toHandle: str,
baseDir: str, nickname: str, password: str, baseDir: str, nickname: str, password: str,
domain: str, port: int, httpPrefix: str, domain: str, port: int, httpPrefix: str,
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
debug: bool, debug: bool,
screenreader: str, systemLanguage: str, screenreader: str, systemLanguage: str,
espeak) -> None: espeak) -> None:
"""Use the notification client to create a new direct message """Use the desktop client to create a new direct message
which can include multiple destination handles which can include multiple destination handles
""" """
if ' ' in toHandle: if ' ' in toHandle:
@ -611,7 +611,7 @@ def _notificationNewDM(session, toHandle: str,
for handle in handlesList: for handle in handlesList:
handle = handle.strip() handle = handle.strip()
_notificationNewDMbase(session, handle, _desktopNewDMbase(session, handle,
baseDir, nickname, password, baseDir, nickname, password,
domain, port, httpPrefix, domain, port, httpPrefix,
cachedWebfingers, personCache, cachedWebfingers, personCache,
@ -620,8 +620,9 @@ def _notificationNewDM(session, toHandle: str,
espeak) espeak)
def _storeMessage(speakerJson: {}, boxName: str) -> None: def _desktopStoreMsg(speakerJson: {}, boxName: str) -> None:
"""Stores a message in your home directory for later reading """Stores a message in your home directory for later reading
which could be offline
""" """
if not speakerJson.get('published'): if not speakerJson.get('published'):
return return
@ -646,14 +647,14 @@ def _storeMessage(speakerJson: {}, boxName: str) -> None:
saveJson(speakerJson, msgFilename) saveJson(speakerJson, msgFilename)
def _notificationNewDMbase(session, toHandle: str, def _desktopNewDMbase(session, toHandle: str,
baseDir: str, nickname: str, password: str, baseDir: str, nickname: str, password: str,
domain: str, port: int, httpPrefix: str, domain: str, port: int, httpPrefix: str,
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
debug: bool, debug: bool,
screenreader: str, systemLanguage: str, screenreader: str, systemLanguage: str,
espeak) -> None: espeak) -> None:
"""Use the notification client to create a new direct message """Use the desktop client to create a new direct message
""" """
toPort = port toPort = port
if '://' in toHandle: if '://' in toHandle:
@ -756,14 +757,14 @@ def _notificationNewDMbase(session, toHandle: str,
"id": postId, "id": postId,
"direct": True "direct": True
} }
_storeMessage(speakerJson, 'sent') _desktopStoreMsg(speakerJson, 'sent')
sayStr = 'Direct message sent' sayStr = 'Direct message sent'
else: else:
sayStr = 'Direct message failed' sayStr = 'Direct message failed'
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
nickname: str, domain: str, port: int, nickname: str, domain: str, port: int,
password: str, screenreader: str, password: str, screenreader: str,
systemLanguage: str, systemLanguage: str,
@ -773,15 +774,15 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
storeInboxPosts: bool, storeInboxPosts: bool,
showNewPosts: bool, showNewPosts: bool,
debug: bool) -> None: debug: bool) -> None:
"""Runs the notifications and screen reader client, """Runs the desktop and screen reader client,
which announces new inbox items which announces new inbox items
""" """
indent = ' ' indent = ' '
if showNewPosts: if showNewPosts:
indent = '' indent = ''
_clearScreen() _desktopClearScreen()
_showDesktopBanner() _desktopShowBanner()
espeak = None espeak = None
if screenreader: if screenreader:
@ -814,12 +815,12 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
if not showNewPosts: if not showNewPosts:
print('') print('')
currInboxIndex = 0 currInboxIndex = 0
_showLocalBox(None, 'inbox', _desktopShowBox(None, 'inbox',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currInboxIndex, 10) currInboxIndex, 10)
currTimeline = 'inbox' currTimeline = 'inbox'
print('') print('')
keyPress = _waitForKeypress(2, debug) commandStr = _desktopWaitForCmd(2, debug)
originalScreenReader = screenreader originalScreenReader = screenreader
domainFull = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
@ -980,16 +981,16 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
speakerJson['decrypted'] = False speakerJson['decrypted'] = False
if speakerJson.get('replyToYou'): if speakerJson.get('replyToYou'):
newRepliesExist = True newRepliesExist = True
_storeMessage(speakerJson, 'replies') _desktopStoreMsg(speakerJson, 'replies')
if speakerJson.get('direct'): if speakerJson.get('direct'):
newDMsExist = True newDMsExist = True
_storeMessage(speakerJson, 'dm') _desktopStoreMsg(speakerJson, 'dm')
if storeInboxPosts: if storeInboxPosts:
_storeMessage(speakerJson, 'inbox') _desktopStoreMsg(speakerJson, 'inbox')
if not showNewPosts: if not showNewPosts:
_clearScreen() _desktopClearScreen()
_showLocalBox(notifyJson, currTimeline, _desktopShowBox(notifyJson, currTimeline,
None, systemLanguage, espeak, None, systemLanguage, espeak,
currInboxIndex, 10, currInboxIndex, 10,
newRepliesExist, newRepliesExist,
@ -1005,80 +1006,82 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
if noKeyPress: if noKeyPress:
time.sleep(10) time.sleep(10)
else: else:
keyPress = _waitForKeypress(30, debug) commandStr = _desktopWaitForCmd(30, debug)
if keyPress: if commandStr:
if keyPress.startswith('/'): if commandStr.startswith('/'):
keyPress = keyPress[1:] commandStr = commandStr[1:]
if keyPress == 'q' or keyPress == 'quit' or keyPress == 'exit': if commandStr == 'q' or \
commandStr == 'quit' or \
commandStr == 'exit':
sayStr = 'Quit' sayStr = 'Quit'
_sayCommand(sayStr, sayStr, screenreader, _sayCommand(sayStr, sayStr, screenreader,
systemLanguage, espeak) systemLanguage, espeak)
if screenreader: if screenreader:
keyPress = _waitForKeypress(2, debug) commandStr = _desktopWaitForCmd(2, debug)
break break
elif keyPress.startswith('show dm'): elif commandStr.startswith('show dm'):
currDMIndex = 0 currDMIndex = 0
_showLocalBox(notifyJson, 'dm', _desktopShowBox(notifyJson, 'dm',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currDMIndex, 10, currDMIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
currTimeline = 'dm' currTimeline = 'dm'
newDMsExist = False newDMsExist = False
elif keyPress.startswith('show rep'): elif commandStr.startswith('show rep'):
currRepliesIndex = 0 currRepliesIndex = 0
_showLocalBox(notifyJson, 'replies', _desktopShowBox(notifyJson, 'replies',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currRepliesIndex, 10, currRepliesIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
currTimeline = 'replies' currTimeline = 'replies'
# Turn off the replies indicator # Turn off the replies indicator
newRepliesExist = False newRepliesExist = False
elif keyPress.startswith('show sen'): elif commandStr.startswith('show sen'):
currSentIndex = 0 currSentIndex = 0
_showLocalBox(notifyJson, 'sent', _desktopShowBox(notifyJson, 'sent',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currSentIndex, 10, currSentIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
currTimeline = 'sent' currTimeline = 'sent'
elif (keyPress == 'show' or keyPress.startswith('show in') or elif (commandStr == 'show' or commandStr.startswith('show in') or
keyPress == 'clear'): commandStr == 'clear'):
currInboxIndex = 0 currInboxIndex = 0
_showLocalBox(notifyJson, 'inbox', _desktopShowBox(notifyJson, 'inbox',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currInboxIndex, 10, currInboxIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
currTimeline = 'inbox' currTimeline = 'inbox'
elif keyPress.startswith('next'): elif commandStr.startswith('next'):
if currTimeline == 'dm': if currTimeline == 'dm':
currDMIndex += 10 currDMIndex += 10
_showLocalBox(notifyJson, 'dm', _desktopShowBox(notifyJson, 'dm',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currDMIndex, 10, currDMIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
elif currTimeline == 'replies': elif currTimeline == 'replies':
currRepliesIndex += 10 currRepliesIndex += 10
_showLocalBox(notifyJson, 'replies', _desktopShowBox(notifyJson, 'replies',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currRepliesIndex, 10, currRepliesIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
elif currTimeline == 'sent': elif currTimeline == 'sent':
currSentIndex += 10 currSentIndex += 10
_showLocalBox(notifyJson, 'sent', _desktopShowBox(notifyJson, 'sent',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currSentIndex, 10, currSentIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
elif currTimeline == 'inbox': elif currTimeline == 'inbox':
currInboxIndex += 10 currInboxIndex += 10
_showLocalBox(notifyJson, 'inbox', _desktopShowBox(notifyJson, 'inbox',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currInboxIndex, 10, currInboxIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
elif keyPress.startswith('prev'): elif commandStr.startswith('prev'):
if currTimeline == 'dm': if currTimeline == 'dm':
currDMIndex -= 10 currDMIndex -= 10
if currDMIndex < 0: if currDMIndex < 0:
currDMIndex = 0 currDMIndex = 0
_showLocalBox(notifyJson, 'dm', _desktopShowBox(notifyJson, 'dm',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currDMIndex, 10, currDMIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
@ -1086,7 +1089,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
currRepliesIndex -= 10 currRepliesIndex -= 10
if currRepliesIndex < 0: if currRepliesIndex < 0:
currRepliesIndex = 0 currRepliesIndex = 0
_showLocalBox(notifyJson, 'replies', _desktopShowBox(notifyJson, 'replies',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currRepliesIndex, 10, currRepliesIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
@ -1094,7 +1097,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
currSentIndex -= 10 currSentIndex -= 10
if currSentIndex < 0: if currSentIndex < 0:
currSentIndex = 0 currSentIndex = 0
_showLocalBox(notifyJson, 'sent', _desktopShowBox(notifyJson, 'sent',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currSentIndex, 10, currSentIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
@ -1102,15 +1105,15 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
currInboxIndex -= 10 currInboxIndex -= 10
if currInboxIndex < 0: if currInboxIndex < 0:
currInboxIndex = 0 currInboxIndex = 0
_showLocalBox(notifyJson, 'inbox', _desktopShowBox(notifyJson, 'inbox',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currInboxIndex, 10, currInboxIndex, 10,
newRepliesExist, newDMsExist) newRepliesExist, newDMsExist)
elif keyPress.startswith('read ') or keyPress == 'read': elif commandStr.startswith('read ') or commandStr == 'read':
if keyPress == 'read': if commandStr == 'read':
postIndexStr = '1' postIndexStr = '1'
else: else:
postIndexStr = keyPress.split('read ')[1] postIndexStr = commandStr.split('read ')[1]
if postIndexStr.isdigit(): if postIndexStr.isdigit():
postIndex = int(postIndexStr) postIndex = int(postIndexStr)
speakerJson = \ speakerJson = \
@ -1118,14 +1121,14 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
systemLanguage, screenreader, systemLanguage, screenreader,
espeak) espeak)
print('') print('')
elif keyPress == 'reply' or keyPress == 'r': elif commandStr == 'reply' or commandStr == 'r':
if speakerJson.get('id'): if speakerJson.get('id'):
postId = speakerJson['id'] postId = speakerJson['id']
subject = None subject = None
if speakerJson.get('summary'): if speakerJson.get('summary'):
subject = speakerJson['summary'] subject = speakerJson['summary']
sessionReply = createSession(proxyType) sessionReply = createSession(proxyType)
_notificationReplyToPost(sessionReply, postId, _desktopReplyToPost(sessionReply, postId,
baseDir, nickname, password, baseDir, nickname, password,
domain, port, httpPrefix, domain, port, httpPrefix,
cachedWebfingers, personCache, cachedWebfingers, personCache,
@ -1133,32 +1136,32 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
screenreader, systemLanguage, screenreader, systemLanguage,
espeak) espeak)
print('') print('')
elif (keyPress == 'post' or keyPress == 'p' or elif (commandStr == 'post' or commandStr == 'p' or
keyPress == 'send' or commandStr == 'send' or
keyPress.startswith('dm ') or commandStr.startswith('dm ') or
keyPress.startswith('direct message ') or commandStr.startswith('direct message ') or
keyPress.startswith('post ') or commandStr.startswith('post ') or
keyPress.startswith('send ')): commandStr.startswith('send ')):
sessionPost = createSession(proxyType) sessionPost = createSession(proxyType)
if keyPress.startswith('dm ') or \ if commandStr.startswith('dm ') or \
keyPress.startswith('direct message ') or \ commandStr.startswith('direct message ') or \
keyPress.startswith('post ') or \ commandStr.startswith('post ') or \
keyPress.startswith('send '): commandStr.startswith('send '):
keyPress = keyPress.replace(' to ', ' ') commandStr = commandStr.replace(' to ', ' ')
keyPress = keyPress.replace(' dm ', ' ') commandStr = commandStr.replace(' dm ', ' ')
keyPress = keyPress.replace(' DM ', ' ') commandStr = commandStr.replace(' DM ', ' ')
# direct message # direct message
toHandle = None toHandle = None
if keyPress.startswith('post '): if commandStr.startswith('post '):
toHandle = keyPress.split('post ', 1)[1] toHandle = commandStr.split('post ', 1)[1]
elif keyPress.startswith('send '): elif commandStr.startswith('send '):
toHandle = keyPress.split('send ', 1)[1] toHandle = commandStr.split('send ', 1)[1]
elif keyPress.startswith('dm '): elif commandStr.startswith('dm '):
toHandle = keyPress.split('dm ', 1)[1] toHandle = commandStr.split('dm ', 1)[1]
elif keyPress.startswith('direct message '): elif commandStr.startswith('direct message '):
toHandle = keyPress.split('direct message ', 1)[1] toHandle = commandStr.split('direct message ', 1)[1]
if toHandle: if toHandle:
_notificationNewDM(sessionPost, toHandle, _desktopNewDM(sessionPost, toHandle,
baseDir, nickname, password, baseDir, nickname, password,
domain, port, httpPrefix, domain, port, httpPrefix,
cachedWebfingers, personCache, cachedWebfingers, personCache,
@ -1167,7 +1170,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
espeak) espeak)
else: else:
# public post # public post
_notificationNewPost(sessionPost, _desktopNewPost(sessionPost,
baseDir, nickname, password, baseDir, nickname, password,
domain, port, httpPrefix, domain, port, httpPrefix,
cachedWebfingers, personCache, cachedWebfingers, personCache,
@ -1175,7 +1178,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
screenreader, systemLanguage, screenreader, systemLanguage,
espeak) espeak)
print('') print('')
elif keyPress == 'like': elif commandStr == 'like':
if speakerJson.get('id'): if speakerJson.get('id'):
sayStr = 'Liking post by ' + speakerJson['name'] sayStr = 'Liking post by ' + speakerJson['name']
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
@ -1189,7 +1192,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
cachedWebfingers, personCache, cachedWebfingers, personCache,
False, __version__) False, __version__)
print('') print('')
elif keyPress == 'unlike' or keyPress == 'undo like': elif commandStr == 'unlike' or commandStr == 'undo like':
if speakerJson.get('id'): if speakerJson.get('id'):
sayStr = 'Undoing like of post by ' + speakerJson['name'] sayStr = 'Undoing like of post by ' + speakerJson['name']
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
@ -1203,9 +1206,9 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
cachedWebfingers, personCache, cachedWebfingers, personCache,
False, __version__) False, __version__)
print('') print('')
elif (keyPress == 'announce' or elif (commandStr == 'announce' or
keyPress == 'boost' or commandStr == 'boost' or
keyPress == 'retweet'): commandStr == 'retweet'):
if speakerJson.get('id'): if speakerJson.get('id'):
postId = speakerJson['id'] postId = speakerJson['id']
sayStr = 'Announcing post by ' + speakerJson['name'] sayStr = 'Announcing post by ' + speakerJson['name']
@ -1220,8 +1223,8 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
cachedWebfingers, personCache, cachedWebfingers, personCache,
True, __version__) True, __version__)
print('') print('')
elif keyPress.startswith('follow '): elif commandStr.startswith('follow '):
followHandle = keyPress.replace('follow ', '').strip() followHandle = commandStr.replace('follow ', '').strip()
if followHandle.startswith('@'): if followHandle.startswith('@'):
followHandle = followHandle[1:] followHandle = followHandle[1:]
if '@' in followHandle or '://' in followHandle: if '@' in followHandle or '://' in followHandle:
@ -1249,9 +1252,9 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
_sayCommand(sayStr, _sayCommand(sayStr,
screenreader, systemLanguage, espeak) screenreader, systemLanguage, espeak)
print('') print('')
elif (keyPress.startswith('unfollow ') or elif (commandStr.startswith('unfollow ') or
keyPress.startswith('stop following ')): commandStr.startswith('stop following ')):
followHandle = keyPress.replace('unfollow ', '').strip() followHandle = commandStr.replace('unfollow ', '').strip()
followHandle = followHandle.replace('stop following ', '') followHandle = followHandle.replace('stop following ', '')
if followHandle.startswith('@'): if followHandle.startswith('@'):
followHandle = followHandle[1:] followHandle = followHandle[1:]
@ -1280,9 +1283,9 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
_sayCommand(sayStr, sayStr, _sayCommand(sayStr, sayStr,
screenreader, systemLanguage, espeak) screenreader, systemLanguage, espeak)
print('') print('')
elif (keyPress == 'repeat' or keyPress == 'replay' or elif (commandStr == 'repeat' or commandStr == 'replay' or
keyPress == 'rp' or keyPress == 'again' or commandStr == 'rp' or commandStr == 'again' or
keyPress == 'say again'): commandStr == 'say again'):
if screenreader and nameStr and \ if screenreader and nameStr and \
gender and messageStr and content: gender and messageStr and content:
sayStr = 'Repeating ' + nameStr sayStr = 'Repeating ' + nameStr
@ -1294,25 +1297,25 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
systemLanguage, espeak, systemLanguage, espeak,
nameStr, gender) nameStr, gender)
print('') print('')
elif (keyPress == 'sounds on' or elif (commandStr == 'sounds on' or
keyPress == 'sound on' or commandStr == 'sound on' or
keyPress == 'sound'): commandStr == 'sound'):
sayStr = 'Notification sounds on' sayStr = 'Notification sounds on'
_sayCommand(sayStr, sayStr, screenreader, _sayCommand(sayStr, sayStr, screenreader,
systemLanguage, espeak) systemLanguage, espeak)
notificationSounds = True notificationSounds = True
elif (keyPress == 'sounds off' or elif (commandStr == 'sounds off' or
keyPress == 'sound off' or commandStr == 'sound off' or
keyPress == 'nosound'): commandStr == 'nosound'):
sayStr = 'Notification sounds off' sayStr = 'Notification sounds off'
_sayCommand(sayStr, sayStr, screenreader, _sayCommand(sayStr, sayStr, screenreader,
systemLanguage, espeak) systemLanguage, espeak)
notificationSounds = False notificationSounds = False
elif (keyPress == 'speak' or elif (commandStr == 'speak' or
keyPress == 'screen reader on' or commandStr == 'screen reader on' or
keyPress == 'speaker on' or commandStr == 'speaker on' or
keyPress == 'talker on' or commandStr == 'talker on' or
keyPress == 'reader on'): commandStr == 'reader on'):
if originalScreenReader: if originalScreenReader:
screenreader = originalScreenReader screenreader = originalScreenReader
sayStr = 'Screen reader on' sayStr = 'Screen reader on'
@ -1320,11 +1323,11 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
systemLanguage, espeak) systemLanguage, espeak)
else: else:
print('No --screenreader option was specified') print('No --screenreader option was specified')
elif (keyPress == 'mute' or elif (commandStr == 'mute' or
keyPress == 'screen reader off' or commandStr == 'screen reader off' or
keyPress == 'speaker off' or commandStr == 'speaker off' or
keyPress == 'talker off' or commandStr == 'talker off' or
keyPress == 'reader off'): commandStr == 'reader off'):
if originalScreenReader: if originalScreenReader:
screenreader = None screenreader = None
sayStr = 'Screen reader off' sayStr = 'Screen reader off'
@ -1332,10 +1335,10 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
systemLanguage, espeak) systemLanguage, espeak)
else: else:
print('No --screenreader option was specified') print('No --screenreader option was specified')
elif keyPress.startswith('open'): elif commandStr.startswith('open'):
currIndex = 0 currIndex = 0
if ' ' in keyPress: if ' ' in commandStr:
postIndex = keyPress.split(' ')[-1].strip() postIndex = commandStr.split(' ')[-1].strip()
if postIndex.isdigit(): if postIndex.isdigit():
currIndex = int(postIndex) currIndex = int(postIndex)
speakerJson = \ speakerJson = \
@ -1358,7 +1361,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
_sayCommand(sayStr, sayStr, originalScreenReader, _sayCommand(sayStr, sayStr, originalScreenReader,
systemLanguage, espeak) systemLanguage, espeak)
print('') print('')
elif keyPress.startswith('accept'): elif commandStr.startswith('accept'):
if notifyJson: if notifyJson:
if notifyJson.get('followRequestsList'): if notifyJson.get('followRequestsList'):
if len(notifyJson['followRequestsList']) > 0: if len(notifyJson['followRequestsList']) > 0:
@ -1371,7 +1374,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
_sayCommand(sayStr, sayStr, originalScreenReader, _sayCommand(sayStr, sayStr, originalScreenReader,
systemLanguage, espeak) systemLanguage, espeak)
print('') print('')
elif keyPress.startswith('reject'): elif commandStr.startswith('reject'):
if notifyJson: if notifyJson:
if notifyJson.get('followRequestsList'): if notifyJson.get('followRequestsList'):
if len(notifyJson['followRequestsList']) > 0: if len(notifyJson['followRequestsList']) > 0:
@ -1384,5 +1387,5 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
_sayCommand(sayStr, sayStr, originalScreenReader, _sayCommand(sayStr, sayStr, originalScreenReader,
systemLanguage, espeak) systemLanguage, espeak)
print('') print('')
elif keyPress.startswith('h'): elif commandStr.startswith('h'):
_desktopHelp() _desktopHelp()

View File

@ -78,7 +78,7 @@ from theme import setTheme
from announce import sendAnnounceViaServer from announce import sendAnnounceViaServer
from socnet import instancesGraph from socnet import instancesGraph
from migrate import migrateAccounts from migrate import migrateAccounts
from notifications_client import runNotificationsClient from desktop_client import runDesktopClient
def str2bool(v) -> bool: def str2bool(v) -> bool:
@ -304,7 +304,7 @@ parser.add_argument("--notifyShowNewPosts",
dest='notifyShowNewPosts', dest='notifyShowNewPosts',
type=str2bool, nargs='?', type=str2bool, nargs='?',
const=True, default=False, const=True, default=False,
help="Notification client shows/speaks new posts " + help="Desktop client shows/speaks new posts " +
"as they arrive") "as they arrive")
parser.add_argument("--noapproval", type=str2bool, nargs='?', parser.add_argument("--noapproval", type=str2bool, nargs='?',
const=True, default=False, const=True, default=False,
@ -1868,7 +1868,7 @@ if args.desktop:
# only store inbox posts if we are not running as a daemon # only store inbox posts if we are not running as a daemon
storeInboxPosts = not args.noKeyPress storeInboxPosts = not args.noKeyPress
runNotificationsClient(baseDir, proxyType, httpPrefix, runDesktopClient(baseDir, proxyType, httpPrefix,
nickname, domain, port, args.password, nickname, domain, port, args.password,
args.screenreader, args.language, args.screenreader, args.language,
args.notificationSounds, args.notificationSounds,