Rearranging things... Made multipublishing work.
This commit is contained in:
parent
45c9a35e3b
commit
caf4f35291
6 changed files with 77 additions and 1 deletions
BIN
lib/twitter/__pycache__/tweet_converter.cpython-37.pyc
Normal file
BIN
lib/twitter/__pycache__/tweet_converter.cpython-37.pyc
Normal file
Binary file not shown.
48
multipub_runtime.py
Normal file
48
multipub_runtime.py
Normal file
|
@ -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()
|
18
pyenv.yml
18
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
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue