|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
from random import choice
|
|
|
|
from time import sleep, time
|
|
|
|
|
|
|
|
from mastodon import Mastodon
|
|
|
|
import typer
|
|
|
|
|
|
|
|
|
|
|
|
app = typer.Typer()
|
|
|
|
|
|
|
|
|
|
|
|
FJ = {
|
|
|
|
"clientcred": "fedijitis_clientcred.secret",
|
|
|
|
"usercred": "fedijitis_usercred.secret",
|
|
|
|
"post_text": "jitis is live! join at {link} \n\n"
|
|
|
|
"if this post was boosted in the last {delay} minutes it's still going!",
|
|
|
|
"closing_texts": [
|
|
|
|
"the jitis has ceased",
|
|
|
|
"the jitis has ended",
|
|
|
|
"jitis boss: defeated",
|
|
|
|
"in terms of people in jitis, we no longer have people in jitis",
|
|
|
|
"jitis ended\n\nbottom text",
|
|
|
|
"end of an era voice end of the jitis",
|
|
|
|
"jitis defederated",
|
|
|
|
"great jitis felled",
|
|
|
|
"jitis was the impostor",
|
|
|
|
"you know what, un-meets your jitis",
|
|
|
|
"jitsi met"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def auth():
|
|
|
|
instance_url: str = typer.prompt("Instance url").rstrip("/")
|
|
|
|
Mastodon.create_app(
|
|
|
|
"fedijitis",
|
|
|
|
api_base_url=instance_url,
|
|
|
|
to_file=FJ["clientcred"]
|
|
|
|
)
|
|
|
|
|
|
|
|
username: str = typer.prompt("Username/Email")
|
|
|
|
password: str = typer.prompt("Password", hide_input=True)
|
|
|
|
mastodon = Mastodon(
|
|
|
|
client_id=FJ["clientcred"],
|
|
|
|
api_base_url=instance_url
|
|
|
|
)
|
|
|
|
|
|
|
|
mastodon.log_in(
|
|
|
|
username,
|
|
|
|
password,
|
|
|
|
to_file=FJ["usercred"]
|
|
|
|
)
|
|
|
|
|
|
|
|
u = mastodon.me() # uwu
|
|
|
|
|
|
|
|
typer.secho(f"Success! logged in as @{u['acct']}", fg="green")
|
|
|
|
|
|
|
|
|
|
|
|
def get_mastodon():
|
|
|
|
if os.path.isfile(FJ["usercred"]):
|
|
|
|
return Mastodon(access_token=FJ["usercred"])
|
|
|
|
auth()
|
|
|
|
return get_mastodon()
|
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
|
|
|
def main():
|
|
|
|
m = get_mastodon()
|
|
|
|
|
|
|
|
link = typer.prompt("jitis link")
|
|
|
|
delay = typer.prompt("boost how often (minutes)", type=int)
|
|
|
|
followers_only = typer.confirm("followers_only?", default=True)
|
|
|
|
|
|
|
|
t = m.status_post(
|
|
|
|
FJ["post_text"].format(link=link, delay=delay),
|
|
|
|
visibility="private" if followers_only else "unlisted"
|
|
|
|
)
|
|
|
|
|
|
|
|
typer.echo("Created the post! ctrl+c to end the jitis and exit.")
|
|
|
|
|
|
|
|
try:
|
|
|
|
i = 1
|
|
|
|
sleep(delay*60)
|
|
|
|
m.status_reblog(t["id"])
|
|
|
|
typer.echo(f"boosting! running for {delay * i} minutes...")
|
|
|
|
sleep(delay*60)
|
|
|
|
while True:
|
|
|
|
now = time()
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
m.status_unreblog(t["id"])
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
sleep(5)
|
|
|
|
m.status_reblog(t["id"])
|
|
|
|
break
|
|
|
|
except:
|
|
|
|
...
|
|
|
|
|
|
|
|
typer.echo(f"boosting! running for {delay*i} minutes...")
|
|
|
|
|
|
|
|
sleep(delay*60 - (time() - now))
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
m.status_post(choice(FJ["closing_texts"]), in_reply_to_id=t["id"])
|
|
|
|
typer.echo("\nposted closing toot, see you next time!")
|
|
|
|
raise typer.Exit()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
typer.run(main)
|