forked from club/makeuser
Final adjustments to makeuser
This commit is contained in:
parent
229149a720
commit
4f4419bad8
1
Makefile
1
Makefile
|
@ -9,6 +9,7 @@ install:
|
||||||
@install -m 644 welcome-email.tmpl $(BINDIR)
|
@install -m 644 welcome-email.tmpl $(BINDIR)
|
||||||
@install -m 700 znccreate.py $(BINDIR)
|
@install -m 700 znccreate.py $(BINDIR)
|
||||||
@install -m 600 znc-config-ex.json $(ZNCCONF)
|
@install -m 600 znc-config-ex.json $(ZNCCONF)
|
||||||
|
@install -m 755 toot.py $(BINDIR)/toot
|
||||||
@echo Remember to edit znc-config with your ZNC details and rename $(ZNCCONF)/znc-config-ex.json to $(ZNCCONF)/znc-config.json
|
@echo Remember to edit znc-config with your ZNC details and rename $(ZNCCONF)/znc-config-ex.json to $(ZNCCONF)/znc-config.json
|
||||||
@echo ENJOY
|
@echo ENJOY
|
||||||
|
|
||||||
|
|
43
toot.py
Executable file
43
toot.py
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
import click
|
||||||
|
import emoji
|
||||||
|
import getpass
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from mastodon import Mastodon
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.argument('status', required=False)
|
||||||
|
@click.option('--creds', default=os.path.join(os.path.dirname(__file__), "toot.json"))
|
||||||
|
def toot(status, creds):
|
||||||
|
# get config
|
||||||
|
with open(creds) as f:
|
||||||
|
config = json.load(f)
|
||||||
|
|
||||||
|
# set up connection to mastodon
|
||||||
|
mastodon = Mastodon(
|
||||||
|
client_id=config['client_id'],
|
||||||
|
client_secret=config['client_secret'],
|
||||||
|
access_token=config['access_token'],
|
||||||
|
api_base_url=config['base_url'],
|
||||||
|
)
|
||||||
|
|
||||||
|
# get status from argument or from stdin
|
||||||
|
if not status:
|
||||||
|
status = "".join(sys.stdin).strip()
|
||||||
|
|
||||||
|
# replace shortcodes with emoji :thumbsup:
|
||||||
|
status = emoji.emojize(status, use_aliases=True)
|
||||||
|
|
||||||
|
# check status length and post status
|
||||||
|
if len(status) > 5000:
|
||||||
|
print("Status is too long, try again")
|
||||||
|
elif len(status) == 0:
|
||||||
|
print("Did you type a status?")
|
||||||
|
else:
|
||||||
|
print(mastodon.toot(f"{status}\n~{getpass.getuser()}")["uri"])
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
toot()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user