From 41667cfaceabf432dde75b7a3d163d8e6cfc93d5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 29 Jun 2020 16:23:52 +0100 Subject: [PATCH] Include petnames in the DM dropdown --- petnames.py | 2 ++ webinterface.py | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/petnames.py b/petnames.py index 4fb90f3d..0ae03f87 100644 --- a/petnames.py +++ b/petnames.py @@ -15,6 +15,8 @@ def setPetName(baseDir: str, nickname: str, domain: str, """ if '@' not in handle: return False + if ' ' in petname: + petname = petname.replace(' ', '_') if handle.startswith('@'): handle = handle[1:] if petname.startswith('@'): diff --git a/webinterface.py b/webinterface.py index e9174feb..8c545ede 100644 --- a/webinterface.py +++ b/webinterface.py @@ -326,8 +326,26 @@ def htmlFollowingDataList(baseDir: str, nickname: str, if os.path.isfile(followingFilename): with open(followingFilename, 'r') as followingFile: msg = followingFile.read() + # add your own handle, so that you can send DMs + # to yourself as reminders msg += nickname + '@' + domainFull + '\n' - followingList = msg.split('\n') + # include petnames + petnamesFilename = \ + baseDir + '/accounts/' + \ + nickname + '@' + domain + '/petnames.txt' + if os.path.isfile(petnamesFilename): + followingList = [] + with open(petnamesFilename, 'r') as petnamesFile: + petStr = petnamesFile.read() + # extract each petname and append it + petnamesList = petStr.split('\n') + for pet in petnamesList: + followingList.append(pet.split(' ')[0]) + # add the following.txt entries + followingList += msg.split('\n') + else: + # no petnames list exists - just use following.txt + followingList = msg.split('\n') followingList.sort() if followingList: for followingAddress in followingList: