Update message option

master
Bob Mottram 2019-07-16 17:43:28 +01:00
parent 8ab84efbbf
commit 53d68cd10d
1 changed files with 51 additions and 40 deletions

View File

@ -24,7 +24,7 @@ from posts import createPublicPost
from posts import deleteAllPosts from posts import deleteAllPosts
from posts import createOutbox from posts import createOutbox
from posts import archivePosts from posts import archivePosts
from posts import sendPost from posts import sendPostViaServer
from posts import getPublicPostsOfPerson from posts import getPublicPostsOfPerson
from posts import getUserUrl from posts import getUserUrl
from posts import archivePosts from posts import archivePosts
@ -214,8 +214,8 @@ if args.tests:
if args.testsnetwork: if args.testsnetwork:
print('Network Tests') print('Network Tests')
#testPostMessageBetweenServers() testPostMessageBetweenServers()
#testFollowBetweenServers() testFollowBetweenServers()
testClientToServer() testClientToServer()
sys.exit() sys.exit()
@ -285,12 +285,22 @@ useTor=args.tor
if domain.endswith('.onion'): if domain.endswith('.onion'):
useTor=True useTor=True
if args.message and nickname: if args.message:
if not nickname:
print('Specify a nickname with the --nickname option')
sys.exit()
if not args.password:
print('Specify a password with the --password option')
sys.exit()
if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain): if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
print(nickname+' is not an account on the system. use --addaccount if necessary.') print(nickname+' is not an account on the system. use --addaccount if necessary.')
sys.exit() sys.exit()
session = createSession(domain,port,useTor) session = createSession(domain,port,useTor)
if args.sendto: if not args.sendto:
print('Specify an account to sent to: --sendto [nickname@domain]')
sys.exit()
if '@' not in args.sendto: if '@' not in args.sendto:
print('syntax: --sendto [nickname@domain]') print('syntax: --sendto [nickname@domain]')
sys.exit() sys.exit()
@ -314,15 +324,16 @@ if args.message and nickname:
subject=args.subject subject=args.subject
attach=args.attach attach=args.attach
replyTo=args.replyTo replyTo=args.replyTo
followersOnly=False
print('Sending post to '+args.sendto) print('Sending post to '+args.sendto)
sendResult = \
sendPost(session,baseDir,nickname,domain,port, \ sendPostViaServer(session,nickname,args.password, \
toNickname,toDomain,toPort,ccUrl,httpPrefix, \ domain,port, \
sendMessage,followersOnly,True,clientToServer, \ toNickname,toDomain,toPort,ccUrl, \
attach,attachedImageDescription, \ httpPrefix,sendMessage,followersOnly, \
useBlurhash,federationList,sendThreads, \ attach,attachedImageDescription,useBlurhash, \
postLog,cachedWebfingers,personCache, \ cachedWebfingers,personCache, \
replyTo,replyTo,subject) args.debug,replyTo,replyTo,subject)
for i in range(10): for i in range(10):
# TODO detect send success/fail # TODO detect send success/fail
time.sleep(1) time.sleep(1)