From 053d8f3b4f939a7ae2430c7847492f688a69abb5 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Mon, 30 Jul 2018 20:44:25 +0200 Subject: Add "untag" parameter to status_reply --- mastodon/Mastodon.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'mastodon') 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: @api_version("1.0.0", "2.3.0", __DICT_VERSION_STATUS) def status_reply(self, to_status, status, media_ids=None, sensitive=False, visibility=None, - spoiler_text=None, language=None, idempotency_key=None): + spoiler_text=None, language=None, idempotency_key=None, untag=False): """ Helper function - acts like status_post, but prepends the name of all the users that are being replied to to the status text and retains CW and visibility if not explicitly overridden. + + Set `untag` to True if you want the reply to only go to the user you + are replying to. """ user_id = self.__get_logged_in_id() # Determine users to mention mentioned_accounts = collections.OrderedDict() mentioned_accounts[to_status.account.id] = to_status.account.acct - for account in to_status.mentions: - if account.id != user_id and not account.id in mentioned_accounts.keys(): - mentioned_accounts[account.id] = account.acct + + if not untag: + for account in to_status.mentions: + if account.id != user_id and not account.id in mentioned_accounts.keys(): + mentioned_accounts[account.id] = account.acct # Join into one piece of text. The space is added inside because of self-replies. status = "".join(map(lambda x: "@" + x + " ", mentioned_accounts.values())) + status -- cgit v1.2.3