# AutoRoom Templates Room names and text channel hints are rendered with a small Jinja subset implemented in `pcx_template.py`. It supports variable substitution, `if`, `elif`, `else` and `endif`, comparison operators, and two filters. ## Variables | Variable | Available in | Value | |---|---|---| | `username` | Name and hint | The owner's display name | | `game` | Name and hint | The game the owner is playing, or an empty string | | `dupenum` | Name | A counter starting at 1, incremented when a generated name already exists | | `mention` | Hint only | The owner's mention | `game` is read at creation time. Starting or stopping a game later does not rename the room. `dupenum` is computed by generating the name, checking for an existing channel with that name in the category, and incrementing until the name is free. A template that does not include `dupenum` therefore produces a duplicate name, and Discord allows duplicate channel names, so rooms can share a name. ## Default templates The `username` format: ``` {{username}}'s Room{% if dupenum > 1 %} ({{dupenum}}){% endif %} ``` The `game` format: ``` {{game}}{% if not game %}{{username}}'s Room{% endif %}{% if dupenum > 1 %} ({{dupenum}}){% endif %} ``` Both append the duplicate number only from the second duplicate onward, so the first room has no suffix. ## Conditionals The template engine accepts: ``` {% if game %}...{% elif username %}...{% else %}...{% endif %} ``` Conditions can compare a variable with a literal using `==`, `!=`, `>`, `<`, `>=` and `<=`, or test a variable for truth with `if game` and `if not game`. Undefined variables are treated as empty, so they are falsy. Whitespace inside tags is ignored. Tags may appear inline with text. ## Filters ``` {{username | lower}} {{game | upper}} ``` | Filter | Effect | |---|---| | `lower` | Lowercases the value | | `upper` | Uppercases the value | Filters are applied before insertion. Unknown filters raise a template error, which is reported to the administrator and the operation is cancelled. ## Hint message `[p]autoroomset modify text set