Paste #114964: Unnamed Denizen Script Paste

Date: 2023/09/08 01:48:47 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


chat_formatting:
  type: world
  debug: true
  enabled: true
  events:
    on player chats flagged:!player.chat.busy:
      ################## highlight player names, server locations and links
      - define textrpl <context.message.parse_color>
      - define symbols <list[?|,|:|;|!|.]>
      - define linkstart <list[https://|http://|www.|meta.|map.|forum.|login.]>
      - define linkend <list[.de|.com|.net|.info|.ly|.be|.fr|.is|.biz|.to|.co|.org|.uk|.at]>
      - definemap words:
          discord: <element[Discord: <&n>https://is.gd/cdiscord].custom_color[discord]>
          Orbis:  <element[Orbis].custom_color[location]>
          Moraira:  <element[Moraira].custom_color[location]>
          Ituria: <element[Ituria].custom_color[location]>
          Projektwelt: <element[Projektwelt].custom_color[server]>
          Regeln: <element[Regeln].custom_color[command].on_click[/regeln].on_hover[Klicken, um Regeln aufzurufen]>
      # loop through each word of message
      - foreach <context.message.split> as:word:
        # test if the word is a link (definition used for now with typical subdomains or domain endings)
        - if <[linkstart].filter_tag[<[word].starts_with[<[filter_value]>]>].any> || <[linkend].filter_tag[<[word].ends_with[<[filter_value]>]>].any>:
            # replace word with word + custom_color ... currently also highlights symbols like !,.,? at the end of the word, needs a fix
            - define textrpl <[textrpl].replace[<[word]>].with[<element[<[word]>].custom_color[link]>]>
            - foreach next
        # loop through every key in map "words"
        - foreach <[words].keys> as:replaceable:
          # if substring (length) of the currently indexed word matches with currently indexed key from words map
          - if <[word].substring[0,<[replaceable].length>]> == <[replaceable]>:
            - define textrpl <[textrpl].replace[<[word].substring[0,<[replaceable].length>]>].with[<[words.<[replaceable]>]>]>
            - foreach stop
      - define text "<player.proc[player_name_format]><&f><&co> <[textrpl]>"