telegram-messager


Nametelegram-messager JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/PasaOpasen/telegram-messager
SummarySimplest util to send messages and documents to Telegram
upload_time2024-02-05 09:40:56
maintainerDemetry Pascal
docs_urlNone
authorDemetry Pascal
requires_python
licenseMIT
keywords telegram bot
VCS
bugtrack_url
requirements requests typing_extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # telegram-messager


Simplest util to send messages to Telegram.

## Usage

### Python

```python
from telegram_messager import TelegramMessager

TM = TelegramMessager(token='token', chatid='chatid')
TM.send_text('message')
```

### CLI

```shell
$ tgmg -h 

usage: tgmg [-h] [--text TEXT] [--files FILES [FILES ...]] [--token TOKEN] [--token-file TOKEN_FILE]
            [--token-env-var TOKEN_ENV_VAR] [--chat CHAT] [--chat-file CHAT_FILE] [--chat-env-var CHAT_ENV_VAR]

Simplest tool to send messages using Telegram HTTP API

optional arguments:
  -h, --help            show this help message and exit
  --text TEXT, -s TEXT  text to send (default: )
  --files FILES [FILES ...], -f FILES [FILES ...]
                        documents to send (default: None)
  --token TOKEN, -t TOKEN
                        bot token (default: None)
  --token-file TOKEN_FILE
                        bot token file to read token from; will be used if no --token specified (default: None)
  --token-env-var TOKEN_ENV_VAR
                        bot token environment variable name to read from; will be used if neither --token nor --token-file
                        specified (default: TELEGRAM_MESSAGER_BOT_TOKEN)
  --chat CHAT, -c CHAT  chat id (default: None)
  --chat-file CHAT_FILE
                        chat id file to read the value from (default: None)
  --chat-env-var CHAT_ENV_VAR
                        chat id environment variable name to read from (default: TELEGRAM_MESSAGER_CHAR_ID)
```


## How to create bot and channel for it

1. Create a bot by BotFather, get its `TOKEN`
2. Make public channel with `@SomeChannelName`, add this bot as admin
3. Get this `ChatId` by visiting https://api.telegram.org/botTOKEN/sendMessage?chat_id=@SomeChannelName&text=123 (with replaces):
```sh
TOKEN=t
CHANNEL=c
curl "https://api.telegram.org/bot${TOKEN}/sendMessage?chat_id=${CHANNEL}&text=123" | jq '.result.chat.id'
```
4. Make channel private (if necessary)
5. Now u can send messages to this channel by command `curl -s -X POST https://api.telegram.org/botTOKEN/sendMessage -d chat_id=ChatId -d text="your message"`

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PasaOpasen/telegram-messager",
    "name": "telegram-messager",
    "maintainer": "Demetry Pascal",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "telegram,bot",
    "author": "Demetry Pascal",
    "author_email": "qtckpuhdsa@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e9/ba/387f9b84fe1a20821383e1597e5abf74f9087f96f211e4f89436b5e96323/telegram_messager-0.0.3.tar.gz",
    "platform": null,
    "description": "# telegram-messager\n\n\nSimplest util to send messages to Telegram.\n\n## Usage\n\n### Python\n\n```python\nfrom telegram_messager import TelegramMessager\n\nTM = TelegramMessager(token='token', chatid='chatid')\nTM.send_text('message')\n```\n\n### CLI\n\n```shell\n$ tgmg -h \n\nusage: tgmg [-h] [--text TEXT] [--files FILES [FILES ...]] [--token TOKEN] [--token-file TOKEN_FILE]\n            [--token-env-var TOKEN_ENV_VAR] [--chat CHAT] [--chat-file CHAT_FILE] [--chat-env-var CHAT_ENV_VAR]\n\nSimplest tool to send messages using Telegram HTTP API\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --text TEXT, -s TEXT  text to send (default: )\n  --files FILES [FILES ...], -f FILES [FILES ...]\n                        documents to send (default: None)\n  --token TOKEN, -t TOKEN\n                        bot token (default: None)\n  --token-file TOKEN_FILE\n                        bot token file to read token from; will be used if no --token specified (default: None)\n  --token-env-var TOKEN_ENV_VAR\n                        bot token environment variable name to read from; will be used if neither --token nor --token-file\n                        specified (default: TELEGRAM_MESSAGER_BOT_TOKEN)\n  --chat CHAT, -c CHAT  chat id (default: None)\n  --chat-file CHAT_FILE\n                        chat id file to read the value from (default: None)\n  --chat-env-var CHAT_ENV_VAR\n                        chat id environment variable name to read from (default: TELEGRAM_MESSAGER_CHAR_ID)\n```\n\n\n## How to create bot and channel for it\n\n1. Create a bot by BotFather, get its `TOKEN`\n2. Make public channel with `@SomeChannelName`, add this bot as admin\n3. Get this `ChatId` by visiting https://api.telegram.org/botTOKEN/sendMessage?chat_id=@SomeChannelName&text=123 (with replaces):\n```sh\nTOKEN=t\nCHANNEL=c\ncurl \"https://api.telegram.org/bot${TOKEN}/sendMessage?chat_id=${CHANNEL}&text=123\" | jq '.result.chat.id'\n```\n4. Make channel private (if necessary)\n5. Now u can send messages to this channel by command `curl -s -X POST https://api.telegram.org/botTOKEN/sendMessage -d chat_id=ChatId -d text=\"your message\"`\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simplest util to send messages and documents to Telegram",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/PasaOpasen/telegram-messager"
    },
    "split_keywords": [
        "telegram",
        "bot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e7be0e1f2be1f2b6cf2058de33767041e8de46d3f92032273286beb55215794e",
                "md5": "c780fb1acaac69031cf4bb8cdde58660",
                "sha256": "70ea45879b9691434152074d7c8a1b8cfb4635d006676d4681cf27ce07537f7c"
            },
            "downloads": -1,
            "filename": "telegram_messager-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c780fb1acaac69031cf4bb8cdde58660",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4986,
            "upload_time": "2024-02-05T09:40:55",
            "upload_time_iso_8601": "2024-02-05T09:40:55.033030Z",
            "url": "https://files.pythonhosted.org/packages/e7/be/0e1f2be1f2b6cf2058de33767041e8de46d3f92032273286beb55215794e/telegram_messager-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e9ba387f9b84fe1a20821383e1597e5abf74f9087f96f211e4f89436b5e96323",
                "md5": "c08f9b3a608022fb0fdffc9c4512b696",
                "sha256": "270d75d2c337d79e6163b1df5d3c7bdf57d76e9e536ab6506e0d2c275ce7c443"
            },
            "downloads": -1,
            "filename": "telegram_messager-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c08f9b3a608022fb0fdffc9c4512b696",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4308,
            "upload_time": "2024-02-05T09:40:56",
            "upload_time_iso_8601": "2024-02-05T09:40:56.945047Z",
            "url": "https://files.pythonhosted.org/packages/e9/ba/387f9b84fe1a20821383e1597e5abf74f9087f96f211e4f89436b5e96323/telegram_messager-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-05 09:40:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PasaOpasen",
    "github_project": "telegram-messager",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "typing_extensions",
            "specs": []
        }
    ],
    "lcname": "telegram-messager"
}
        
Elapsed time: 0.18373s