slack-time-localization-bot


Nameslack-time-localization-bot JSON
Version 0.1.12 PyPI version JSON
download
home_pagehttps://github.com/Slack-Time-Localization-Bot/Slack-Time-Localization-Bot
SummaryDetect temporal expressions in Slack messages ("tomorrow at 5 pm") and translate them for readers in other timezones.
upload_time2024-05-27 23:40:30
maintainerNone
docs_urlNone
authorPhilipp Hossner
requires_python<4.0,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Slack Time Localization Bot

[![codecov](https://codecov.io/gh/Slack-Time-Localization-Bot/Slack-Time-Localization-Bot/graph/badge.svg?token=RHMXGIH8Z9)](https://codecov.io/gh/Slack-Time-Localization-Bot/Slack-Time-Localization-Bot)

Detect temporal expressions in Slack messages (_tomorrow at 5 pm_) and translate them for readers in other timezones.

# Who is this for?

Many organizations have people around the globe communicating via Slack. 
That usually means a lot of different timezones.
So when people try to coordinate their activities a lot of time conversions have to happen when reading messages.
If you read `"How about tomorrow at 5 pm?"` you might need to do the following:

1. Check the author's timezone.
2. Check your own timezone (you usually know that already).
3. Convert `"tomorrow at 5 pm"` into your timezone.

This is cumbersome and prone to errors. Especially when dealing with summer/winter time.
This bot aims to help people with that.

The bot can easily be self-hosted and does not need to be reachable from the internet due to Slack's [socket mode](https://api.slack.com/apis/connections/socket).

## How It Works

Currently, the implementation is centered around Meta's [Duckling library](https://github.com/facebook/duckling). 
It can detect temporal expressions in [various languages](https://github.com/facebook/duckling/tree/main/Duckling/Dimensions) and extract a timestamp from it.
Since Duckling needs to know the language of the text in advance the library [lingua-py](https://github.com/pemistahl/lingua-py) is used to detect the language.
Big kudos to the authors of these libraries. Without them this bot could not have been developed in a feasible amount of time.

The Slack bot reads every message it has access to and uses Duckling to extract timestamps. 
For every possible reader of the message the bot then compares the timezone of the message author and the reader and translates the timestamp to the reader's timezone.
Finally, the bot will post an ephemeral message below the message with the detected temporal expressions and the timestamps translated to the local timezone.
That ephemeral message might look different for readers if they are not in the same timezone.

## Quickstart

[Create a Slack app](https://api.slack.com/start/quickstart) with the following manifest:

```yaml
display_information:
  name: Time Localization
  description: Detect temporal expressions in Slack messages ("tomorrow at 5 pm") and translate them for readers in other timezones.
  background_color: "#240b24"
features:
  app_home:
    home_tab_enabled: false
    messages_tab_enabled: true
    messages_tab_read_only_enabled: false
  bot_user:
    display_name: Time Localization
    always_online: true
oauth_config:
  scopes:
    bot:
      - app_mentions:read
      - channels:history
      - chat:write
      - groups:history
      - groups:write
      - im:history
      - im:write
      - mpim:history
      - mpim:write
      - users:read
      - channels:read
      - groups:read
      - mpim:read
      - im:read
settings:
  event_subscriptions:
    bot_events:
      - app_mention
      - channel_history_changed
      - group_history_changed
      - im_history_changed
      - message.channels
      - message.groups
      - message.im
      - message.mpim
  interactivity:
    is_enabled: true
  org_deploy_enabled: false
  socket_mode_enabled: true
  token_rotation_enabled: false
```

Create and get the bot token (under "OAuth & Permissions") and app token (under "Basic Information") for your Slack app.

```shell
pip install slack-time-localization-bot
```

> ℹ️ Currently only Linx x86_64 is supported

Finally you can run it with

```shell
export SLACK_BOT_TOKEN=xoxb-...
export SLACK_APP_TOKEN=xapp-...
export USER_CACHE_SIZE=500 # number of user profiles to cache in memory
export USER_CACHE_TTL=600 # number of seconds a user profile will be cached in memory
export PREFER_24h_INTERPRETATION=true # set to true if 5:00 usually means 5 in the morning and not late afternoon
export DEBUG=false # set to true to enable verbose logging including message contents
slack-time-localization-bot
```

You can now invite the bot to a conversation is slack and the bot will translate temporal expressions for every message.

## Running Tests

Install poetry and run

```shell
poetry install
poetry run pytest ./tests
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Slack-Time-Localization-Bot/Slack-Time-Localization-Bot",
    "name": "slack-time-localization-bot",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Philipp Hossner",
    "author_email": "philipp.hossner@posteo.de",
    "download_url": "https://files.pythonhosted.org/packages/fc/a6/a3020171697b817f71948be44d7e2ceb2cf04e9b3e9caf3991b1ec983d91/slack_time_localization_bot-0.1.12.tar.gz",
    "platform": null,
    "description": "# Slack Time Localization Bot\n\n[![codecov](https://codecov.io/gh/Slack-Time-Localization-Bot/Slack-Time-Localization-Bot/graph/badge.svg?token=RHMXGIH8Z9)](https://codecov.io/gh/Slack-Time-Localization-Bot/Slack-Time-Localization-Bot)\n\nDetect temporal expressions in Slack messages (_tomorrow at 5 pm_) and translate them for readers in other timezones.\n\n# Who is this for?\n\nMany organizations have people around the globe communicating via Slack. \nThat usually means a lot of different timezones.\nSo when people try to coordinate their activities a lot of time conversions have to happen when reading messages.\nIf you read `\"How about tomorrow at 5 pm?\"` you might need to do the following:\n\n1. Check the author's timezone.\n2. Check your own timezone (you usually know that already).\n3. Convert `\"tomorrow at 5 pm\"` into your timezone.\n\nThis is cumbersome and prone to errors. Especially when dealing with summer/winter time.\nThis bot aims to help people with that.\n\nThe bot can easily be self-hosted and does not need to be reachable from the internet due to Slack's [socket mode](https://api.slack.com/apis/connections/socket).\n\n## How It Works\n\nCurrently, the implementation is centered around Meta's [Duckling library](https://github.com/facebook/duckling). \nIt can detect temporal expressions in [various languages](https://github.com/facebook/duckling/tree/main/Duckling/Dimensions) and extract a timestamp from it.\nSince Duckling needs to know the language of the text in advance the library [lingua-py](https://github.com/pemistahl/lingua-py) is used to detect the language.\nBig kudos to the authors of these libraries. Without them this bot could not have been developed in a feasible amount of time.\n\nThe Slack bot reads every message it has access to and uses Duckling to extract timestamps. \nFor every possible reader of the message the bot then compares the timezone of the message author and the reader and translates the timestamp to the reader's timezone.\nFinally, the bot will post an ephemeral message below the message with the detected temporal expressions and the timestamps translated to the local timezone.\nThat ephemeral message might look different for readers if they are not in the same timezone.\n\n## Quickstart\n\n[Create a Slack app](https://api.slack.com/start/quickstart) with the following manifest:\n\n```yaml\ndisplay_information:\n  name: Time Localization\n  description: Detect temporal expressions in Slack messages (\"tomorrow at 5 pm\") and translate them for readers in other timezones.\n  background_color: \"#240b24\"\nfeatures:\n  app_home:\n    home_tab_enabled: false\n    messages_tab_enabled: true\n    messages_tab_read_only_enabled: false\n  bot_user:\n    display_name: Time Localization\n    always_online: true\noauth_config:\n  scopes:\n    bot:\n      - app_mentions:read\n      - channels:history\n      - chat:write\n      - groups:history\n      - groups:write\n      - im:history\n      - im:write\n      - mpim:history\n      - mpim:write\n      - users:read\n      - channels:read\n      - groups:read\n      - mpim:read\n      - im:read\nsettings:\n  event_subscriptions:\n    bot_events:\n      - app_mention\n      - channel_history_changed\n      - group_history_changed\n      - im_history_changed\n      - message.channels\n      - message.groups\n      - message.im\n      - message.mpim\n  interactivity:\n    is_enabled: true\n  org_deploy_enabled: false\n  socket_mode_enabled: true\n  token_rotation_enabled: false\n```\n\nCreate and get the bot token (under \"OAuth & Permissions\") and app token (under \"Basic Information\") for your Slack app.\n\n```shell\npip install slack-time-localization-bot\n```\n\n> \u2139\ufe0f Currently only Linx x86_64 is supported\n\nFinally you can run it with\n\n```shell\nexport SLACK_BOT_TOKEN=xoxb-...\nexport SLACK_APP_TOKEN=xapp-...\nexport USER_CACHE_SIZE=500 # number of user profiles to cache in memory\nexport USER_CACHE_TTL=600 # number of seconds a user profile will be cached in memory\nexport PREFER_24h_INTERPRETATION=true # set to true if 5:00 usually means 5 in the morning and not late afternoon\nexport DEBUG=false # set to true to enable verbose logging including message contents\nslack-time-localization-bot\n```\n\nYou can now invite the bot to a conversation is slack and the bot will translate temporal expressions for every message.\n\n## Running Tests\n\nInstall poetry and run\n\n```shell\npoetry install\npoetry run pytest ./tests\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Detect temporal expressions in Slack messages (\"tomorrow at 5 pm\") and translate them for readers in other timezones.",
    "version": "0.1.12",
    "project_urls": {
        "Homepage": "https://github.com/Slack-Time-Localization-Bot/Slack-Time-Localization-Bot",
        "Repository": "https://github.com/Slack-Time-Localization-Bot/Slack-Time-Localization-Bot"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1d51c11f920c48d7dbd6c468e03e4fc530b7e93a2a5c3a38275e4478b91655e2",
                "md5": "c19d0941aa1b0bcfba486a3cad90a2be",
                "sha256": "4a36a0e348115dc99e0aca03206ee7d73c5ec35c07b5d43d7f766c6d086d6cba"
            },
            "downloads": -1,
            "filename": "slack_time_localization_bot-0.1.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c19d0941aa1b0bcfba486a3cad90a2be",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 12065,
            "upload_time": "2024-05-27T23:40:28",
            "upload_time_iso_8601": "2024-05-27T23:40:28.833796Z",
            "url": "https://files.pythonhosted.org/packages/1d/51/c11f920c48d7dbd6c468e03e4fc530b7e93a2a5c3a38275e4478b91655e2/slack_time_localization_bot-0.1.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fca6a3020171697b817f71948be44d7e2ceb2cf04e9b3e9caf3991b1ec983d91",
                "md5": "b29e5fc77e1ce5ea2fa3953591d8c6fc",
                "sha256": "e05f8d3b9b0fa62faf6f8cb058ebb1ed6826d3a3f7826d38db673440ee6b26ac"
            },
            "downloads": -1,
            "filename": "slack_time_localization_bot-0.1.12.tar.gz",
            "has_sig": false,
            "md5_digest": "b29e5fc77e1ce5ea2fa3953591d8c6fc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 11276,
            "upload_time": "2024-05-27T23:40:30",
            "upload_time_iso_8601": "2024-05-27T23:40:30.376696Z",
            "url": "https://files.pythonhosted.org/packages/fc/a6/a3020171697b817f71948be44d7e2ceb2cf04e9b3e9caf3991b1ec983d91/slack_time_localization_bot-0.1.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-27 23:40:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Slack-Time-Localization-Bot",
    "github_project": "Slack-Time-Localization-Bot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "slack-time-localization-bot"
}
        
Elapsed time: 0.29566s