diff --git a/utils.py b/utils.py index 5fd88bdff..b477c7442 100644 --- a/utils.py +++ b/utils.py @@ -4161,6 +4161,12 @@ def load_instance_software(base_dir: str) -> []: return {} +def chatbot_nicknames() -> []: + """Returns a list of common chatbot usernames/nicknames + """ + return ('gemini', 'chatgpt') + + def get_event_categories() -> []: """Returns event categories https://codeberg.org/fediverse/fep/src/branch/main/fep/8a8e/fep-8a8e.md diff --git a/webapp_post.py b/webapp_post.py index 4ca0018e5..3a10ec2ed 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -42,6 +42,7 @@ from textmode import text_mode_removals from quote import get_quote_toot_url from timeFunctions import date_from_string_format from timeFunctions import convert_published_to_local_timezone +from utils import chatbot_nicknames from utils import get_mutuals_of_person from utils import save_json from utils import remove_header_tags @@ -1578,7 +1579,8 @@ def _get_post_title_announce_html(base_dir: str, actor_type = get_actor_type(base_dir, attributed_to, person_cache) bot_prefix = '' if actor_type: - if actor_type != 'Person': + if actor_type != 'Person' or \ + announce_nickname in chatbot_nicknames(): bot_prefix = '[' + translate['Bot'] + '] ' _log_post_timing(enable_timing_log, post_start_time, '13.3.1') @@ -1730,7 +1732,11 @@ def _get_reply_html(translate: {}, bot_prefix = '' if actor_type: - if actor_type != 'Person': + reply_nickname = '' + if '@' in reply_nickname: + reply_nickname = reply_handle.split('@')[0] + if actor_type != 'Person' or \ + reply_nickname in chatbot_nicknames(): bot_prefix = '[' + translate['Bot'] + '] ' replying_to_str = _replying_to_with_scope(post_json_object, translate) @@ -2692,7 +2698,8 @@ def individual_post_as_html(signing_priv_key_pem: str, actor_type = get_actor_type(base_dir, post_actor, person_cache) bot_prefix = '' if actor_type: - if actor_type != 'Person': + if actor_type != 'Person' or \ + actor_nickname in chatbot_nicknames(): bot_prefix = '[' + translate['Bot'] + '] ' if display_name: diff --git a/webapp_profile.py b/webapp_profile.py index 650fb2248..c1fb5d566 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -23,6 +23,7 @@ from textmode import text_mode_removals from unicodetext import uninvert_text from unicodetext import standardize_text from occupation import get_occupation_name +from utils import chatbot_nicknames from utils import get_actor_type from utils import get_mutuals_of_person from utils import get_person_icon @@ -351,7 +352,8 @@ def html_profile_after_search(authorized: bool, # is this a bot account? if profile_json.get('type'): if isinstance(profile_json['type'], str): - if profile_json['type'] != 'Person': + if profile_json['type'] != 'Person' or \ + search_nickname in chatbot_nicknames(): display_name = '[' + translate['Bot'] + '] ' + display_name pronouns = get_pronouns(profile_json) @@ -1186,7 +1188,8 @@ def html_profile(signing_priv_key_pem: str, # is this a bot account? if profile_json.get('type'): if isinstance(profile_json['type'], str): - if profile_json['type'] != 'Person': + if profile_json['type'] != 'Person' or \ + nickname in chatbot_nicknames(): display_name = '[' + translate['Bot'] + '] ' + display_name domain_full = get_full_domain(domain, port) @@ -3924,7 +3927,8 @@ def _individual_follow_as_html(signing_priv_key_pem: str, actor_nickname, domain, display_name, False, translate) actor_type = get_actor_type(base_dir, follow_url, person_cache) - if actor_type != 'Person': + if actor_type != 'Person' or \ + actor_nickname in chatbot_nicknames(): display_name = '[' + translate['Bot'] + '] ' + display_name title_str = display_name