-
-
Save davidlj95/570933a25ea37ff69cf03fc568ddbea0 to your computer and use it in GitHub Desktop.
Telegram file sender via CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # tgm: TeleGram send Message | |
| # Sends a message via Telegram (using telegram-cli) | |
| # Author: davidlj95 | |
| # | |
| # Telegram CLI: | |
| # https://github.com/vysheng/tg | |
| # yay -S telegram-cli-git | |
| # Constants | |
| TELEGRAM_CLI="telegram-cli -W -I -C -e" | |
| # Check enough arguments or help | |
| if [ $# -lt 2 ]; then | |
| echo "Usage: tgm <nickname> <message>" | |
| echo "Sends the message to the Telegram nickname" | |
| exit 1 | |
| fi | |
| # Parse arguments | |
| nickname="$1" | |
| shift | |
| message="$@" | |
| # Find user id | |
| userid=$($TELEGRAM_CLI "contact_search $nickname" \ | |
| | grep -v '[[:space:]]user#' | grep -Eo 'user#[0-9]+') | |
| if [ $? -ne 0 ]; then echo Nickname \"$nickname\" not found; exit 1; fi | |
| # Do send file | |
| $TELEGRAM_CLI "msg $userid \"$message\"" &> /dev/null | |
| if [ $? -ne 0 ]; then echo Unable to send send messaget 1; fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Telegram File sender
Sends to the Telegram nickname the specified file
Usage