Added some example bot scripts which I tested

pull/1/head
Mike Lynch 2025-01-08 10:50:57 +11:00
parent 48f94ad8ad
commit 70f14c5ab8
4 changed files with 46 additions and 2 deletions

View File

@ -4,7 +4,7 @@ version = "0.1.0"
description = "A Python library for GoToSocial clients"
readme = "README.md"
authors = [
{ name = "Mike Lynch", email = "m.lynch@sydney.edu.au" }
{ name = "Mike Lynch", email = "mike@llull.club" }
]
requires-python = ">=3.9"
dependencies = [

View File

@ -0,0 +1,21 @@
# example bot script
from gotosocial.client import GoToSocialBot
import json
CONFIG = "config.json"
# the config file should look like
#
# {
# "base_url": "https://your.gts.instance.here",
# "access_token": "YOURACCESSTOKENGOESHERE"
# }
#
if __name__ == "__main__":
with open(CONFIG, "r") as cfh:
cf = json.load(cfh)
bot = GoToSocialBot()
bot.auth(cf)
bot.post("A test post", {"spoiler_text": "test post"})

View File

@ -0,0 +1,21 @@
# example bot script
from gotosocial.client import GoToSocialBot
import json
CONFIG = "config.json"
# the config file should look like
#
# {
# "base_url": "https://your.gts.instance.here",
# "access_token": "YOURACCESSTOKENGOESHERE"
# }
#
if __name__ == "__main__":
with open(CONFIG, "r") as cfh:
cf = json.load(cfh)
bot = GoToSocialBot()
bot.auth(cf)
bot.post_image("./my_image.png", "A test post", {"spoiler_text": "test post"})

View File

@ -42,7 +42,9 @@ class Application:
print("Visit this URL in a private browser window to authenticate:")
print(auth_url)
print("\nThen run this script again with the OOB token, like:")
print("> uv run register -u {self.base_ur} -n {self.name} -t OOB_TOKEB")
print(
"> uv run register -u {self.base_ur} -n {self.name} -t REPLACEMEWITHTOKEN"
)
return True
except Exception as e:
print("Something went wrong:")