This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
multipub/multipub_runtime.py

49 lines
1.5 KiB
Python
Raw Permalink Normal View History

#!/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.
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)
# Authorize Mastodon, set api base
# TODO: Modularize this
mastodon = masto(
access_token = '~/.secrets/mastodon_api_access_token.secret',
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)
mastodon.status_post(post)
'''
print(post)
except Exception as e:
print(str(e))
print('There was an issue.')
main()