Last active
October 7, 2022 20:04
-
-
Save daisyUniverse/2fdf772fad23e5e63aaf152e62c05e52 to your computer and use it in GitHub Desktop.
A command line tool to show your twitter / mastodon followers who is fronting from bash in your bio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Licensed under the WTFNOPL | |
# Written by the Multiverse System, mostly Theta. | |
# Requires Tweepy & Mastodon.py modules | |
from mastodon import Mastodon | |
import tweepy | |
import os | |
import argparse | |
parser = argparse.ArgumentParser("Switch") | |
parser.add_argument("--front", help="Name of Alter.", type=str, default="") | |
parser.add_argument("--pre", help="Text to put before the Alters name.", type=str, default="") | |
parser.add_argument("--post", help="Text to put after the Alters name.", type=str, default="") | |
parser.add_argument("--service", help="Change Twitter / Masto (default is both)", type=str, default="") | |
args = parser.parse_args() | |
# Twitter API Creds. Update it to use environment variables if you care enough | |
twit = { | |
"access_token" : "TWITTER ACCESS TOKEN HERE", | |
"access_token_secret" : "TWITTER ACCESS TOKEN SECRET HERE", | |
"consumer_key" : "TWITTER CONSUMER KEY HERE", | |
"consumer_secret" : "TWITTER CONSUMER SECRET HERE", | |
"bio" : "Copy your current bio and paste it here. Use \n to represent newlines" | |
} | |
# Ditto for mastodon | |
masto = { | |
"access_token" : "MASTODON ACCESS TOKEN HERE", | |
"bio" : "Copy your current bio and paste it here. Use \n to represent newlines", | |
"url" : "THE URL OF YOUR MASTODON INSTANCE HERE" | |
} | |
auth = tweepy.OAuth1UserHandler( | |
twit['consumer_key'], | |
twit['consumer_secret'], | |
twit['access_token'], | |
twit['access_token_secret'] | |
) | |
mastodon = Mastodon( | |
access_token = masto['access_token'], | |
api_base_url = masto['url'] | |
) | |
twitter = tweepy.API(auth) | |
def updateTwitter(): | |
try: | |
print("Adding "+args.front+" to twitter bio") | |
twitter.update_profile(description=(args.pre + twit['bio'] + args.front.replace('"','') + args.post)) | |
except Exception as e: | |
print(str(e)) | |
def updateMastodon(): | |
try: | |
print("Adding "+args.front+" to mastodon bio") | |
mastodon.account_update_credentials(note=(args.pre + masto['bio'] + args.front.replace('"','') + args.post)) | |
except Exception as e: | |
print(str(e)) | |
if "twit" in args.service.lower(): | |
updateTwitter() | |
elif "masto" in args.service.lower(): | |
updateMastodon() | |
else: | |
updateTwitter() | |
updateMastodon() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment