Skip to content

Commit 7b16d41

Browse files
authored
feat: Support alt text (#114)
Modify pics.py example to allow alt text to be specified
1 parent d5115cf commit 7b16d41

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

examples/pic.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@
5353
type=str,
5454
help="Which password to authenticate with",
5555
)
56+
arg_parser.add_argument(
57+
"-a",
58+
"--alt_text",
59+
action="store",
60+
required=False,
61+
type=str,
62+
help="the image alt text to use",
63+
)
64+
65+
5666
args = arg_parser.parse_args()
5767

5868

@@ -97,6 +107,7 @@
97107
args.title,
98108
url=image[0]["image_url"],
99109
body=args.body,
110+
alt_text=args.alt_text,
100111
)
101112
if post:
102113
print(f"Successfully posted ({post['post_view']['post']['ap_id']})")

pythorhead/post.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def create(
8484
name: str,
8585
url: Optional[str] = None,
8686
body: Optional[str] = None,
87+
alt_text: Optional[str] = None,
8788
nsfw: Optional[bool] = None,
8889
honeypot: Optional[str] = None,
8990
language_id: Union[int, LanguageType, None] = None,
@@ -96,6 +97,7 @@ def create(
9697
name (str)
9798
url (str, optional): Defaults to None.
9899
body (str, optional): Defaults to None.
100+
alt_text (ste, optional): Defaults to None. Lemmy 0.19.4+
99101
nsfw (bool, optional): Defaults to None.
100102
honeypot (str, optional): Defaults to None.
101103
language_id (Union[int, LanguageType], optional): Defaults to None.
@@ -112,6 +114,8 @@ def create(
112114
new_post["url"] = url
113115
if body is not None:
114116
new_post["body"] = body
117+
if alt_text is not None:
118+
new_post["alt_text"] = alt_text
115119
if nsfw is not None:
116120
new_post["nsfw"] = nsfw
117121
if honeypot is not None:
@@ -169,6 +173,7 @@ def edit(
169173
name: Optional[str] = None,
170174
url: Optional[str] = None,
171175
body: Optional[str] = None,
176+
alt_text: Optional[str] = None,
172177
nsfw: Optional[bool] = None,
173178
language_id: Union[int, LanguageType, None] = None,
174179
) -> Optional[dict]:
@@ -181,6 +186,7 @@ def edit(
181186
name (str, optional): Defaults to None.
182187
url (str, optional): Defaults to None.
183188
body (str, optional): Defaults to None.
189+
alt_text (str, optional): Defaults to None. Lemmy 0.19.4+
184190
nsfw (bool, optional): Defaults to None.
185191
language_id (Union[int, LanguageType], optional): Defaults to None.
186192
@@ -196,6 +202,8 @@ def edit(
196202
edit_post["url"] = url
197203
if body is not None:
198204
edit_post["body"] = body
205+
if alt_text is not None:
206+
edit_post["alt_text"] = alt_text
199207
if nsfw is not None:
200208
edit_post["nsfw"] = nsfw
201209
if language_id is not None:

0 commit comments

Comments
 (0)