mailman-telegram-webhook


Namemailman-telegram-webhook JSON
Version 0.8.0 PyPI version JSON
download
home_pagehttps://github.com/nanoy42/mailman-telegram-webhook
SummaryA small archiver sending message to telegram chats.
upload_time2022-12-27 16:04:08
maintainer
docs_urlNone
authorYoann Piétri
requires_python>=3.7,<4
licenseGPLv3
keywords mailman telegram webhook
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Mailman Telegram Webhook

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Code style black](https://img.shields.io/badge/code%20style-black-000000.svg)]("https://github.com/psf/black)
[![GitHub release](https://img.shields.io/github/release/nanoy42/dinomail.svg)](https://github.com/nanoy42/dinomail/releases/)
[![PyPI version fury.io](https://badge.fury.io/py/mailman-telegram-webhook.svg)](https://pypi.org/project/mailman-telegram-webhook/)

Want to send message to telegram chats when receiving an email on a mailing list ? This script do it for you.

## Installation

### Installation procedure

It is possible to install the package via pip :

```
pip install mailman-telegram-webhook
```

but make sure to install it at good location. The config file is also downloaded with the python file.

Create the folder `/usr/lib/python3/dist-packages/mailman_telegram_webhook` and copy the `__init__.py` file inside.

You will need the python-telegram-bot package (as specified in the dependencies files).

Then copy the `mailam-telegram-webhook.cfg` file to `/ect/mailman3` and edit it :

 * You need to set the token to a valid telegram bot token
 * If you want, you can specify a global chat id. Messages will be sent to this chat when the archiver is enabled for a mailing-list but no specific chat id is defined. If you leave this chat id empty, nothing happens when the archiver is enabled for a list without specific chat id.
 * You can specify specific chat id in `[list.list_name]` sections

Then copy the following code to mailman configuration (`/etc/mailman3/mailman.cfg`) :
```
[archiver.telegram_webhook]
class: mailman_telegram_webhook.Archiver
enable: yes
configuration: /etc/mailman3/mailman-telegram-webhook.cfg
```

Note : By default, the archiver will be enable on every list and if a global chat id is defined, messages will be sent from every list to this chat.

### Configuration examples

```
[global]
token = 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
chat_id = 103

[list.contact]
chat_id = 104
```

We suppose that contact@my.domain and webmaster@my.domain have the archiver enabled and the token `123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11` (which is an example token) is associated to myBot.

 * A mail sent to contact@my.domain will make myBot send a message to the chat with id 104.
 * A mail sent to webmaster@my.domain will make myBot send a message to the the chat with id 103.

```
[global]
token = 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11

[list.contact]
chat_id = 104
```

We suppose that contact@my.domain and webmaster@my.domain have the archiver enabled and the token `123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11` (which is an example token) is associated to myBot.

 * A mail sent to contact@my.domain will make myBot send a message to the chat with id 104.
 * A mail sent to webmaster@my.domain will make do nothing.

## Under the hood

This little script acts as an archiver (like Hyperkitty). When a message is received by mailman, if the archiver is configured and enabled on the mailing list, the message is passed to the archiver. The `archive_function` function just sends a message to telegram, according to the configuration.

The code is widely adapted from https://github.com/ondrejkolin/mailman_to_rocketchat and from Hyperkitty.

## FAQ

### How do I obtain a telegram bot token ?

You need to create a bot by speaking with @BotFather (see here for more information : https://core.telegram.org/bots)

### How do I find chat ids ?

You can chat with some specific bots to find the chat id or you can use the bot you created. Invite him on the group or chat with him and take a look to `https://api.telegram.org/bot<token>/getUpdates`

### What looks like the message on telegram ?

The message looks like `New message from {from} to {to} : {subject}`.

Example :

`New message from Yoann Pietri <me@nanoy.fr> to webmaster@my.domain : [Webmaster] Unable to access website`.

### Can I change the message on telegram ?

No. You cannot change it in the configuration but you can edit the message in the `__init__.py` file, in the `archive_message` function. 

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nanoy42/mailman-telegram-webhook",
    "name": "mailman-telegram-webhook",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4",
    "maintainer_email": "",
    "keywords": "mailman,telegram,webhook",
    "author": "Yoann Pi\u00e9tri",
    "author_email": "me@nanoy.fr",
    "download_url": "https://files.pythonhosted.org/packages/5a/af/1cdf087b92972f2c68375d17c6d70d6a11810a5d6d91162591bac10f38da/mailman_telegram_webhook-0.8.0.tar.gz",
    "platform": null,
    "description": "# Mailman Telegram Webhook\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Code style black](https://img.shields.io/badge/code%20style-black-000000.svg)](\"https://github.com/psf/black)\n[![GitHub release](https://img.shields.io/github/release/nanoy42/dinomail.svg)](https://github.com/nanoy42/dinomail/releases/)\n[![PyPI version fury.io](https://badge.fury.io/py/mailman-telegram-webhook.svg)](https://pypi.org/project/mailman-telegram-webhook/)\n\nWant to send message to telegram chats when receiving an email on a mailing list ? This script do it for you.\n\n## Installation\n\n### Installation procedure\n\nIt is possible to install the package via pip :\n\n```\npip install mailman-telegram-webhook\n```\n\nbut make sure to install it at good location. The config file is also downloaded with the python file.\n\nCreate the folder `/usr/lib/python3/dist-packages/mailman_telegram_webhook` and copy the `__init__.py` file inside.\n\nYou will need the python-telegram-bot package (as specified in the dependencies files).\n\nThen copy the `mailam-telegram-webhook.cfg` file to `/ect/mailman3` and edit it :\n\n * You need to set the token to a valid telegram bot token\n * If you want, you can specify a global chat id. Messages will be sent to this chat when the archiver is enabled for a mailing-list but no specific chat id is defined. If you leave this chat id empty, nothing happens when the archiver is enabled for a list without specific chat id.\n * You can specify specific chat id in `[list.list_name]` sections\n\nThen copy the following code to mailman configuration (`/etc/mailman3/mailman.cfg`) :\n```\n[archiver.telegram_webhook]\nclass: mailman_telegram_webhook.Archiver\nenable: yes\nconfiguration: /etc/mailman3/mailman-telegram-webhook.cfg\n```\n\nNote : By default, the archiver will be enable on every list and if a global chat id is defined, messages will be sent from every list to this chat.\n\n### Configuration examples\n\n```\n[global]\ntoken = 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\nchat_id = 103\n\n[list.contact]\nchat_id = 104\n```\n\nWe suppose that contact@my.domain and webmaster@my.domain have the archiver enabled and the token `123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11` (which is an example token) is associated to myBot.\n\n * A mail sent to contact@my.domain will make myBot send a message to the chat with id 104.\n * A mail sent to webmaster@my.domain will make myBot send a message to the the chat with id 103.\n\n```\n[global]\ntoken = 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\n\n[list.contact]\nchat_id = 104\n```\n\nWe suppose that contact@my.domain and webmaster@my.domain have the archiver enabled and the token `123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11` (which is an example token) is associated to myBot.\n\n * A mail sent to contact@my.domain will make myBot send a message to the chat with id 104.\n * A mail sent to webmaster@my.domain will make do nothing.\n\n## Under the hood\n\nThis little script acts as an archiver (like Hyperkitty). When a message is received by mailman, if the archiver is configured and enabled on the mailing list, the message is passed to the archiver. The `archive_function` function just sends a message to telegram, according to the configuration.\n\nThe code is widely adapted from https://github.com/ondrejkolin/mailman_to_rocketchat and from Hyperkitty.\n\n## FAQ\n\n### How do I obtain a telegram bot token ?\n\nYou need to create a bot by speaking with @BotFather (see here for more information : https://core.telegram.org/bots)\n\n### How do I find chat ids ?\n\nYou can chat with some specific bots to find the chat id or you can use the bot you created. Invite him on the group or chat with him and take a look to `https://api.telegram.org/bot<token>/getUpdates`\n\n### What looks like the message on telegram ?\n\nThe message looks like `New message from {from} to {to} : {subject}`.\n\nExample :\n\n`New message from Yoann Pietri <me@nanoy.fr> to webmaster@my.domain : [Webmaster] Unable to access website`.\n\n### Can I change the message on telegram ?\n\nNo. You cannot change it in the configuration but you can edit the message in the `__init__.py` file, in the `archive_message` function. \n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "A small archiver sending message to telegram chats.",
    "version": "0.8.0",
    "split_keywords": [
        "mailman",
        "telegram",
        "webhook"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "07e42565bf330a006a96acb2b838cee8",
                "sha256": "48667ac73cee22a946f341ba5a4895a11356b53fb50bab2b381d608ab7e81a3d"
            },
            "downloads": -1,
            "filename": "mailman_telegram_webhook-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "07e42565bf330a006a96acb2b838cee8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4",
            "size": 17029,
            "upload_time": "2022-12-27T16:04:06",
            "upload_time_iso_8601": "2022-12-27T16:04:06.969071Z",
            "url": "https://files.pythonhosted.org/packages/8d/83/8b2473c14981542c42a4317a2ac384bbae747a15812efb3f3233ac132d52/mailman_telegram_webhook-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "3adc98e495c7f7e1bd2ec0f6e814fc0b",
                "sha256": "68a854164b2f339fc5e03dd71410741aaee4f50138347ccdf90de36de0dcda5c"
            },
            "downloads": -1,
            "filename": "mailman_telegram_webhook-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3adc98e495c7f7e1bd2ec0f6e814fc0b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4",
            "size": 16538,
            "upload_time": "2022-12-27T16:04:08",
            "upload_time_iso_8601": "2022-12-27T16:04:08.928012Z",
            "url": "https://files.pythonhosted.org/packages/5a/af/1cdf087b92972f2c68375d17c6d70d6a11810a5d6d91162591bac10f38da/mailman_telegram_webhook-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-27 16:04:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "nanoy42",
    "github_project": "mailman-telegram-webhook",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "mailman-telegram-webhook"
}
        
Elapsed time: 0.04614s