epicyon/epicyon.py

99 lines
3.2 KiB
Python
Raw Normal View History

2019-06-28 18:55:29 +00:00
__filename__ = "epicyon.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "0.0.1"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
from person import createPerson
from person import setPreferredUsername
2019-06-28 20:00:25 +00:00
from person import setBio
2019-06-28 18:55:29 +00:00
from webfinger import webfingerHandle
from posts import getUserPosts
2019-06-29 10:08:59 +00:00
from posts import createPublicPost
2019-06-29 11:47:33 +00:00
from posts import deleteAllPosts
2019-06-29 13:17:02 +00:00
from posts import createOutbox
2019-06-29 13:44:21 +00:00
from posts import archivePosts
2019-06-28 18:55:29 +00:00
from session import createSession
2019-06-29 16:47:37 +00:00
from session import getJson
2019-06-28 18:55:29 +00:00
import json
import sys
import requests
from pprint import pprint
from httpsig import testHttpsig
from daemon import runDaemon
2019-06-28 19:52:35 +00:00
import socket
2019-06-29 18:23:13 +00:00
from follow import clearFollows
2019-06-29 20:21:37 +00:00
from follow import clearFollowers
2019-06-29 18:23:13 +00:00
from follow import followPerson
from follow import followerOfPerson
from follow import unfollowPerson
from follow import unfollowerOfPerson
2019-06-28 18:55:29 +00:00
2019-06-29 20:34:41 +00:00
federationList=['mastodon.social','wild.com','trees.com']
2019-06-28 19:52:35 +00:00
username='testuser'
#domain=socket.gethostname()
domain='mydomain.com'
port=6227
https=True
2019-06-28 18:55:29 +00:00
useTor=False
session = createSession(useTor)
2019-06-29 18:23:13 +00:00
clearFollows(username,domain)
2019-06-29 20:34:41 +00:00
followPerson(username,domain,'badger','wild.com',federationList)
followPerson(username,domain,'squirrel','secret.com',federationList)
followPerson(username,domain,'rodent','drainpipe.com',federationList)
followPerson(username,domain,'batman','mesh.com',federationList)
followPerson(username,domain,'giraffe','trees.com',federationList)
2019-06-29 18:23:13 +00:00
2019-06-29 20:21:37 +00:00
clearFollowers(username,domain)
2019-06-29 20:34:41 +00:00
followerOfPerson(username,domain,'badger','wild.com',federationList)
followerOfPerson(username,domain,'squirrel','secret.com',federationList)
followerOfPerson(username,domain,'rodent','drainpipe.com',federationList)
followerOfPerson(username,domain,'batman','mesh.com',federationList)
followerOfPerson(username,domain,'giraffe','trees.com',federationList)
2019-06-29 20:21:37 +00:00
#unfollowPerson(username,domain,'squirrel','secret.com')
#sys.exit()
#asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
2019-06-29 16:47:37 +00:00
#userFollowing = getJson(session,"https://mastodon.social/users/Gargron/followers?page=true",asHeader,None)
2019-06-29 20:21:37 +00:00
#userFollowing = getJson(session,"https://mastodon.social/users/Gargron/following",asHeader,None)
#userFollowing = getJson(session,"https://mastodon.social/users/Gargron/following?page=1",asHeader,None)
#pprint(userFollowing)
#sys.exit()
2019-06-29 15:18:35 +00:00
2019-06-28 19:52:35 +00:00
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(username,domain,https,True)
2019-06-29 13:17:02 +00:00
#deleteAllPosts(username,domain)
2019-06-28 19:52:35 +00:00
setPreferredUsername(username,domain,'badger')
2019-06-28 20:00:25 +00:00
setBio(username,domain,'Some personal info')
2019-06-29 13:17:02 +00:00
#createPublicPost(username, domain, https, "G'day world!", False, True, None, None, 'Not suitable for Vogons')
2019-06-29 14:35:26 +00:00
#archivePosts(username,domain,4)
2019-06-29 17:12:26 +00:00
#outboxJson=createOutbox(username,domain,https,2,True,None)
#pprint(outboxJson)
2019-06-29 10:08:59 +00:00
2019-06-29 17:12:26 +00:00
runDaemon(domain,port,federationList,useTor)
2019-06-28 18:55:29 +00:00
#testHttpsig()
2019-06-29 17:12:26 +00:00
#sys.exit()
2019-06-28 18:55:29 +00:00
#pprint(person)
#print('\n')
#pprint(wfEndpoint)
handle="https://mastodon.social/@Gargron"
wfRequest = webfingerHandle(session,handle,True)
if not wfRequest:
sys.exit()
#wfResult = json.dumps(wfRequest, indent=4, sort_keys=True)
#print(str(wfResult))
#sys.exit()
maxMentions=10
maxEmoji=10
maxAttachments=5
2019-06-28 20:43:37 +00:00
userPosts = getUserPosts(session,wfRequest,2,maxMentions,maxEmoji,maxAttachments,federationList)
2019-06-29 10:08:59 +00:00
#print(str(userPosts))