diff --git a/mastodon_publisher.py b/lib/masto/mastodon_publisher.py similarity index 100% rename from mastodon_publisher.py rename to lib/masto/mastodon_publisher.py diff --git a/lib/twitter/__pycache__/tweet_converter.cpython-37.pyc b/lib/twitter/__pycache__/tweet_converter.cpython-37.pyc new file mode 100644 index 0000000..733061c Binary files /dev/null and b/lib/twitter/__pycache__/tweet_converter.cpython-37.pyc differ diff --git a/tweet_converter.py b/lib/twitter/tweet_converter.py similarity index 100% rename from tweet_converter.py rename to lib/twitter/tweet_converter.py diff --git a/multipub_runtime.py b/multipub_runtime.py new file mode 100644 index 0000000..190b1ae --- /dev/null +++ b/multipub_runtime.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# I'd put a more professional header here but since I'm the only one working on it idc. + +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) + api = tweepy.API(auth) + + # Authorize Mastodon, set api base + # TODO: Modularize this + mastodon = masto( + access_token = '/Users/shadow8t4/.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. + api.update_status(post) + mastodon.status_post(post) + ''' + print(post) + except Exception as e: + print(str(e)) + print('There was an issue.') + +main() \ No newline at end of file diff --git a/pyenv.yml b/pyenv.yml index 5fd3960..d012e50 100644 --- a/pyenv.yml +++ b/pyenv.yml @@ -26,4 +26,22 @@ dependencies: - wrapt=1.11.0=py37h1de35cc_0 - xz=5.2.4=h1de35cc_4 - zlib=1.2.11=h1de35cc_3 + - pip: + - asn1crypto==0.24.0 + - cffi==1.12.1 + - chardet==3.0.4 + - cryptography==2.5 + - decorator==4.3.2 + - http-ece==1.1.0 + - idna==2.8 + - mastodon-py==1.3.1 + - oauthlib==3.0.1 + - pycparser==2.19 + - pysocks==1.6.8 + - python-dateutil==2.8.0 + - pytz==2018.9 + - requests==2.21.0 + - requests-oauthlib==1.2.0 + - tweepy==3.7.0 + - urllib3==1.24.1 prefix: /Users/shadow8t4/git/MultiPub/.pyenv diff --git a/tweet_echoer.py b/tweet_echoer.py index 7097e5c..caef23e 100644 --- a/tweet_echoer.py +++ b/tweet_echoer.py @@ -1,8 +1,18 @@ #!/usr/bin/env python # encoding: utf-8 +# Hey lazy, move this to its own repo, it doesn't need to be here +# Also give it its own API key + # Tweet echoing works. I just need this to be refactored into something more useful... -from tweet_converter import convert_tweets +try: + from lib.twitter.tweet_converter import convert_tweets +except ImportError: + try: + from tweepy import convert_tweets + except ImportError: + print('Errori mporting tweet_converter') + from mastodon import Mastodon from time import sleep import tweepy