Paste #114897: Unnamed Denizen Script Paste

Date: 2023/09/07 06:48:04 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


chat_formatting:
  type: world
  debug: true
  enabled: true
    on player chats flagged:!player.chat.busy:
      - determine cancelled passively
      ################## highlight player names, server locations, links, etc.
      # 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
      - foreach <[locations]> as:loc:
          - define textrpl <[textrpl].replace[<[loc]>].with[<&c><[loc]><&r>]>
      # highlight server words
      - foreach <[serverwords]> as:words:
          - define textrpl <[textrpl].replace[<[words]>].with[<&color[<color[#DBF227]>]><[words]><&r>]>
      # higlight player names
      - foreach <server.online_players.exclude[<player>].include[<server.offline_players>]> as:player:
        - define name <[player].name>
        - if <[textrpl].contains_text[<[name]>]>:
          - define textrpl <[textrpl].replace[<[name]>].with[<&a><[name]><&r>]>
          - if <[player].is_online>:
            - playsound <[player]> sound:block_bell_use
      # highlight and replace misc words
      - 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 rules:
            - define textrpl <[textrpl].replace[<element[Regeln]>].with[<element[<&color[<color[#F26800]>]><&n>Regeln].on_click[/regeln].on_hover[Klicken, um Regeln aufzurufen]><&r>]>
            - define textrpl <[textrpl].replace[<element[rules]>].with[<element[<&color[<color[#F26800]>]><&n>Regeln].on_click[/regeln].on_hover[Klicken, um Regeln aufzurufen]><&r>]>
          - case Hilfe help:
            - define textrpl <[textrpl].replace[<element[Hilfe]>].with[<element[<&color[<color[#F26800]>]><&n>Hilfe].on_click[/hilfe].on_hover[Klicken, um Hilfe aufzurufen]><&r>]>
            - define textrpl <[textrpl].replace[<element[help]>].with[<element[<&color[<color[#F26800]>]><&n>Hilfe].on_click[/hilfe].on_hover[Klicken, um Hilfe aufzurufen]><&r>]>
          - case Support report:
            - define textrpl <[textrpl].replace[<element[Support]>].with[<element[<&color[<color[#F26800]>]><&n>Support].on_click[/support].on_hover[Klicken, um Support aufzurufen]><&r>]>
            - define textrpl <[textrpl].replace[<element[report]>].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]>"