xenua
2 years ago
commit
af8630d143
3 changed files with 109 additions and 0 deletions
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
#!/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" |
||||
] |
||||
} |
||||
|
||||
|
||||
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: |
||||
sleep(delay*60) |
||||
m.status_reblog(t["id"]) |
||||
sleep(delay*60) |
||||
i = 0 |
||||
while True: |
||||
now = time() |
||||
|
||||
m.status_unreblog(t["id"]) |
||||
sleep(10) |
||||
m.status_reblog(t["id"]) |
||||
|
||||
typer.echo(f"boosting! running for {delay*i} minutes...") |
||||
|
||||
sleep(delay*60 - (time() - now)) |
||||
i += 1 |
||||
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) |
Loading…
Reference in new issue