Simplest util to send messages and documents to Telegram
Project description
telegram-messager
Simplest util to send messages to Telegram.
Usage
Python
from telegram_messager import TelegramMessager
TM = TelegramMessager(token='token', chatid='chatid')
TM.send_text('message')
CLI
$ 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
- Create a bot by BotFather, get its
TOKEN
- Make public channel with
@SomeChannelName
, add this bot as admin - Get this
ChatId
by visiting https://api.telegram.org/botTOKEN/sendMessage?chat_id=@SomeChannelName&text=123 (with replaces):
TOKEN=t
CHANNEL=c
curl "https://api.telegram.org/bot${TOKEN}/sendMessage?chat_id=${CHANNEL}&text=123" | jq '.result.chat.id'
- Make channel private (if necessary)
- 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"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for telegram_messager-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70ea45879b9691434152074d7c8a1b8cfb4635d006676d4681cf27ce07537f7c |
|
MD5 | c780fb1acaac69031cf4bb8cdde58660 |
|
BLAKE2b-256 | e7be0e1f2be1f2b6cf2058de33767041e8de46d3f92032273286beb55215794e |