Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

An Espanso trigger for Discord's local time feature

License

Notifications You must be signed in to change notification settings

Noorts/espanso-discord-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation


Espanso Discord Time

An Espanso trigger for Discord its local time feature

InfoInstallationUsageLicense

Info

This repo contains a trigger for the text expander Espanso that eases the use of Discord its local time feature. Discord allows you to write a unix timestamp as → <t:1643787562> which will turn into the reader its local time equivelant (for me in CET February 2, 2022 8:39 AM). This can be useful to quickly share times and dates without the need for the readers to convert the time into their local timezone.

Installation

  • [For Linux] Install Modulo manually to enable the use of forms with Espanso. See the forms prerequisites page.
  • Make sure that the datetime and os modules are available in your Python environment (otherwise the script will fail when you run the trigger down below).
  • Run espanso edit in your terminal to configure your espanso matches.
  • Add the following trigger to the matches in your espanso config:
# Discord Local Time
  - trigger: "`dlt"
    replace: "<t:{{unixTimestamp}}> (← your local time)"
    vars:
      - name: mytime
        type: date
        params:
          format: "%a %d/%m/%Y - %H:%M"
      - name: form1
        type: form
        params:
          layout: |
            --- Your local time: ---
            {{name}}
          fields:
            name:
              default: "31-12-2022 23:59"
      - name: unixTimestamp
        type: script
        params:
          args:
            - python
            - "%CONFIG%/scripts/local_datetime_to_unix.py"
            - "$ESPANSO_FORM1_NAME"
  • Run espanso restart if the config wasn't reloaded automatically.
  • Navigate to your espanso config directory (espanso path) and add a scripts directory.
  • Add the local_datetime_to_unix.py script to your scripts directory.
  • Ready to use!

Usage

  • Activate espanso by typing in the trigger `dlt.
  • A form will pop up. Provide it a date and time in the provided default format. (Note: This is in D-M-YYYY format. Adjust the trigger and Python script if you want it in a different format).
  • Press enter (or Ctrl+Enter on MacOS).
  • The correct Discord timestamp string should now appear.

Alternatives

  • Get the unix timestamp manually (with a tool for example) and then write out your message.
  • For iOS use one of the following shortcuts #1 and #2.

License

This repo is licensed under The Unlicense.

About

An Espanso trigger for Discord's local time feature

Topics

Resources

License

Stars

Watchers

Forks

Languages