Paste #114900: Unnamed Denizen Script Paste

Date: 2023/09/07 08:54:36 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:
      - determine cancelled passively
      ################## highlight player names, server locations and links
      # TODO: move this to a task script with data containers
      - 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]>
      - define locations <list[Orbis|Avarus|Arboretum|Kaos|Orcus|Zeitkapsel|Hortusmanium|Ituria|Moraira|Blackshire]>
      - define serverwords <list[Projektantrag|Fachgespräche|Gallerie|Projektwelt|Bauprojekt]>
      - define misc <list[Discord|Regeln|Hilfe|Support|Wiki|Guide]>
      - define symbols <list[?|,|:|;|!|.]>
      - define textrpl <context.message.parse_color>
      # loop through each word of the message and highlight links
      - foreach <context.message.split> as:arg:
        - if <[linkstart].filter_tag[<[arg].starts_with[<[filter_value]>]>].any> || <[linkend].filter_tag[<[arg].ends_with[<[filter_value]>]>].any>:
            - define textrpl <[textrpl].replace[<[arg]>].with[<&n><[arg]><&r>]>
        # filter out symbols like ?,:,!
        - if <[symbols].filter_tag[<[arg].ends_with[<[filter_value]>]>].any>:
            - define textrpl <[textrpl].replace[<[arg].to_list.last>].with[<&f><[arg].to_list.last><&r>]>
        # highlitght predefined locations
        - if <[locations].filter_tag[<[arg].starts_with[<[filter_value]>]>].any>:
          - define textrpl <[textrpl].replace[<[arg]>].with[<&c><[arg]><&r>]>
        # highlight server words
        - if <[serverwords].filter_tag[<[arg].starts_with[<[filter_value]>]>].any>:
          - define textrpl <[textrpl].replace[<[arg]>].with[<&color[<color[#DBF227]>]><[arg]><&r>]>
        # higlight player names
        - foreach <server.online_players.exclude[<player>].include[<server.offline_players>]> as:player:
          - define name <[player].name>
          - if <[arg].starts_with[<[name]>]>:
            - define textrpl <[textrpl].replace[<[arg]>].with[<&a><[name]><&r>]>
            - if <[player].is_online>:
              - playsound <[player]> sound:block_bell_use
        # highlight and replace misc words
        - if <[misc].filter_tag[<[arg].starts_with[<[filter_value]>]>].any>:
          - foreach <[misc]> as:misc:
            - choose <[misc]>:
              - case Discord:
                - define textrpl <[textrpl].replace_text[<element[Discord]>].with[<&color[<color[#5865F2]>]>Discord<&co> <&n>https://is.gd/cdiscord<&r>]>
              - case Regeln:
                - define textrpl <[textrpl].replace[<element[Regeln]>].with[<element[<&color[<color[#F26800]>]><&n>Regeln].on_click[/regeln].on_hover[Klicken, um Regeln aufzurufen]><&r>]>
              - case Hilfe:
                - define textrpl <[textrpl].replace[<element[Hilfe]>].with[<element[<&color[<color[#F26800]>]><&n>Hilfe].on_click[/hilfe].on_hover[Klicken, um Hilfe aufzurufen]><&r>]>
              - case Support:
                - define textrpl <[textrpl].replace[<element[Support]>].with[<element[<&color[<color[#F26800]>]><&n>Support].on_click[/support].on_hover[Klicken, um Support aufzurufen]><&r>]>
      ################### build the text
      - define text "<player.proc[player_name_format]><&f><&co> <[textrpl]>"