2019-02-21 20:18:28 -06:00
|
|
|
#!/usr/bin/python
|
|
|
|
# I'd put a more professional header here but since I'm the only one working on it idc.
|
2019-02-21 20:19:31 -06:00
|
|
|
# Hey don't forget to install PyInstaller and probably py2exe for distrobution.
|
2019-02-21 20:18:28 -06:00
|
|
|
|
|
|
|
try:
|
|
|
|
from lib.twitter.tweet_converter import convert_tweets
|
|
|
|
except ImportError:
|
|
|
|
print('Error importing libraries.')
|
|
|
|
|
|
|
|
import tweepy
|
|
|
|
from mastodon import Mastodon as masto
|
|
|
|
|
|
|
|
# The main runtime for this program.
|
|
|
|
def main():
|
|
|
|
# TODO: Encrypt this file for extra security?
|
|
|
|
# TODO: Probably move all of this to its own function.
|
|
|
|
with open('keys.txt', 'r') as f:
|
|
|
|
#Twitter API credential
|
|
|
|
consumer_key = f.readline().rstrip()
|
|
|
|
consumer_secret = f.readline().rstrip()
|
|
|
|
access_key = f.readline().rstrip()
|
|
|
|
access_secret = f.readline().rstrip()
|
|
|
|
|
|
|
|
# Authorize Twitter, initialize tweepy
|
|
|
|
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
|
|
|
|
auth.set_access_token(access_key, access_secret)
|
2019-03-02 18:14:41 -06:00
|
|
|
twitter = tweepy.API(auth)
|
2019-02-21 20:18:28 -06:00
|
|
|
|
|
|
|
# Authorize Mastodon, set api base
|
|
|
|
# TODO: Modularize this
|
|
|
|
mastodon = masto(
|
2019-03-02 18:14:13 -06:00
|
|
|
access_token = '~/.secrets/mastodon_api_access_token.secret',
|
2019-02-21 20:18:28 -06:00
|
|
|
api_base_url = 'https://masto.werefoxsoftware.com'
|
|
|
|
)
|
|
|
|
|
|
|
|
post = 'Proof of concept post.'
|
|
|
|
|
|
|
|
try:
|
|
|
|
'''
|
|
|
|
# TODO: Change this to be modular and actually do something useful.
|
2019-03-02 18:14:41 -06:00
|
|
|
twitter.update_status(post)
|
2019-02-21 20:18:28 -06:00
|
|
|
mastodon.status_post(post)
|
|
|
|
'''
|
|
|
|
print(post)
|
|
|
|
except Exception as e:
|
|
|
|
print(str(e))
|
|
|
|
print('There was an issue.')
|
|
|
|
|
|
|
|
main()
|