Include petnames in the DM dropdown

main
Bob Mottram 2020-06-29 16:23:52 +01:00
parent 5097693e3e
commit 41667cface
2 changed files with 21 additions and 1 deletions

View File

@ -15,6 +15,8 @@ def setPetName(baseDir: str, nickname: str, domain: str,
""" """
if '@' not in handle: if '@' not in handle:
return False return False
if ' ' in petname:
petname = petname.replace(' ', '_')
if handle.startswith('@'): if handle.startswith('@'):
handle = handle[1:] handle = handle[1:]
if petname.startswith('@'): if petname.startswith('@'):

View File

@ -326,7 +326,25 @@ def htmlFollowingDataList(baseDir: str, nickname: str,
if os.path.isfile(followingFilename): if os.path.isfile(followingFilename):
with open(followingFilename, 'r') as followingFile: with open(followingFilename, 'r') as followingFile:
msg = followingFile.read() msg = followingFile.read()
# add your own handle, so that you can send DMs
# to yourself as reminders
msg += nickname + '@' + domainFull + '\n' msg += nickname + '@' + domainFull + '\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 = msg.split('\n')
followingList.sort() followingList.sort()
if followingList: if followingList: