diff options
author | Lorenz Diener <[email protected]> | 2018-07-30 20:44:25 +0200 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2018-07-30 20:44:25 +0200 |
commit | 053d8f3b4f939a7ae2430c7847492f688a69abb5 (patch) | |
tree | 778b192a3feef448d584fedc9c0c1fbfb71c3414 /mastodon | |
parent | 087fb249dad981be4dfbfea13a842bfcc1cd8fd7 (diff) | |
download | mastodon.py-053d8f3b4f939a7ae2430c7847492f688a69abb5.tar.gz |
Add "untag" parameter to status_reply
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index f524c61..4efa475 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -1191,20 +1191,25 @@ class Mastodon: | |||
1191 | 1191 | ||
1192 | @api_version("1.0.0", "2.3.0", __DICT_VERSION_STATUS) | 1192 | @api_version("1.0.0", "2.3.0", __DICT_VERSION_STATUS) |
1193 | def status_reply(self, to_status, status, media_ids=None, sensitive=False, visibility=None, | 1193 | def status_reply(self, to_status, status, media_ids=None, sensitive=False, visibility=None, |
1194 | spoiler_text=None, language=None, idempotency_key=None): | 1194 | spoiler_text=None, language=None, idempotency_key=None, untag=False): |
1195 | """ | 1195 | """ |
1196 | Helper function - acts like status_post, but prepends the name of all | 1196 | Helper function - acts like status_post, but prepends the name of all |
1197 | the users that are being replied to to the status text and retains | 1197 | the users that are being replied to to the status text and retains |
1198 | CW and visibility if not explicitly overridden. | 1198 | CW and visibility if not explicitly overridden. |
1199 | |||
1200 | Set `untag` to True if you want the reply to only go to the user you | ||
1201 | are replying to. | ||
1199 | """ | 1202 | """ |
1200 | user_id = self.__get_logged_in_id() | 1203 | user_id = self.__get_logged_in_id() |
1201 | 1204 | ||
1202 | # Determine users to mention | 1205 | # Determine users to mention |
1203 | mentioned_accounts = collections.OrderedDict() | 1206 | mentioned_accounts = collections.OrderedDict() |
1204 | mentioned_accounts[to_status.account.id] = to_status.account.acct | 1207 | mentioned_accounts[to_status.account.id] = to_status.account.acct |
1205 | for account in to_status.mentions: | 1208 | |
1206 | if account.id != user_id and not account.id in mentioned_accounts.keys(): | 1209 | if not untag: |
1207 | mentioned_accounts[account.id] = account.acct | 1210 | for account in to_status.mentions: |
1211 | if account.id != user_id and not account.id in mentioned_accounts.keys(): | ||
1212 | mentioned_accounts[account.id] = account.acct | ||
1208 | 1213 | ||
1209 | # Join into one piece of text. The space is added inside because of self-replies. | 1214 | # Join into one piece of text. The space is added inside because of self-replies. |
1210 | status = "".join(map(lambda x: "@" + x + " ", mentioned_accounts.values())) + status | 1215 | status = "".join(map(lambda x: "@" + x + " ", mentioned_accounts.values())) + status |