Add torrent to Transmission by Telegram Bot

Hello!
I am trying to write automation for adding torrents to the transmission from the telegram bot. Integrations with telegram and transmission works well, but apparently there are some problems with the template. The template is needed to remove quotes at the beginning and at the end of {{ trigger.event.data.args }}.

- alias: Telegram Bot Add Torrent
  trigger:
    - platform: event
      event_type: telegram_command
      event_data:
        command: '/add_torrent'
  action:
    - service: transmission.add_torrent
      data_template:
        name: Transmission
        torrent: >
          {% set string = trigger.event.data.args %}
          {% set string = string[:-1] %}
          {% set string = string[1:] %}
          {{ string }}

Well… Finally I’ll try regular expressions and it work! Although this is not the answer to my question, but a cheating.
My code:

- alias: Telegram Bot Add Torrent
  initial_state: True
  trigger:
    - platform: event
      event_type: telegram_command
      event_data:
        command: '/add_torrent'
  action:
    - service: transmission.add_torrent
      data_template:
        name: Transmission
        torrent: '{{ trigger.event.data.args  | regex_replace(find="^..", replace="", ignorecase=False) | regex_replace(find="..$", replace="", ignorecase=False) }}'